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