GL Studio API
gls_runtime_font_base.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsRuntimeFontBase class and related classes.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef INCLUDE_GLS_RUNTIME_FONT_BASE_H
41 #define INCLUDE_GLS_RUNTIME_FONT_BASE_H
42 
43 #include "gls_font_base.h"
44 #include <memory>
45 
46 // autoptr is deprecated
47 #if __GNUC__ == 5
48 #pragma GCC diagnostic push
49 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50 #endif
51 
52 namespace disti
53 {
54 
55 // Forward Declaration
56 class RuntimeGlyphGenerationFont;
57 
58 //===========================================================================
59 /**
60 * The GlsRuntimeFontBase class provides a specific font face for use within the GL
61 * Studio. The font face is determined at construction time by the
62 * parameters passed in by the creator of the GlsFontBase instance. Specific
63 * instances should be wrapped in a singleton object wrapper, as there is
64 * no reason to have more than one instance of the exact same face (meaning
65 * font family, style, and point size.)
66 *
67 * Once instanced, a GlsFontRenderer object can be used to render characters in
68 * Open GL at specific locations and with several different text effects.
69 *
70 * \sa GlsFontRenderer
71 */
72 //===========================================================================
74 {
75 public:
76 
77  /** char index associated with absent glyph */
78  static const unsigned short NO_GLYPH;
79 
80  //-----------------------------------------------------------------------
81  /// Attributes of the specific font
82  //-----------------------------------------------------------------------
84 
85  //-----------------------------------------------------------------------
86  /// Character attributes. One item for each character in the set.
87  //-----------------------------------------------------------------------
89 
90  typedef std::vector<CharAttrRuntime_t> AttrContRuntime_t;
91 
92  /** Class Constructor
93  * \param family the family name of the font.
94  * \param style the style name of the font.
95  * \param ptSize the point size of the font.
96  * \param fontPath the path and filename of the font file to load.
97  * \param maxCharWidth the maximum width of the largest character.
98  * \param maxCharHeight the maximum height of the largest character.
99  * \param descender the maximum descender of the largest character.
100  */
101  GLS_EXPORT GlsRuntimeFontBase( const char* family, const char* style, const unsigned int ptSize, const char* fontPath,
102  const unsigned int maxCharWidth, const unsigned int maxCharHeight, const unsigned int descender );
103 
104  /** Determine if font was instantiated correctly
105  * \return true if valid else false
106  */
107  GLS_EXPORT bool IsValid( void ) const;
108 
109  /** Gets the runtime character attribute for the given char
110  * \param c The character to retrieve attributes for.
111  * \returns The attributes for the character else char attributes for first character
112  * in font if char is not in range for this font
113  */
114  GLS_EXPORT const CharAttrRuntime_t& CharAttrRuntime( Char_t c ) const;
115 
116  /** Gets a pointer to the internal data needed for runtime glyph generation.
117  * \return A pointer to the internal data needed for runtime glyph generation.
118  */
119  GLS_EXPORT RuntimeGlyphGenerationFont* GetRuntimeGlyphGenerationFont( );
120 
121 protected:
122 
123  /**
124  * Class Destructor. This is protected so that no one can delete a font
125  * except via the font manager GlsFontMan.
126  * It is not virtual because we want to avoid calling destructors on unloaded font code,
127  * and it is not needed.
128  */
129  GLS_EXPORT ~GlsRuntimeFontBase();
130 
131  friend class GlsFontMan;
132 
133  FontAttrRuntime_t _fontAttrRuntime; /**< runtime font attributes */
134 
135  mutable CharAttrRuntime_t _charAttrRuntime; /**< runtime char attributes */
136 
137  bool _isValid; /**< true if font is valid else false */
138 
139  /** Pointer to the internal data needed for runtime glyph generation. */
140  std::auto_ptr< RuntimeGlyphGenerationFont > _runtimeGlyphGenerationFont;
141 
142 private:
143 
144  //-----------------------------------------------------------------------
145  // Prevent copies
146  //-----------------------------------------------------------------------
148  GlsRuntimeFontBase& operator=(const GlsRuntimeFontBase&);
149 
150 }; // end class GlsRuntimeFontBase
151 
152 } // end namespace disti
153 
154 #if __GNUC__ == 5
155 #pragma GCC diagnostic pop
156 #endif
157 
158 #endif
GlsRuntimeFontBase(const char *family, const char *style, const unsigned int ptSize, const char *fontPath, const unsigned int maxCharWidth, const unsigned int maxCharHeight, const unsigned int descender)
The disti::GlsFontBase class and related classes.
static const unsigned short NO_GLYPH
Definition: gls_runtime_font_base.h:78
bool IsValid(void) const
GlsFontBase::CharAttr_t CharAttrRuntime_t
Character attributes. One item for each character in the set.
Definition: gls_runtime_font_base.h:88
FontAttrRuntime_t _fontAttrRuntime
Definition: gls_runtime_font_base.h:133
std::auto_ptr< RuntimeGlyphGenerationFont > _runtimeGlyphGenerationFont
Definition: gls_runtime_font_base.h:140
bool _isValid
Definition: gls_runtime_font_base.h:137
const CharAttrRuntime_t & CharAttrRuntime(Char_t c) const
Attributes of the specific font.
Definition: gls_font_base.h:97
Definition: gls_runtime_font_base.h:73
Definition: gls_font_man.h:63
CharAttrRuntime_t _charAttrRuntime
Definition: gls_runtime_font_base.h:135
Character attributes. One item for each character in the set.
Definition: gls_font_base.h:127
GlsFontBase::FontAttr_t FontAttrRuntime_t
Attributes of the specific font.
Definition: gls_runtime_font_base.h:83
Definition: bmpimage.h:46
RuntimeGlyphGenerationFont * GetRuntimeGlyphGenerationFont()
Definition: gls_font_base.h:87