KiCad PCB EDA Suite
No Matches
gr_text.cpp File Reference
#include <gr_basic.h>
#include <plotters/plotter.h>
#include <trigo.h>
#include <math/util.h>
#include <font/font.h>
#include <callback_gal.h>

Go to the source code of this file.


int GetPenSizeForBold (int aTextSize)
int GetPenSizeForDemiBold (int aTextSize)
int GetPenSizeForBold (const wxSize &aTextSize)
int GetPenSizeForDemiBold (const wxSize &aTextSize)
int GetPenSizeForNormal (int aTextSize)
int GetPenSizeForNormal (const wxSize &aTextSize)
int Clamp_Text_PenSize (int aPenSize, int aSize, bool aStrict)
 Pen width should not allow characters to become cluttered up in their own fatness. More...
float Clamp_Text_PenSize (float aPenSize, int aSize, bool aStrict)
int Clamp_Text_PenSize (int aPenSize, const VECTOR2I &aSize, bool aStrict)
int GRTextWidth (const wxString &aText, KIFONT::FONT *aFont, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS &aFontMetrics)
void GRPrintText (wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
 Print a graphic text through wxDC. More...

Function Documentation

◆ Clamp_Text_PenSize() [1/3]

float Clamp_Text_PenSize ( float  aPenSize,
int  aSize,
bool  aStrict 

Definition at line 96 of file gr_text.cpp.

References scale.

◆ Clamp_Text_PenSize() [2/3]

int Clamp_Text_PenSize ( int  aPenSize,
const VECTOR2I aSize,
bool  aStrict 

Definition at line 105 of file gr_text.cpp.

References std::abs(), Clamp_Text_PenSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Clamp_Text_PenSize() [3/3]

int Clamp_Text_PenSize ( int  aPenSize,
int  aSize,
bool  aStrict 

Pen width should not allow characters to become cluttered up in their own fatness.

Normal text is normally around 15% the fontsize, and bold text around 20%. So we set a hard limit at 25%, and a secondary limit for non-decorative text that must be readable at small sizes at 18%.

aPenSizeis the pen size to clamp.
aSizeis the character size (height or width).
aBolduse true if text accept bold pen size.
the max pen size allowed.

Definition at line 87 of file gr_text.cpp.

References KiROUND(), and scale.

Referenced by Clamp_Text_PenSize(), KIGFX::SCH_PAINTER::draw(), EDA_TEXT::GetEffectiveTextPenWidth(), LIB_PIN::PlotPinTexts(), LIB_PIN::printPinTexts(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::Validate(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

◆ GetPenSizeForBold() [1/2]

int GetPenSizeForBold ( const wxSize &  aTextSize)

Definition at line 52 of file gr_text.cpp.

References GetPenSizeForBold().

◆ GetPenSizeForBold() [2/2]

◆ GetPenSizeForDemiBold() [1/2]

int GetPenSizeForDemiBold ( const wxSize &  aTextSize)

Definition at line 58 of file gr_text.cpp.

References GetPenSizeForDemiBold().

◆ GetPenSizeForDemiBold() [2/2]

int GetPenSizeForDemiBold ( int  aTextSize)
aTextSizethe char size (height or width).
the "best" value for a pen size to draw/plot a demibold text.

Definition at line 46 of file gr_text.cpp.

References KiROUND().

Referenced by KIGFX::SCH_PAINTER::draw(), and GetPenSizeForDemiBold().

◆ GetPenSizeForNormal() [1/2]

int GetPenSizeForNormal ( const wxSize &  aTextSize)

Definition at line 70 of file gr_text.cpp.

References GetPenSizeForNormal().

◆ GetPenSizeForNormal() [2/2]

◆ GRPrintText()

void GRPrintText ( wxDC *  aDC,
const VECTOR2I aPos,
const COLOR4D aColor,
const wxString &  aText,
const EDA_ANGLE aOrient,
const VECTOR2I aSize,
enum GR_TEXT_H_ALIGN_T  aH_justify,
enum GR_TEXT_V_ALIGN_T  aV_justify,
int  aWidth,
bool  aItalic,
bool  aBold,
const KIFONT::METRICS aFontMetrics 

Print a graphic text through wxDC.

aDCis the current Device Context.
aPosis the text position (according to h_justify, v_justify).
aColoris the text color.
aTextis the text to draw.
aOrientis the angle.
aSizeis the text size (size.x or size.y can be < 0 for mirrored texts).
aH_justifyis the horizontal justification (Left, center, right).
aV_justifyis the vertical justification (bottom, center, top).
aWidthis the line width (pen width) (use default width if aWidth = 0). if width < 0 : draw segments in sketch mode, width = abs(width) Use a value min(aSize.x, aSize.y) / 5 for a bold text.
aItalicis the true to simulate an italic font.
aBolduse true to use a bold font. Useful only with default width value (aWidth = 0).
aFontis the font to use, or nullptr for the KiCad stroke font

Definition at line 142 of file gr_text.cpp.

References KIFONT::FONT::Draw(), KIFONT::FONT::GetFont(), GetPenSizeForBold(), GRClosedPoly(), GRCSegm(), GRLine(), TEXT_ATTRIBUTES::m_Angle, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_FIELD::Print(), LIB_FIELD::print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), EDA_TEXT::printOneLineOfText(), LIB_PIN::printPinElectricalTypeName(), and LIB_PIN::printPinTexts().

◆ GRTextWidth()

int GRTextWidth ( const wxString &  aText,
const VECTOR2I aSize,
int  aThickness,
bool  aBold,
bool  aItalic,
const KIFONT::METRICS aFontMetrics 
the X size of the graphic text.

Definition at line 113 of file gr_text.cpp.

References KIFONT::FONT::GetFont(), KiROUND(), KIFONT::FONT::StringBoundaryLimits(), and VECTOR2< T >::x.

Referenced by SVG_PLOTTER::Text().