| 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
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 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
47 namespace 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
55 class GlsFontBase;
56 class GlsGlobals;
57
58/** The GlsFontMan class provides a manager singleton for registering and retrieving fonts. */
59 class GlsFontMan
60{
61 public:
62 /// \return A reference to the singleton factory object.
63 GLS_EXPORT static GlsFontMan& Instance();
64
65 // Lifetime of singleton managed by GlsGlobals
66 friend class GlsGlobals;
67
68 /** Class Destructor. */
69 GLS_EXPORT ~GlsFontMan();
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 */
79 GLS_EXPORT GlsFontBase* Font(
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 */
87 GLS_EXPORT void Register( GlsFontBase* font );
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 */
100 GLS_EXPORT void Use( GlsFontBase* font );
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 */
111 GLS_EXPORT void Release( GlsFontBase* font );
112
113 private:
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
disti::GlsFontBase
Definition: gls_font_base.h:87
disti::GlsFontMan
Definition: gls_font_man.h:60
disti::GlsFontMan::Release
void Release(GlsFontBase *font)
disti::GlsFontMan::Register
void Register(GlsFontBase *font)
disti::GlsFontMan::~GlsFontMan
~GlsFontMan()
disti::GlsFontMan::Instance
static GlsFontMan & Instance()
disti::GlsFontMan::Font
GlsFontBase * Font(const std::string &name, const std::string &style, GLuint ptSize) const
disti::GlsFontMan::Use
void Use(GlsFontBase *font)
disti::GlsGlobals
Hold global objects so we can control order of destruction.
Definition: util.h:2071
gls_gl.h
The gls_gl.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti
Definition: bmpimage.h:47