GL Studio API
gls_font_man.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsFontMan class.
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 _GLS_FONT_MAN_H
41 #define _GLS_FONT_MAN_H
42 
43 #include <map>
44 #include <string>
45 #include "gls_gl.h"
46 
47 namespace disti
48 {
49 
50 /** prefix used for font name to indicate that font is a Unicode font */
51 #define GLS_UNICODE_FONT_NAME_PREFIX "$$GLS_UNICODE_FONT$$"
52 
53 /** prefix used for font name to indicate that font is a Runtime font */
54 #define GLS_RUNTIME_FONT_NAME_PREFIX "$$GLS_RUNTIME_FONT$$"
55 
56 class GlsFontBase;
57 
58 //---------------------------------------------------------------------------
59 /**
60 * The GlsFontMan class provides a manager singleton for registering and
61 * retrieving fonts.
62 */
63 class GlsFontMan
64 {
65 public:
66  /** Provides access to the singleton factory object. */
67  GLS_EXPORT static GlsFontMan& Instance();
68 
69  /** Class Destructor. */
70  GLS_EXPORT ~GlsFontMan();
71 
72  /** Retrieve the specified font object.
73  * \param name font family name, eg. Arial
74  * \param style font style, eg. Bold
75  * \param ptSize point size
76  *
77  * \return a pointer to the font object, or 0 if the font has not been
78  * registered with the factory.
79  */
80  GLS_EXPORT GlsFontBase* Font(
81  const std::string& name,
82  const std::string& style,
83  GLuint ptSize) const;
84 
85  /** Register the specified font object.
86  * \param font font object
87  */
88  GLS_EXPORT void Register(GlsFontBase* font);
89 
90  /** Notify the font manager that the particular font is being used so
91  * that its reference count can be managed. If the font is not already
92  * being managed, it will be added to the manager's font repository first.
93  * The font's reference count will be incremented by 1. The Use and
94  * Release reference counting methods are separate from the Font and
95  * Register methods so that reference counting of fonts can be optional.
96  * For example, reference counting may be necessary in the GL Studio
97  * editor but not desired at run-time.
98  *
99  * \param font font object
100  */
101  GLS_EXPORT void Use(GlsFontBase* font);
102 
103  /** Notify the font manager that the particular font is no longer being
104  * used by the caller so that its reference count can be managed.
105  * The font's reference count will be decremented by 1 and if there are
106  * no longer any users, the font object will be deleted. Only use
107  * Release subsequent to using the Use call or the reference counting
108  * will not work.
109  *
110  * \param font font object
111  */
112  GLS_EXPORT void Release(GlsFontBase* font);
113 
114 private:
115 
116  struct FontRef_t
117  {
118  GlsFontBase* font;
119  GLint refCount;
120  FontRef_t() : font(0), refCount(0) {}
121  FontRef_t(GlsFontBase* newFont, GLint initialCount) :
122  font(newFont), refCount(initialCount) {}
123  };
124 
125  typedef std::map<std::string, FontRef_t> FontMap_t;
126 
127  /** Container of all registered fonts */
128  FontMap_t _fonts;
129 
130  /** Class Constructor. */
131  GLS_EXPORT GlsFontMan(void);
132 
133  //-----------------------------------------------------------------------
134  // Prevent copies
135  //-----------------------------------------------------------------------
136  GlsFontMan(const GlsFontMan&);
137  GlsFontMan& operator=(const GlsFontMan&);
138 
139 }; // end class GlsFontMan
140 
141 
142 } // end namespace disti
143 
144 #endif
GlsFontBase * Font(const std::string &name, const std::string &style, GLuint ptSize) const
void Use(GlsFontBase *font)
void Release(GlsFontBase *font)
static GlsFontMan & Instance()
Definition: gls_font_man.h:63
Definition: bmpimage.h:46
void Register(GlsFontBase *font)
Definition: gls_font_base.h:87
The gls_gl.