GL Studio C++ Runtime 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) 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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40#ifndef INCLUDED_GLS_FONT_MAN_H
41#define INCLUDED_GLS_FONT_MAN_H
42
43#include "gls_gl.h"
44#include <map>
45#include <string>
46
47namespace disti
48{
49/** prefix used for font name to indicate that font is a Unicode font */
50#define GLS_UNICODE_FONT_NAME_PREFIX "$$GLS_UNICODE_FONT$$"
51
52/** prefix used for font name to indicate that font is a Runtime font */
53#define GLS_RUNTIME_FONT_NAME_PREFIX "$$GLS_RUNTIME_FONT$$"
54
55class GlsFontBase;
56class GlsGlobals;
57
58/** The GlsFontMan class provides a manager singleton for registering and retrieving fonts. */
60{
61public:
62 /// \return A reference to the singleton factory object.
64
65 // Lifetime of singleton managed by GlsGlobals
66 friend class GlsGlobals;
67
68 /** Class Destructor. */
70
71 /** Retrieve the specified font object.
72 * \param name font family name, eg. Arial
73 * \param style font style, eg. Bold
74 * \param ptSize point size
75 *
76 * \return a pointer to the font object, or 0 if the font has not been
77 * registered with the factory.
78 */
80 const std::string& name,
81 const std::string& style,
82 GLuint ptSize ) const;
83
84 /** Register the specified font object.
85 * \param font font object
86 */
88
89 /** Notify the font manager that the particular font is being used so
90 * that its reference count can be managed. If the font is not already
91 * being managed, it will be added to the manager's font repository first.
92 * The font's reference count will be incremented by 1. The Use and
93 * Release reference counting methods are separate from the Font and
94 * Register methods so that reference counting of fonts can be optional.
95 * For example, reference counting may be necessary in the GL Studio
96 * editor but not desired at run-time.
97 *
98 * \param font font object
99 */
101
102 /** Notify the font manager that the particular font is no longer being
103 * used by the caller so that its reference count can be managed.
104 * The font's reference count will be decremented by 1 and if there are
105 * no longer any users, the font object will be deleted. Only use
106 * Release subsequent to using the Use call or the reference counting
107 * will not work.
108 *
109 * \param font font object
110 */
112
113private:
114 struct FontRef_t
115 {
116 GlsFontBase* font;
117 GLint refCount;
118 FontRef_t()
119 : font( 0 )
120 , refCount( 0 )
121 {}
122 FontRef_t( GlsFontBase* newFont, GLint initialCount )
123 : font( newFont )
124 , refCount( initialCount )
125 {}
126 };
127
128 typedef std::map<std::string, FontRef_t> FontMap_t;
129
130 /** Container of all registered fonts */
131 FontMap_t _fonts;
132
133 /** Class Constructor. */
134 GLS_EXPORT GlsFontMan();
135
136 //-----------------------------------------------------------------------
137 // Prevent copies
138 //-----------------------------------------------------------------------
139 GlsFontMan( const GlsFontMan& );
140 GlsFontMan& operator=( const GlsFontMan& );
141
142}; // end class GlsFontMan
143
144} // end namespace disti
145
146#endif
Definition: gls_font_base.h:87
Definition: gls_font_man.h:60
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:1917
The gls_gl.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47