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