Panda3D
Loading...
Searching...
No Matches
fontPool.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file fontPool.h
10 * @author drose
11 * @date 2003-01-31
12 */
13
14#ifndef FONTPOOL_H
15#define FONTPOOL_H
16
17#include "pandabase.h"
18
19#include "texture.h"
20#include "textFont.h"
21#include "filename.h"
22#include "lightMutex.h"
23#include "pmap.h"
24
25/**
26 * This is the preferred interface for loading fonts for the TextNode system.
27 * It is similar to ModelPool and TexturePool in that it unifies references to
28 * the same filename.
29 */
30class EXPCL_PANDA_TEXT FontPool {
31PUBLISHED:
32 // These functions take string parameters instead of Filenames because the
33 // parameters may not be entirely an actual filename: they may be a filename
34 // followed by a face index.
35
36 INLINE static bool has_font(const std::string &filename);
37 INLINE static bool verify_font(const std::string &filename);
38 BLOCKING INLINE static TextFont *load_font(const std::string &filename);
39 INLINE static void add_font(const std::string &filename, TextFont *font);
40 INLINE static void release_font(const std::string &filename);
41 INLINE static void release_all_fonts();
42
43 INLINE static int garbage_collect();
44
45 INLINE static void list_contents(std::ostream &out);
46 static void write(std::ostream &out);
47
48private:
49 INLINE FontPool();
50
51 bool ns_has_font(const std::string &str);
52 TextFont *ns_load_font(const std::string &str);
53 void ns_add_font(const std::string &str, TextFont *font);
54 void ns_release_font(const std::string &str);
55 void ns_release_all_fonts();
56 int ns_garbage_collect();
57 void ns_list_contents(std::ostream &out) const;
58
59 static void lookup_filename(const std::string &str, std::string &index_str,
60 Filename &filename, int &face_index);
61
62 static FontPool *get_ptr();
63 static FontPool *_global_ptr;
64
65 LightMutex _lock;
66 typedef pmap<std::string, PT(TextFont) > Fonts;
67 Fonts _fonts;
68};
69
70#include "fontPool.I"
71
72#endif
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This is the preferred interface for loading fonts for the TextNode system.
Definition fontPool.h:30
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition lightMutex.h:41
An encapsulation of a font; i.e.
Definition textFont.h:32
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.