KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TARGET3001::FONTS Class Reference

Maps TARGET 3001! More...

#include <target3001_fonts.h>

Public Member Functions

void Apply (EDA_TEXT *aText, const ELEMENT &aElem, int aUnit)
 Give aText the font, style, size and stroke width of text aElem.
 

Static Public Member Functions

static VECTOR2I BaselineShift (const EDA_TEXT &aText)
 Offset in text units that moves aText so the baseline-left point of its first glyph lies on its position.
 

Private Member Functions

bool applyTrueType (EDA_TEXT *aText, const ELEMENT &aElem, int aUnit)
 

Private Attributes

std::map< std::tuple< wxString, bool, bool >, KIFONT::OUTLINE_FONT * > m_fonts
 
std::map< const KIFONT::OUTLINE_FONT *, double > m_averageWidth
 per unit of text size
 

Detailed Description

Maps TARGET 3001!

text onto KiCad fonts.

The built-in TARGET font is fixed pitch with a cap height equal to the text height, so its width is chosen to give KiCad's stroke font the same string length. DIN-ISO-ANSI scales its glyphs uniformly by the larger of height and width with a cap height of 0.9 of that size. Its glyphs are proportional with a fixed gap, so the width is the least squares fit of KiCad's glyph centres to the DIN-ISO-ANSI ones.

TrueType fonts scale a fixed master rendering linearly: the em square is 300/222 of the text height (300/241 for Calibri) and the width is the font's average character width. The average is the classic weighted lowercase average, so it is measured from glyph advances and stays correct when a metric-compatible substitute font is loaded.

Definition at line 54 of file target3001_fonts.h.

Member Function Documentation

◆ Apply()

void TARGET3001::FONTS::Apply ( EDA_TEXT * aText,
const ELEMENT & aElem,
int aUnit )

Give aText the font, style, size and stroke width of text aElem.

The text content must already be set, because fixed-pitch text is sized by its length.

Parameters
aUnitis the number of file nanometres per unit of aText.

Definition at line 160 of file target3001_fonts.cpp.

References ANGLE_0, applyTrueType(), end, TARGET3001::TEXT::font, KIFONT::FONT::GetFont(), EDA_TEXT::GetText(), KIFONT::FONT::GetTextAsGlyphs(), TARGET3001::TEXT::height, KiROUND(), scale, EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), text, TARGET3001::ELEMENT::text, TARGET3001::ToWx(), TARGET3001::TEXT::weight, TARGET3001::TEXT::width, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ applyTrueType()

◆ BaselineShift()

VECTOR2I TARGET3001::FONTS::BaselineShift ( const EDA_TEXT & aText)
static

Offset in text units that moves aText so the baseline-left point of its first glyph lies on its position.

KiCad offsets text from its position by amounts that depend on the font, while TARGET 3001! anchors the baseline at the pen. The built-in fonts draw the stem of H at the pen, so stroke text is also aligned horizontally by it. Only the baseline is aligned for right-justified text.

Definition at line 219 of file target3001_fonts.cpp.

References ANGLE_0, SHAPE_COMPOUND::BBox(), BOX2< Vec >::GetBottom(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetEffectiveTextShape(), EDA_TEXT::GetFont(), EDA_TEXT::GetHorizJustify(), BOX2< Vec >::GetLeft(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, EDA_TEXT::IsMirrored(), KIFONT::FONT::IsStroke(), RotatePoint(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetVertJustify(), and VECTOR2< T >::x.

Referenced by TARGET3001_SCH_BUILDER::addComponent(), TARGET3001_PCB_BUILDER::configureText(), and TARGET3001_SCH_BUILDER::makeGraphic().

Member Data Documentation

◆ m_averageWidth

std::map<const KIFONT::OUTLINE_FONT*, double> TARGET3001::FONTS::m_averageWidth
private

per unit of text size

Definition at line 80 of file target3001_fonts.h.

Referenced by applyTrueType().

◆ m_fonts

std::map<std::tuple<wxString, bool, bool>, KIFONT::OUTLINE_FONT*> TARGET3001::FONTS::m_fonts
private

Definition at line 79 of file target3001_fonts.h.

Referenced by applyTrueType().


The documentation for this class was generated from the following files: