29#include <wx/textfile.h> 
   67    if( aFontName.empty() )
 
 
   86    for( 
const std::vector<VECTOR2D>& pointList : *aGlyph )
 
   88        for( 
const VECTOR2D& point : pointList )
 
   90            min.
y = std::min( min.
y, point.y );
 
   91            max.
y = std::max( max.
y, point.y );
 
   95    aGlyph->SetBoundingBox( 
BOX2D( min, max - min ) );
 
 
  111        for( 
int j = 0; j < aNewStrokeFontSize; j++ )
 
  113            std::shared_ptr<STROKE_GLYPH> glyph = std::make_shared<STROKE_GLYPH>();
 
  115            double glyphStartX = 0.0;
 
  116            double glyphEndX = 0.0;
 
  117            double glyphWidth = 0.0;
 
  121            while( aNewStrokeFont[j][i] )
 
  123                if( aNewStrokeFont[j][i] == 
' ' && aNewStrokeFont[j][i+1] == 
'R' )
 
  129            glyph->reserve( strokes + 1 );
 
  133            while( aNewStrokeFont[j][i] )
 
  136                char     coordinate[2] = { 0, };
 
  138                for( 
int k : { 0, 1 } )
 
  139                    coordinate[k] = aNewStrokeFont[j][i + k];
 
  146                    glyphWidth  = glyphEndX - glyphStartX;
 
  148                else if( ( coordinate[0] == 
' ' ) && ( coordinate[1] == 
'R' ) )
 
  169                    glyph->AddPoint( point );
 
 
  196    static double LEGACY_FACTOR = 0.9583;   
 
  198    return aFontMetrics.
GetInterline( aGlyphHeight ) * LEGACY_FACTOR;
 
 
  203                                       const wxString& aText, 
const VECTOR2I& aSize,
 
  205                                       bool aMirror, 
const VECTOR2I& aOrigin,
 
  208    constexpr int    TAB_WIDTH = 4;
 
  209    constexpr double INTER_CHAR = 0.2;
 
  210    constexpr double SUPER_SUB_SIZE_MULTIPLIER = 0.8;
 
  211    constexpr double SUPER_HEIGHT_OFFSET = 0.35;
 
  212    constexpr double SUB_HEIGHT_OFFSET = 0.15;
 
  222        glyphSize = glyphSize * SUPER_SUB_SIZE_MULTIPLIER;
 
  225            cursor.y += glyphSize.
y * SUB_HEIGHT_OFFSET;
 
  227            cursor.y -= glyphSize.
y * SUPER_HEIGHT_OFFSET;
 
  230    for( wxUniChar c : aText )
 
  235            char_count = ( char_count / TAB_WIDTH + 1 ) * TAB_WIDTH - 1;
 
  237            int new_cursor = aPosition.
x + aSize.
x * char_count
 
  238                    + aSize.
x * space_width;
 
  240            while( new_cursor <= 
cursor.x )
 
  242                char_count += TAB_WIDTH;
 
  243                new_cursor += aSize.
x * TAB_WIDTH;
 
  256            int dd = (signed) c - 
' ';
 
  262                dd = (signed) c - 
' ';
 
  269                aGlyphs->push_back( source->
Transform( glyphSize, 
cursor, tilt, aAngle, aMirror,
 
  275            glyphExtents *= glyphSize;
 
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
constexpr const Vec GetEnd() const
 
constexpr void SetOrigin(const Vec &pos)
 
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
 
constexpr void SetEnd(coord_type x, coord_type y)
 
wxString m_fontName
Font name.
 
wxString m_fontFileName
Font file name.
 
double GetInterline(double aFontHeight) const
 
double GetInterline(double aGlyphHeight, const METRICS &aFontMetrics) const override
Compute the distance (interline) between 2 lines of text (for multiline texts).
 
void loadNewStrokeFont(const char *const aNewStrokeFont[], int aNewStrokeFontSize)
Load the standard KiCad stroke font.
 
const STROKE_GLYPH * GetGlyph(unsigned aIndex) const
 
const BOX2D & GetGlyphBoundingBox(unsigned aIndex) const
 
const std::vector< BOX2D > * m_glyphBoundingBoxes
 
const std::vector< std::shared_ptr< GLYPH > > * m_glyphs
 
static STROKE_FONT * LoadFont(const wxString &aFontName)
Load a stroke font.
 
unsigned GetGlyphCount() const
 
VECTOR2I GetTextAsGlyphs(BOX2I *aBoundingBox, 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 override
Convert text string to an array of GLYPHs.
 
BOX2D BoundingBox() override
 
std::unique_ptr< GLYPH > Transform(const VECTOR2D &aGlyphSize, const VECTOR2I &aOffset, double aTilt, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin)
 
static bool empty(const wxTextEntryBase *aCtrl)
 
unsigned int TEXT_STYLE_FLAGS
 
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
 
const int newstroke_font_bufsize
 
const char *const newstroke_font[]
Modified 2019 to include based CJK Unicode Ideographs, using code copyright (c) 2018 Lingdong Huang.
 
static constexpr int FONT_OFFSET
Offset (in stroke font units) to move the origin to the baseline.
 
std::mutex g_defaultFontLoadMutex
 
std::vector< std::shared_ptr< GLYPH > > g_defaultFontGlyphs
 
bool g_defaultFontInitialized
 
std::vector< BOX2D > * g_defaultFontGlyphBoundingBoxes
 
void buildGlyphBoundingBox(std::shared_ptr< STROKE_GLYPH > &aGlyph, double aGlyphWidth)
 
static constexpr double STROKE_FONT_SCALE
Scale factor for a glyph.
 
VECTOR2< int32_t > VECTOR2I
 
VECTOR2< double > VECTOR2D