20 FT_Library FreetypeFace::_ft_library;
21 bool FreetypeFace::_ft_initialized =
false;
22 bool FreetypeFace::_ft_ok =
false;
30 FreetypeFace() : _lock(
"FreetypeFace::_lock") {
37 if (!_ft_initialized) {
38 initialize_ft_library();
47 if (_face !=
nullptr){
60 FT_Face FreetypeFace::
61 acquire_face(
int char_size,
int dpi,
int pixel_width,
int pixel_height) {
64 if (pixel_height != 0) {
65 if (pixel_height != _pixel_height || pixel_width != _pixel_width) {
68 _pixel_height = pixel_height;
69 _pixel_width = pixel_width;
70 FT_Set_Pixel_Sizes(_face, _pixel_width, _pixel_height);
73 if (char_size != _char_size || dpi != _dpi) {
74 _char_size = char_size;
78 if (_char_size != 0) {
79 FT_Set_Char_Size(_face, _char_size, _char_size, _dpi, _dpi);
92 release_face(FT_Face face) {
93 nassertv(_face == face);
101 set_face(FT_Face face) {
104 if (_face !=
nullptr){
113 _name = _face->family_name;
114 if (_face->style_name !=
nullptr) {
116 _name += _face->style_name;
120 <<
"Loaded font " << _name <<
"\n";
122 if (pnmtext_cat.is_debug()) {
124 << _name <<
" has " << _face->num_charmaps <<
" charmaps:\n";
125 for (
int i = 0; i < _face->num_charmaps; i++) {
126 pnmtext_cat.debug(
false) <<
" " << (
void *)_face->charmaps[i];
128 pnmtext_cat.debug(
false) <<
"\n";
130 <<
"default charmap is " << (
void *)_face->charmap <<
"\n";
132 if (_face->charmap ==
nullptr) {
135 if (_face->num_charmaps == 0) {
136 pnmtext_cat.warning()
137 << _name <<
" has no charmaps available.\n";
139 pnmtext_cat.warning()
140 << _name <<
" has no default Unicode charmap.\n";
141 if (_face->num_charmaps > 1) {
142 pnmtext_cat.warning()
143 <<
"Arbitrarily choosing first of " 144 << _face->num_charmaps <<
" charmaps.\n";
146 FT_Set_Charmap(_face, _face->charmaps[0]);
155 initialize_ft_library() {
156 if (!_ft_initialized) {
157 int error = FT_Init_FreeType(&_ft_library);
158 _ft_initialized =
true;
161 <<
"Unable to initialize FreeType; dynamic fonts will not load.\n";
168 #endif // HAVE_FREETYPE PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.