KiCad PCB EDA Suite
|
FONT is an abstract base class for both outline and stroke fonts. More...
#include <font.h>
Public Member Functions | |
FONT () | |
virtual | ~FONT () |
virtual bool | IsStroke () const |
virtual bool | IsOutline () const |
virtual bool | IsBold () const |
virtual bool | IsItalic () const |
const wxString & | GetName () const |
const char * | NameAsToken () const |
void | Draw (KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const |
Draw a string. More... | |
void | Draw (KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const |
VECTOR2I | StringBoundaryLimits (const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const |
Compute the boundary limits of aText (the bounding box of all shapes). More... | |
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. More... | |
virtual double | GetInterline (double aGlyphHeight, const METRICS &aFontMetrics) const =0 |
Compute the distance (interline) between 2 lines of text (for multiline texts). More... | |
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. More... | |
Static Public Member Functions | |
static FONT * | GetFont (const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false) |
static bool | IsStroke (const wxString &aFontName) |
Protected Member Functions | |
unsigned | linesCount (const wxString &aText) const |
Returns number of lines for a given text. More... | |
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 METRICS &aFontMetrics) const |
Draws a single line of text. More... | |
VECTOR2I | boundingBoxSingleLine (BOX2I *aBBox, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aSize, bool aItalic, const METRICS &aFontMetrics) const |
Computes the bounding box for a single line of text. More... | |
void | getLinePositions (const wxString &aText, const VECTOR2I &aPosition, wxArrayString &aTextLines, std::vector< VECTOR2I > &aPositions, std::vector< VECTOR2I > &aExtents, const TEXT_ATTRIBUTES &aAttrs, const METRICS &aFontMetrics) 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 METRICS &aFontMetrics) const |
void | wordbreakMarkup (std::vector< std::pair< wxString, int > > *aWords, const wxString &aText, const VECTOR2I &aSize, TEXT_STYLE_FLAGS aTextStyle) const |
Protected Attributes | |
wxString | m_fontName |
Font name. More... | |
wxString | m_fontFileName |
Font file name. More... | |
Static Private Member Functions | |
static FONT * | getDefaultFont () |
Static Private Attributes | |
static FONT * | s_defaultFont = nullptr |
static std::map< std::tuple< wxString, bool, bool >, FONT * > | s_fontMap |
FONT is an abstract base class for both outline and stroke fonts.
|
protected |
Computes the bounding box for a single line of text.
Multiline texts should be split before using the function.
aBBox | is an optional pointer to be filled with the bounding box. |
aText | is the text to be drawn. |
aPosition | is text position. |
aSize | is the cap-height and em-width of the text. |
Definition at line 458 of file font.cpp.
References ANGLE_0, and drawMarkup().
Referenced by getLinePositions().
|
inline |
void FONT::Draw | ( | KIGFX::GAL * | aGal, |
const wxString & | aText, | ||
const VECTOR2I & | aPosition, | ||
const VECTOR2I & | aCursor, | ||
const TEXT_ATTRIBUTES & | aAttrs, | ||
const METRICS & | aFontMetrics | ||
) | const |
Draw a string.
aGal | is the graphics context. |
aText | is the text to be drawn. |
aPosition | is the text position in world coordinates. |
aCursor | is the current text position (for multiple text blocks within a single text object, such as a run of superscript characters) |
aAttrs | are the styling attributes of the text, including its rotation |
aGal | |
aText | is the text to be drawn. |
aPosition | is the text object position in world coordinates. |
aCursor | is the current text position (for multiple text blocks within a single text object, such as a run of superscript characters) |
aAttrs | are the styling attributes of the text, including its rotation |
Definition at line 251 of file font.cpp.
References drawSingleLineText(), getLinePositions(), TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Underlined, and KIGFX::GAL::SetLineWidth().
Referenced by BOARD_ADAPTER::addText(), KIGFX::GAL::BitmapText(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), EDA_TEXT::GetEffectiveTextShape(), GRPrintText(), KIGFX::SCH_PAINTER::knockoutText(), PLOTTER::PlotText(), KIGFX::SCH_PAINTER::strokeText(), KIGFX::PCB_PAINTER::strokeText(), PLOTTER::Text(), PCB_TEXT::TransformTextToPolySet(), and PCB_TEXTBOX::TransformTextToPolySet().
|
protected |
Definition at line 377 of file font.cpp.
References MARKUP_CACHE::Get(), MARKUP::MARKUP_PARSER::Parse(), MARKUP_CACHE::Put(), MARKUP_CACHE::ENTRY::root, s_markupCache, s_markupCacheMutex, MARKUP_CACHE::ENTRY::source, and TO_UTF8.
Referenced by boundingBoxSingleLine(), drawSingleLineText(), KIFONT::OUTLINE_FONT::GetLinesAsGlyphs(), and StringBoundaryLimits().
|
protected |
Draws a single line of text.
Multiline texts should be split before using the function.
aGal | is a pointer to the graphics abstraction layer, or nullptr (nothing is drawn) |
aBBox | is an optional pointer to be filled with the bounding box. |
aText | is the text to be drawn. |
aPosition | is text position. |
aSize | is the cap-height and em-width of the text |
aAngle | is text angle. |
aMirror | is true if text should be drawn mirrored, false otherwise. |
aOrigin | is the point around which the text should be rotated, mirrored, etc. |
Definition at line 403 of file font.cpp.
References KIGFX::GAL::DrawGlyphs(), and drawMarkup().
Referenced by Draw().
|
staticprivate |
Definition at line 137 of file font.cpp.
References KIFONT::STROKE_FONT::LoadFont(), and s_defaultFont.
Referenced by GetFont().
|
static |
Definition at line 146 of file font.cpp.
References getDefaultFont(), KICAD_FONT_NAME, KIFONT::OUTLINE_FONT::LoadFont(), and s_fontMap.
Referenced by LABEL_MANAGER::Add(), BOARD_ADAPTER::addText(), SCH_EASYEDAPRO_PARSER::ApplyFontStyle(), KIGFX::GAL::BitmapText(), BOOST_AUTO_TEST_CASE(), KIGFX::SCH_PAINTER::boxText(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), KIGFX::DS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), LIB_PIN::GetBoundingBox(), EDA_TEXT::getDrawFont(), LIB_FIELD::getDrawFont(), LIB_TEXT::getDrawFont(), LIB_TEXTBOX::getDrawFont(), SCH_FIELD::getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), KIGFX::SCH_PAINTER::getFont(), FONT_CHOICE::GetFontSelection(), SCH_FIELD::GetRenderCache(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), GRPrintText(), GRTextWidth(), KIGFX::SCH_PAINTER::knockoutText(), PCB_EASYEDAPRO_PARSER::ParseBoard(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDA_PARSER::ParseSymbolShapes(), DRAWING_SHEET_PARSER::parseText(), PCB_EASYEDA_PARSER::ParseToBoardItemContainer(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), PlotDrawingSheet(), LIB_PIN::PlotPinTexts(), BRDITEMS_PLOTTER::PlotText(), PLOTTER::PlotText(), SCH_FIELD::Print(), LIB_FIELD::print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), SCH_TEXT::Print(), EDA_TEXT::printOneLineOfText(), LIB_PIN::printPinElectricalTypeName(), LIB_PIN::printPinTexts(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), FIELDS_GRID_TABLE< T >::SetValue(), KIGFX::SCH_PAINTER::strokeText(), KIGFX::PCB_PAINTER::strokeText(), PLOTTER::Text(), and PDF_PLOTTER::Text().
|
pure virtual |
Compute the distance (interline) between 2 lines of text (for multiline texts).
This is the distance between baselines, not the space between line bounding boxes.
Implemented in KIFONT::OUTLINE_FONT, and KIFONT::STROKE_FONT.
Referenced by getLinePositions(), and EDA_TEXT::GetTextBox().
|
protected |
Definition at line 178 of file font.cpp.
References boundingBoxSingleLine(), GetInterline(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, IsStroke(), TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_LineSpacing, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, wxStringSplit(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Draw(), and KIFONT::OUTLINE_FONT::GetLinesAsGlyphs().
|
inline |
Definition at line 147 of file font.h.
Referenced by TEXT_ATTRIBUTES::Compare(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), DS_DATA_MODEL_IO::format(), EDA_TEXT::GetFontName(), operator<<(), and FONT_CHOICE::SetFontSelection().
|
pure virtual |
Convert text string to an array of GLYPHs.
aBBox | pointer to a BOX2I that will set to the bounding box, or nullptr |
aGlyphs | storage for the returned GLYPHs |
aText | text to convert to polygon/polyline |
aSize | is the cap-height and em-width of the text |
aPosition | position of text (cursor position before this text) |
aAngle | text angle |
aMirror | is true if text should be drawn mirrored, false otherwise. |
aOrigin | is the point around which the text should be rotated, mirrored, etc. |
aTextStyle | text style flags |
Implemented in KIFONT::OUTLINE_FONT, and KIFONT::STROKE_FONT.
Referenced by drawMarkup(), LinebreakText(), and wordbreakMarkup().
|
inlinevirtual |
Reimplemented in KIFONT::OUTLINE_FONT.
Definition at line 140 of file font.h.
Referenced by operator<<().
|
inlinevirtual |
Reimplemented in KIFONT::OUTLINE_FONT.
Definition at line 141 of file font.h.
Referenced by operator<<().
|
inlinevirtual |
Reimplemented in KIFONT::OUTLINE_FONT.
Definition at line 139 of file font.h.
Referenced by ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), PCB_PLUGIN::format(), EDA_TEXT::GetEffectiveTextShape(), EDA_TEXT::GetRenderCache(), SCH_FIELD::GetRenderCache(), operator<<(), SCH_TEXT::Plot(), SCH_TEXT::Print(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), StringBoundaryLimits(), KIGFX::SCH_PAINTER::strokeText(), and KIGFX::PCB_PAINTER::strokeText().
|
inlinevirtual |
Reimplemented in KIFONT::STROKE_FONT.
Definition at line 138 of file font.h.
Referenced by getLinePositions(), EDA_TEXT::GetTextBox(), DIALOG_DIMENSION_PROPERTIES::onFontSelected(), DIALOG_TEXT_PROPERTIES::onFontSelected(), DIALOG_TEXTBOX_PROPERTIES::onFontSelected(), operator<<(), StringBoundaryLimits(), KIGFX::SCH_PAINTER::strokeText(), and KIGFX::PCB_PAINTER::strokeText().
|
static |
Definition at line 170 of file font.cpp.
References _, and KICAD_FONT_NAME.
void FONT::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.
Definition at line 582 of file font.cpp.
References ANGLE_0, GetTextAsGlyphs(), wordbreakMarkup(), wxStringSplit(), and VECTOR2< T >::x.
Referenced by LIB_TEXTBOX::GetShownText(), PCB_TEXTBOX::GetShownText(), and SCH_TEXTBOX::GetShownText().
|
inlineprotected |
|
inline |
Definition at line 148 of file font.h.
Referenced by DS_DATA_MODEL_IO::format().
VECTOR2I FONT::StringBoundaryLimits | ( | const wxString & | aText, |
const VECTOR2I & | aSize, | ||
int | aThickness, | ||
bool | aBold, | ||
bool | aItalic, | ||
const METRICS & | aFontMetrics | ||
) | const |
Compute the boundary limits of aText (the bounding box of all shapes).
Definition at line 428 of file font.cpp.
References ANGLE_0, boundingBox(), drawMarkup(), BOX2< Vec >::GetSize(), BOX2< Vec >::Inflate(), IsOutline(), IsStroke(), and KiROUND().
Referenced by LABEL_MANAGER::Add(), KIGFX::SCH_PAINTER::boxText(), EDA_TEXT::GetTextBox(), GRTextWidth(), PDF_PLOTTER::Text(), and LIB_PIN::validateExtentsCache().
|
protected |
Definition at line 561 of file font.cpp.
References MARKUP::MARKUP_PARSER::Parse(), TO_UTF8, and wordbreakMarkup().
Referenced by LinebreakText(), and wordbreakMarkup().
|
protected |
Font file name.
Definition at line 277 of file font.h.
Referenced by KIFONT::STROKE_FONT::loadNewStrokeFont().
|
protected |
Font name.
Definition at line 276 of file font.h.
Referenced by KIFONT::STROKE_FONT::loadNewStrokeFont().
|
staticprivate |
Definition at line 280 of file font.h.
Referenced by getDefaultFont().
|
staticprivate |