forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfontPool.I
More file actions
127 lines (117 loc) · 5.09 KB
/
fontPool.I
File metadata and controls
127 lines (117 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Filename: fontPool.I
// Created by: drose (31Jan03)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: FontPool::has_font
// Access: Public, Static
// Description: Returns true if the font has ever been loaded,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool FontPool::
has_font(const string &filename) {
return get_ptr()->ns_has_font(filename);
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::verify_font
// Access: Public, Static
// Description: Loads the given filename up into a font, if it has
// not already been loaded, and returns true to indicate
// success, or false to indicate failure. If this
// returns true, it is guaranteed that a subsequent call
// to load_font() with the same font name will
// return a valid Font pointer.
////////////////////////////////////////////////////////////////////
INLINE bool FontPool::
verify_font(const string &filename) {
return load_font(filename) != (TextFont *)NULL;
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::load_font
// Access: Public, Static
// Description: Loads the given filename up into a font, if it has
// not already been loaded, and returns the new font.
// If a font with the same filename was previously
// loaded, returns that one instead. If the font
// file cannot be found, returns NULL.
////////////////////////////////////////////////////////////////////
INLINE TextFont *FontPool::
load_font(const string &filename) {
return get_ptr()->ns_load_font(filename);
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::add_font
// Access: Public, Static
// Description: Adds the indicated already-loaded font to the
// pool. The font will always replace any
// previously-loaded font in the pool that had the
// same filename.
////////////////////////////////////////////////////////////////////
INLINE void FontPool::
add_font(const string &filename, TextFont *font) {
get_ptr()->ns_add_font(filename, font);
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::release_font
// Access: Public, Static
// Description: Removes the indicated font from the pool,
// indicating it will never be loaded again; the font
// may then be freed. If this function is never called,
// a reference count will be maintained on every font
// every loaded, and fonts will never be freed.
////////////////////////////////////////////////////////////////////
INLINE void FontPool::
release_font(const string &filename) {
get_ptr()->ns_release_font(filename);
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::release_all_fonts
// Access: Public, Static
// Description: Releases all fonts in the pool and restores the
// pool to the empty state.
////////////////////////////////////////////////////////////////////
INLINE void FontPool::
release_all_fonts() {
get_ptr()->ns_release_all_fonts();
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::garbage_collect
// Access: Public, Static
// Description: Releases only those fonts in the pool that have a
// reference count of exactly 1; i.e. only those
// fonts that are not being used outside of the pool.
// Returns the number of fonts released.
////////////////////////////////////////////////////////////////////
INLINE int FontPool::
garbage_collect() {
return get_ptr()->ns_garbage_collect();
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::list_contents
// Access: Public, Static
// Description: Lists the contents of the font pool to the
// indicated output stream.
////////////////////////////////////////////////////////////////////
INLINE void FontPool::
list_contents(ostream &out) {
get_ptr()->ns_list_contents(out);
}
////////////////////////////////////////////////////////////////////
// Function: FontPool::Constructor
// Access: Private
// Description: The constructor is not intended to be called
// directly; there's only supposed to be one FontPool
// in the universe and it constructs itself.
////////////////////////////////////////////////////////////////////
INLINE FontPool::
FontPool() {
}