27#ifndef OUTLINE_FONT_H_
28#define OUTLINE_FONT_H_
35#include <freetype2/ft2build.h>
71 return m_face && ( m_fakeBold || ( m_face->style_flags & FT_STYLE_FLAG_BOLD ) );
76 return m_face && ( m_fakeItal || ( m_face->style_flags & FT_STYLE_FLAG_ITALIC ) );
89 const wxString&
GetFileName()
const {
return m_fontFileName; }
91 EMBEDDING_PERMISSION GetEmbeddingPermission()
const;
97 static OUTLINE_FONT* LoadFont(
const wxString& aFontFileName,
bool aBold,
bool aItalic,
98 const std::vector<wxString>* aEmbeddedFiles,
99 bool aForDrawingSheet );
105 double GetInterline(
double aGlyphHeight,
const METRICS& aFontMetrics )
const override;
107 VECTOR2I GetTextAsGlyphs(
BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
108 const wxString& aText,
const VECTOR2I& aSize,
112 void GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const wxString& aText,
114 const METRICS& aFontMetrics )
const;
116 const FT_Face&
GetFace()
const {
return m_face; }
119 void RenderToOpenGLCanvas( KIGFX::OPENGL_FREETYPE& aTarget,
const wxString& aString,
120 const VECTOR2D& aSize,
const wxPoint& aPosition,
121 const EDA_ANGLE& aAngle,
bool aMirror )
const;
125 FT_Error loadFace(
const wxString& aFontFileName,
int aFaceIndex );
127 BOX2I getBoundingBox(
const std::vector<std::unique_ptr<GLYPH>>& aGlyphs )
const;
129 VECTOR2I getTextAsGlyphs(
BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
130 const wxString& aText,
const VECTOR2I& aSize,
136 std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
137 const wxString& aText,
const VECTOR2I& aSize,
139 bool aMirror,
const VECTOR2I& aOrigin,
167 static constexpr double m_outlineFontSizeCompensation = 1.4;
170 static constexpr int m_charSizeScaler = 64;
177 static constexpr double m_subscriptSuperscriptSize = 0.64;
179 static constexpr double m_underlineOffsetScaler = -0.16;
183 return aSize * m_charSizeScaler * m_outlineFontSizeCompensation;
190 return KiROUND( faceSize( aSize ) * m_subscriptSuperscriptSize );
194 static constexpr double m_subscriptVerticalOffset = -0.25;
195 static constexpr double m_superscriptVerticalOffset = 0.45;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
FONT is an abstract base class for both outline and stroke fonts.
Class OUTLINE_FONT implements outline font drawing.
static std::mutex m_freeTypeMutex
Mutex for freetype access, FT_Library and FT_Face are not thread safe.
static FT_Library m_freeType
const FT_Face & GetFace() const
int subscriptSize(int aSize) const
bool IsItalic() const override
int faceSize(int aSize) const
bool IsOutline() const override
std::map< unsigned int, std::vector< std::vector< VECTOR2D > > > m_contourCache
const wxString & GetFileName() const
int subscriptSize() const
bool IsBold() const override
unsigned int TEXT_STYLE_FLAGS