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 "scoped_ptr.h"
45 
46 namespace disti
47 {
48 
49 // Forward Declaration
50 class RuntimeGlyphGenerationFont;
51 
52 //===========================================================================
53 /**
54 * The GlsRuntimeFontBase class provides a specific font face for use within the GL
55 * Studio. The font face is determined at construction time by the
56 * parameters passed in by the creator of the GlsFontBase instance. Specific
57 * instances should be wrapped in a singleton object wrapper, as there is
58 * no reason to have more than one instance of the exact same face (meaning
59 * font family, style, and point size.)
60 *
61 * Once instanced, a GlsFontRenderer object can be used to render characters in
62 * Open GL at specific locations and with several different text effects.
63 *
64 * \sa GlsFontRenderer
65 */
66 //===========================================================================
68 {
69 public:
70 
71  /** char index associated with absent glyph */
72  static const unsigned short NO_GLYPH;
73 
74  //-----------------------------------------------------------------------
75  /// Attributes of the specific font
76  //-----------------------------------------------------------------------
78 
79  //-----------------------------------------------------------------------
80  /// Character attributes. One item for each character in the set.
81  //-----------------------------------------------------------------------
83 
84  typedef std::vector<CharAttrRuntime_t> AttrContRuntime_t;
85 
86  /** Class Constructor
87  * \param family the family name of the font.
88  * \param style the style name of the font.
89  * \param ptSize the point size of the font.
90  * \param fontPath the path and filename of the font file to load.
91  * \param maxCharWidth the maximum width of the largest character.
92  * \param maxCharHeight the maximum height of the largest character.
93  * \param descender the maximum descender of the largest character.
94  */
95  GLS_EXPORT GlsRuntimeFontBase( const char* family, const char* style, const unsigned int ptSize, const char* fontPath,
96  const unsigned int maxCharWidth, const unsigned int maxCharHeight, const unsigned int descender );
97 
98  /** Determine if font was instantiated correctly
99  * \return true if valid else false
100  */
101  GLS_EXPORT bool IsValid( void ) const;
102 
103  /** Gets the runtime character attribute for the given char
104  * \param c The character to retrieve attributes for.
105  * \returns The attributes for the character else char attributes for first character
106  * in font if char is not in range for this font
107  */
108  GLS_EXPORT const CharAttrRuntime_t& CharAttrRuntime( Char_t c ) const;
109 
110  /** Gets a pointer to the internal data needed for runtime glyph generation.
111  * \return A pointer to the internal data needed for runtime glyph generation.
112  */
113  GLS_EXPORT RuntimeGlyphGenerationFont* GetRuntimeGlyphGenerationFont( );
114 
115 protected:
116 
117  /**
118  * Class Destructor. This is protected so that no one can delete a font
119  * except via the font manager GlsFontMan.
120  * It is not virtual because we want to avoid calling destructors on unloaded font code,
121  * and it is not needed.
122  */
123  GLS_EXPORT ~GlsRuntimeFontBase();
124 
125  friend class GlsFontMan;
126 
127  FontAttrRuntime_t _fontAttrRuntime; /**< runtime font attributes */
128 
129  mutable CharAttrRuntime_t _charAttrRuntime; /**< runtime char attributes */
130 
131  bool _isValid; /**< true if font is valid else false */
132 
133  /** Pointer to the internal data needed for runtime glyph generation. */
135 
136 private:
137 
138  //-----------------------------------------------------------------------
139  // Prevent copies
140  //-----------------------------------------------------------------------
142  GlsRuntimeFontBase& operator=(const GlsRuntimeFontBase&);
143 
144 }; // end class GlsRuntimeFontBase
145 
146 } // end namespace disti
147 
148 #endif
ScopedPtr< RuntimeGlyphGenerationFont > _runtimeGlyphGenerationFont
Definition: gls_runtime_font_base.h:134
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:72
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:82
FontAttrRuntime_t _fontAttrRuntime
Definition: gls_runtime_font_base.h:127
bool _isValid
Definition: gls_runtime_font_base.h:131
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:67
Definition: gls_font_man.h:63
CharAttrRuntime_t _charAttrRuntime
Definition: gls_runtime_font_base.h:129
A smart pointer with unique ownership – poor man's std::unique_ptr.
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:77
Definition: bmpimage.h:46
RuntimeGlyphGenerationFont * GetRuntimeGlyphGenerationFont()
Definition: gls_font_base.h:87