My Project
GLFontFreeType.h
1 #pragma once
2 
3 #include "GLType.h"
4 #include "GLFont.h"
5 
6 #include <string>
7 
8 #include "ft2build.h"
9 #include FT_FREETYPE_H
10 #include FT_STROKER_H
11 #include FT_IMAGE_H
12 
13 
14 namespace ParaEngine
15 {
16 
17  class FontFreeType : public Font
18  {
19  public:
20  static const int DistanceMapSpread;
21 
22  static FontFreeType* create(const std::string &fontName, float fontSize, GlyphCollection glyphs,
23  const char *customGlyphs, bool distanceFieldEnabled = false, int outline = 0);
24 
25  static void shutdownFreeType();
26  static void shutdownFreeType_exit();
27 
28  bool isDistanceFieldEnabled() const { return _distanceFieldEnabled; }
29 
30  float getOutlineSize() const { return _outlineSize; }
31 
32  void renderCharAt(unsigned char *dest, int posX, int posY, unsigned char* bitmap, long bitmapWidth, long bitmapHeight);
33 
34  FT_Encoding getEncoding() const { return _encoding; }
35 
36  int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override;
37 
38  unsigned char* getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, CCRect &outRect, int &xAdvance);
39 
40  int getFontAscender() const;
41  const char* getFontFamily() const;
42 
43  virtual FontAtlas* createFontAtlas() override;
44  virtual int getFontMaxHeight() const override { return _lineHeight; }
45 
46  static void releaseFont(const std::string &fontName);
47 
48  private:
49  static const char* _glyphASCII;
50  static const char* _glyphNEHE;
51  static FT_Library _FTlibrary;
52  static bool _FTInitialized;
53 
54  FontFreeType(bool distanceFieldEnabled = false, int outline = 0);
55  virtual ~FontFreeType();
56 
57  bool createFontObject(const std::string &fontName, float fontSize);
58 
59  bool initFreeType();
60  FT_Library getFTLibrary();
61 
62  int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
63  unsigned char* getGlyphBitmapWithOutline(unsigned short code, FT_BBox &bbox);
64 
65  void setGlyphCollection(GlyphCollection glyphs, const char* customGlyphs = nullptr);
66  const char* getGlyphCollection() const;
67 
68  FT_Face _fontRef;
69  FT_Stroker _stroker;
70  FT_Encoding _encoding;
71 
72  std::string _fontName;
73  bool _distanceFieldEnabled;
74  float _outlineSize;
75  int _lineHeight;
76  FontAtlas* _fontAtlas;
77 
78  GlyphCollection _usedGlyphs;
79  std::string _customGlyphs;
80  };
81 }
Definition: GLFontAtlas.h:14
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: GLFont.h:10
Definition: inftrees.h:24
Definition: GLFontFreeType.h:17
Definition: GLType.h:237