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;
98 static OUTLINE_FONT* LoadFont(
const wxString& aFontFileName,
bool aBold,
bool aItalic,
99 const std::vector<wxString>* aEmbeddedFiles,
100 bool aForDrawingSheet );
107 double GetInterline(
double aGlyphHeight,
const METRICS& aFontMetrics )
const override;
109 VECTOR2I GetTextAsGlyphs(
BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
110 const wxString& aText,
const VECTOR2I& aSize,
114 void GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const wxString& aText,
116 const METRICS& aFontMetrics )
const;
118 const FT_Face&
GetFace()
const {
return m_face; }
121 void RenderToOpenGLCanvas( KIGFX::OPENGL_FREETYPE& aTarget,
const wxString& aString,
122 const VECTOR2D& aSize,
const wxPoint& aPosition,
123 const EDA_ANGLE& aAngle,
bool aMirror )
const;
127 FT_Error loadFace(
const wxString& aFontFileName,
int aFaceIndex );
129 BOX2I getBoundingBox(
const std::vector<std::unique_ptr<GLYPH>>& aGlyphs )
const;
131 VECTOR2I getTextAsGlyphs(
BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
132 const wxString& aText,
const VECTOR2I& aSize,
138 std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
139 const wxString& aText,
const VECTOR2I& aSize,
141 bool aMirror,
const VECTOR2I& aOrigin,
169 static constexpr double m_outlineFontSizeCompensation = 1.4;
172 static constexpr int m_charSizeScaler = 64;
179 static constexpr double m_subscriptSuperscriptSize = 0.64;
181 static constexpr double m_underlineOffsetScaler = -0.16;
185 return aSize * m_charSizeScaler * m_outlineFontSizeCompensation;
193 return KiROUND( faceSize( aSize ) * m_subscriptSuperscriptSize );
197 static constexpr double m_subscriptVerticalOffset = -0.25;
198 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