blip  0.1
FontManager.hpp
Go to the documentation of this file.
1 #ifndef __blip_FontManager_hpp
2 #define __blip_FontManager_hpp
3 
4 #include <commonc++/DynamicCache.h++>
5 #include <commonc++/String.h++>
6 
7 #include <blip/Blip.hpp>
8 #include <blip/Pixmap.hpp>
9 
10 struct FT_LibraryRec_;
11 
12 CCXX_FWD_DECL(DataReader);
13 
14 namespace blip {
15 
16 class Font;
17 class NativeActivity;
18 
26 {
27  friend class NativeActivity;
28 
29  public:
30 
39  FontManager(uint_t fontCacheSize = 4, uint_t glyphCacheSize = 96);
40 
42  ~FontManager();
43 
56  void loadFont(ccxx::DataReader* reader, int size, int index = 0);
57 
66  const Font* lookupFont(const ccxx::String& name, int size, int style = 0)
67  const;
68 
69  private:
70 
71  FT_LibraryRec_* _freetype;
72 
73  struct FontKey
74  {
75  FontKey(const ccxx::String& name, int style, int size)
76  : name(name), style(style), size(size)
77  { }
78 
79  ccxx::String name;
80  int style;
81  int size;
82 
83  bool operator<(const FontKey& other) const;
84  };
85 
86  mutable ccxx::DynamicCache<FontKey, Font> _cache;
87  uint_t _glyphCacheSize;
88 
89  CCXX_COPY_DECLS(FontManager);
90 };
91 
92 } // namespace blip
93 
94 #endif // __blip_FontManager_hpp
void loadFont(ccxx::DataReader *reader, int size, int index=0)
Load a font from a DataReader.
Definition: FontManager.cpp:105
FontManager(uint_t fontCacheSize=4, uint_t glyphCacheSize=96)
Construct a new FontManager with the given cache sizes.
Definition: FontManager.cpp:82
A class for loading and caching TrueType fonts.
Definition: FontManager.hpp:25
A TrueType font.
Definition: Font.hpp:74
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
An abstract base class for all "native" (C++) Android activities.
Definition: NativeActivity.hpp:71
~FontManager()
Destructor.
Definition: FontManager.cpp:97
CCXX_FWD_DECL(DataReader)
const Font * lookupFont(const ccxx::String &name, int size, int style=0) const
Look up a font previously loaded with loadFont().
Definition: FontManager.cpp:147