3 // This source code has been donated to the Public Domain. Do
4 // whatever you want with it.
6 // A module to take care of all of gnash's loaded fonts.
9 #include "gnashconfig.h" // HAVE_ZLIB_H, USE_SWFTREE
12 #include "smart_ptr.h"
15 #include "DefineShapeTag.h"
16 #include "LineStyle.h"
17 #include "movie_definition.h"
19 // Define to the name of a default font.
20 #define DEFAULT_FONT_NAME "_sans"
26 std::vector
< boost::intrusive_ptr
<Font
> > s_fonts
;
27 boost::intrusive_ptr
<Font
> _defaultFont
;
37 // Release all the fonts we know about.
42 boost::intrusive_ptr
<Font
>
45 if ( _defaultFont
) return _defaultFont
;
46 _defaultFont
= new Font(DEFAULT_FONT_NAME
);
51 // Return the number of fonts in our library.
53 return s_fonts
.size();
57 Font
* get_font(int index
)
58 // Retrieve one of our fonts, by index.
60 if (index
< 0 || index
>= (int) s_fonts
.size())
65 return s_fonts
[index
].get();
69 Font
* get_font(const std::string
& name
, bool bold
, bool italic
)
71 // Dumb linear search.
72 for (unsigned int i
= 0; i
< s_fonts
.size(); i
++)
74 Font
* f
= s_fonts
[i
].get();
76 if ( f
->matches(name
, bold
, italic
) )
81 Font
* f
= new Font(name
, bold
, italic
);
86 void add_font(Font
* f
)
87 // Add the given font to our library.
92 // Make sure font isn't already in the list.
93 for (unsigned int i
= 0; i
< s_fonts
.size(); i
++)
95 assert(s_fonts
[i
] != f
);
104 } // end namespace fontlib
105 } // end namespace gnash
112 // indent-tabs-mode: t