KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EASYPC::TEXT_METRICS Class Reference

#include <easypc_text_metrics.h>

Public Member Functions

 TEXT_METRICS (const SOURCE_TEXT_STYLE &aStyle)
 
bool CanMeasure () const
 False for a TrueType style; the measuring calls throw IO_ERROR for one.
 
int32_t Height () const
 
int32_t RunWidth (const std::string &aText, size_t aBegin, size_t aEnd) const
 Width of bytes [aBegin, aEnd); a run that measures 0 is one height wide.
 
BOX2I TextBox (const wxString &aText, const VECTOR2I &aAnchor, int32_t aAngle, bool aMirrored, int aHAlign, int aVAlign=TEXT_V_BASELINE) const
 Every line's cell, inflated by half the pen width, mirrored about the anchor and bounded after rotation.
 
VECTOR2I UprightAnchor (const wxString &aText, const VECTOR2I &aAnchor, int32_t aAngle, bool aMirrored, int aHAlign, bool aKeepUpright) const
 When aKeepUpright and UprightRotation turns the text, the anchor moves to the far end of the first line one height up, then is mirrored and rotated with it; otherwise it is unchanged.
 

Static Public Member Functions

static std::string Encode (const wxString &aText)
 The CP1252 bytes of aText; characters CP1252 lacks become 0.
 

Private Member Functions

void checkMeasurable () const
 
int32_t linePitch () const
 
int32_t charWidth (char aChar) const
 

Private Attributes

int32_t m_height = 0
 
int32_t m_penWidth = 0
 
int32_t m_interlinePercent = 120
 
int32_t m_charWidthPercent = 100
 
bool m_proportional = false
 
bool m_typeFont = false
 

Detailed Description

Definition at line 67 of file easypc_text_metrics.h.

Constructor & Destructor Documentation

◆ TEXT_METRICS()

EASYPC::TEXT_METRICS::TEXT_METRICS ( const SOURCE_TEXT_STYLE & aStyle)
explicit

Member Function Documentation

◆ CanMeasure()

bool EASYPC::TEXT_METRICS::CanMeasure ( ) const
inline

False for a TrueType style; the measuring calls throw IO_ERROR for one.

Definition at line 73 of file easypc_text_metrics.h.

References m_typeFont.

Referenced by EASYPC::SCH_BUILDER::computeOffset(), and EASYPC::DrawsUpright().

◆ charWidth()

int32_t EASYPC::TEXT_METRICS::charWidth ( char aChar) const
private

Definition at line 141 of file easypc_text_metrics.cpp.

References m_charWidthPercent, m_height, and m_proportional.

Referenced by RunWidth().

◆ checkMeasurable()

void EASYPC::TEXT_METRICS::checkMeasurable ( ) const
private

Definition at line 128 of file easypc_text_metrics.cpp.

References _, m_typeFont, and THROW_IO_ERROR.

Referenced by RunWidth().

◆ Encode()

std::string EASYPC::TEXT_METRICS::Encode ( const wxString & aText)
static

The CP1252 bytes of aText; characters CP1252 lacks become 0.

Definition at line 300 of file easypc_text_metrics.cpp.

Referenced by EASYPC_PCB::ApplyTextPosition(), and TextBox().

◆ Height()

int32_t EASYPC::TEXT_METRICS::Height ( ) const
inline

Definition at line 75 of file easypc_text_metrics.h.

References m_height.

Referenced by TEXT_METRICS().

◆ linePitch()

int32_t EASYPC::TEXT_METRICS::linePitch ( ) const
private

Definition at line 135 of file easypc_text_metrics.cpp.

References m_height, and m_interlinePercent.

Referenced by TextBox().

◆ RunWidth()

int32_t EASYPC::TEXT_METRICS::RunWidth ( const std::string & aText,
size_t aBegin,
size_t aEnd ) const

Width of bytes [aBegin, aEnd); a run that measures 0 is one height wide.

Definition at line 152 of file easypc_text_metrics.cpp.

References charWidth(), checkMeasurable(), and m_height.

Referenced by TextBox().

◆ TextBox()

BOX2I EASYPC::TEXT_METRICS::TextBox ( const wxString & aText,
const VECTOR2I & aAnchor,
int32_t aAngle,
bool aMirrored,
int aHAlign,
int aVAlign = TEXT_V_BASELINE ) const

Every line's cell, inflated by half the pen width, mirrored about the anchor and bounded after rotation.

An empty string gives an empty box.

Definition at line 165 of file easypc_text_metrics.cpp.

References Encode(), end, left, linePitch(), m_height, m_penWidth, RunWidth(), BOX2< Vec >::SetEnd(), text, EASYPC::TEXT_H_CENTRE, EASYPC::TEXT_H_RIGHT, EASYPC::TEXT_V_MIDDLE, EASYPC::TEXT_V_TOP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EASYPC::SCH_BUILDER::computeOffset(), and UprightAnchor().

◆ UprightAnchor()

VECTOR2I EASYPC::TEXT_METRICS::UprightAnchor ( const wxString & aText,
const VECTOR2I & aAnchor,
int32_t aAngle,
bool aMirrored,
int aHAlign,
bool aKeepUpright ) const

When aKeepUpright and UprightRotation turns the text, the anchor moves to the far end of the first line one height up, then is mirrored and rotated with it; otherwise it is unchanged.

Definition at line 278 of file easypc_text_metrics.cpp.

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), m_height, m_penWidth, EASYPC::TEXT_H_LEFT, TextBox(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EASYPC::ApplyTextPosition().

Member Data Documentation

◆ m_charWidthPercent

int32_t EASYPC::TEXT_METRICS::m_charWidthPercent = 100
private

Definition at line 105 of file easypc_text_metrics.h.

Referenced by charWidth(), and TEXT_METRICS().

◆ m_height

int32_t EASYPC::TEXT_METRICS::m_height = 0
private

◆ m_interlinePercent

int32_t EASYPC::TEXT_METRICS::m_interlinePercent = 120
private

Definition at line 104 of file easypc_text_metrics.h.

Referenced by linePitch(), and TEXT_METRICS().

◆ m_penWidth

int32_t EASYPC::TEXT_METRICS::m_penWidth = 0
private

Definition at line 103 of file easypc_text_metrics.h.

Referenced by TEXT_METRICS(), TextBox(), and UprightAnchor().

◆ m_proportional

bool EASYPC::TEXT_METRICS::m_proportional = false
private

Definition at line 106 of file easypc_text_metrics.h.

Referenced by charWidth(), and TEXT_METRICS().

◆ m_typeFont

bool EASYPC::TEXT_METRICS::m_typeFont = false
private

Definition at line 107 of file easypc_text_metrics.h.

Referenced by CanMeasure(), checkMeasurable(), and TEXT_METRICS().


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