114 virtual bool IsBold()
const {
return false; }
117 static FONT*
GetFont(
const wxString& aFontName = wxEmptyString,
bool aBold =
false,
118 bool aItalic =
false );
119 static bool IsStroke(
const wxString& aFontName );
140 Draw( aGal, aText, aPosition,
VECTOR2I( 0, 0 ), aAttributes );
149 bool aBold,
bool aItalic )
const;
155 int aThickness,
bool aBold,
bool aItalic )
const;
173 virtual double GetInterline(
double aGlyphHeight,
double aLineSpacing = 1.0 )
const = 0;
190 const wxString& aText,
const VECTOR2I& aSize,
192 bool aMirror,
const VECTOR2I& aOrigin,
208 return std::count( aText.begin(), aText.end() - 1,
'\n' ) + 1;
228 bool aItalic,
bool aUnderline )
const;
241 const VECTOR2I& aSize,
bool aItalic )
const;
244 wxArrayString& aTextLines, std::vector<VECTOR2I>& aPositions,
245 std::vector<VECTOR2I>& aExtents,
const TEXT_ATTRIBUTES& aAttrs )
const;
252 void wordbreakMarkup( std::vector<std::pair<wxString, int>>* aWords,
const wxString& aText,
276 os <<
"[Font \"" << aFont.
GetName() <<
"\"" << ( aFont.
IsStroke() ?
" stroke" :
"" )
277 << ( aFont.
IsOutline() ?
" outline" :
"" ) << ( aFont.
IsBold() ?
" bold" :
"" )
278 << ( aFont.
IsItalic() ?
" italic" :
"" ) <<
"]";
FONT is an abstract base class for both outline and stroke fonts.
virtual double ComputeUnderlineVerticalPosition(double aGlyphHeight) const =0
Compute the vertical position of an underline.
wxString m_fontName
Font name.
virtual double GetInterline(double aGlyphHeight, double aLineSpacing=1.0) const =0
Compute the distance (interline) between 2 lines of text (for multiline texts).
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
virtual double ComputeOverbarVerticalPosition(double aGlyphHeight) const =0
Compute the vertical position of an overbar.
wxString m_fontFileName
Font file name.
void drawSingleLineText(KIGFX::GAL *aGal, BOX2I *aBoundingBox, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, bool aItalic, bool aUnderline) const
Draws a single line of text.
virtual bool IsStroke() const
static FONT * s_defaultFont
void getLinePositions(const wxString &aText, const VECTOR2I &aPosition, wxArrayString &aTextLines, std::vector< VECTOR2I > &aPositions, std::vector< VECTOR2I > &aExtents, const TEXT_ATTRIBUTES &aAttrs) const
VECTOR2I boundingBoxSingleLine(BOX2I *aBBox, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aSize, bool aItalic) const
Computes the bounding box for a single line of text.
const char * NameAsToken() const
void wordbreakMarkup(std::vector< std::pair< wxString, int > > *aWords, const wxString &aText, const VECTOR2I &aSize, TEXT_STYLE_FLAGS aTextStyle) const
Factor that determines the pitch between 2 lines.
virtual bool IsItalic() const
virtual bool IsBold() const
const wxString & GetName() const
virtual bool IsOutline() const
VECTOR2I drawMarkup(BOX2I *aBoundingBox, std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, TEXT_STYLE_FLAGS aTextStyle) const
static std::map< std::tuple< wxString, bool, bool >, FONT * > s_fontMap
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
unsigned linesCount(const wxString &aText) const
Returns number of lines for a given text.
virtual VECTOR2I GetTextAsGlyphs(BOX2I *aBBox, std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aSize, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, TEXT_STYLE_FLAGS aTextStyle) const =0
Convert text string to an array of GLYPHs.
static constexpr double INTERLINE_PITCH_RATIO
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttributes) const
static FONT * getDefaultFont()
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
Abstract interface for drawing on a 2D-surface.
unsigned int TEXT_STYLE_FLAGS
bool IsOverbar(TEXT_STYLE_FLAGS aFlags)
bool IsBold(TEXT_STYLE_FLAGS aFlags)
bool IsSuperscript(TEXT_STYLE_FLAGS aFlags)
std::string TextStyleAsString(TEXT_STYLE_FLAGS aFlags)
bool IsItalic(TEXT_STYLE_FLAGS aFlags)
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
bool IsSubscript(TEXT_STYLE_FLAGS aFlags)
std::ostream & operator<<(std::ostream &os, const KIFONT::FONT &aFont)
The Cairo implementation of the graphics abstraction layer.