DistanceFieldFont.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
11 
12 namespace ewol {
13  namespace resource {
15  private:
16  std::string m_fileName;
17  float m_sizeRatio;
18  // specific element to have the the know if the specify element is known...
19  // == > otherwise I can just generate italic ...
20  // == > Bold is a little more complicated (maybe with the bordersize)
22  public:
23  std::vector<GlyphProperty> m_listElement;
24  private:
25  // for the texture generation :
26  ivec2 m_lastGlyphPos;
27  int32_t m_lastRawHeigh;
28  protected:
30  void init(const std::string& _fontName);
31  public:
32  DECLARE_RESOURCE_NAMED_FACTORY(DistanceFieldFont);
33  virtual ~DistanceFieldFont();
34  public:
35  float getDisplayRatio(float _size);
41  float getHeight(float _size) {
42  return ((float)m_font->getHeight(_size));
43  };
49  float getSize(float _fontHeight) {
50  return m_font->getSizeWithHeight(_fontHeight);
51  }
57  int32_t getIndex(char32_t _charcode);
63  ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode);
64  public:
71  static ememory::SharedPtr<ewol::resource::DistanceFieldFont> keep(const std::string& _filename);
72  private:
78  bool addGlyph(const char32_t& _val);
79 
80  void generateDistanceField(const egami::ImageMono& _input, egami::Image& _output);
81  private:
82  float m_borderSize;
83  vec2 m_textureBorderSize;
84  public:
85  float getPixelBorderSize() {
86  return m_borderSize;
87  }
88  const vec2& getTextureBorderSize() {
89  return m_textureBorderSize;
90  }
91  public:
92  void exportOnFile();
93  bool importFromFile();
94  };
95  };
96 };
static ememory::SharedPtr< ewol::resource::DistanceFieldFont > keep(const std::string &_filename)
keep the resource pointer.
int32_t getIndex(char32_t _charcode)
get the ID of a unicode charcode
ewol::GlyphProperty * getGlyphPointer(const char32_t &_charcode)
get the pointer on the coresponding glyph
Definition: Area.hpp:16
Definition: GlyphProperty.hpp:48
float getHeight(float _size)
get the display height of this font
Definition: DistanceFieldFont.hpp:41
Definition: DistanceFieldFont.hpp:14
float getSize(float _fontHeight)
get the font size with a specific display size
Definition: DistanceFieldFont.hpp:49
Definition: Texture.hpp:15