CGM Objects Library
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Font.h
1 // Font.h: interface for the CLSTFont class.
2 //
5 
6 #if !defined(LST_FONT_H__INCLUDED_)
7 #define LST_FONT_H__INCLUDED_
8 
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 #include "FontProperties.h"
15 #include "Utility/Config.h"
16 #include "FontCacheEntry.h"
17 #include "Utility/wstring.h"
18 
19 
20 namespace Larson
21 {
22  class CFontCache;
23 
24  void trimFontName(std::wstring &name);
25  std::wstring normalizeFontName(std::wstring &name);
26 
28  class CLSTFont
29  {
30  public:
32  CLSTFont(std::wstring fontname, CFontProperties *props = NULL);
33  ~CLSTFont();
34 
35  const std::wstring& getName() { return m_name; };
36  std::wstring getNormalizedName();
37  void setName( const std::wstring& newName ) { m_name = newName; };
38  void setSubst(vector<std::wstring>* substitutes, bool forceSubst);
39  const vector<std::wstring>& getSub(bool *forceSubst);
40 
43  void generatePropertiesFromName(CFontProperties *props);
46 
48  void* getFace(Larson::CConfig* config);
49 
50  std::wstring getFaceFamily();
51  std::wstring getFaceStyle();
52  std::wstring getPathFromName(std::wstring &name);
53  std::wstring getGenericFamily();
54 
55  CFontProperties::Posture getPostureFromName(std::wstring &trimmedName);
56  CFontProperties::Weight getWeightFromName(std::wstring &trimmedName);
57  void resetFace();
58 
59  protected:
60  CFontProperties::ProportionateWidth getWidthFromName(std::wstring &trimmedName);
61 
64  std::wstring m_name;
66  vector<std::wstring> m_substitutes;
71  vector<std::wstring> m_aliases;
76 
77  private:
78  CFontCache *getCacheInstance();
79 
82  // typed as void* so that #include freetype.h not required
83  void* m_face;
84  };
85 }
86 
87 #endif // LST_FONT_H__INCLUDED_
88 
CFontCache – generates and maintains font cache.
Definition: FontCache.h:89
Larson::CFontProperties * getProperties()
get font properties (maybe be null if font properties for this font was not present in the CGM ...
Definition: Font.cpp:50
CFontCache * m_fontCache
pointer to font cache if loaded
Definition: Font.h:73
void * getFace(Larson::CConfig *config)
return pointer to Freetype Face object (FT_Face)
Definition: Font.cpp:393
CFontProperties * m_properties
pointer to font properties
Definition: Font.h:75
bool m_forceSubst
Definition: Font.h:69
CFontCacheEntry * m_fontCacheEntry
pointer to font cache entry for this font
Definition: Font.h:45
CLSTFont – Font object class, one per facename used in a CGM picture.
Definition: Font.h:28
CLSTFont(std::wstring fontname, CFontProperties *props=NULL)
Contructor from assigned font name.
Definition: Font.cpp:17
std::wstring m_name
Definition: Font.h:64
CFontCacheEntry – defines the data in a font cache entry.
Definition: FontCacheEntry.h:20
vector< std::wstring > m_substitutes
font name substitution priority-ordered list
Definition: Font.h:66
CFontProperties – FontProperties attributes.
Definition: FontProperties.h:19
vector< std::wstring > m_aliases
list of aliases for this font
Definition: Font.h:71