KiCad PCB EDA Suite
Loading...
Searching...
No Matches
outline_font.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Ola Rinta-Koski <[email protected]>
5 * Copyright (C) 2021-2024 Kicad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <limits>
26#include <harfbuzz/hb.h>
27#include <harfbuzz/hb-ft.h>
28#include <bezier_curves.h>
30#include <font/fontconfig.h>
31#include <font/outline_font.h>
32#include FT_GLYPH_H
33#include FT_BBOX_H
34#include <trigo.h>
35#include <core/utf8.h>
36
37using namespace KIFONT;
38
39
40FT_Library OUTLINE_FONT::m_freeType = nullptr;
42
44 m_face(NULL),
45 m_faceSize( 16 ),
46 m_fakeBold( false ),
47 m_fakeItal( false )
48{
49 std::lock_guard<std::mutex> guard( m_freeTypeMutex );
50
51 if( !m_freeType )
52 FT_Init_FreeType( &m_freeType );
53}
54
55
56OUTLINE_FONT* OUTLINE_FONT::LoadFont( const wxString& aFontName, bool aBold, bool aItalic )
57{
58 std::unique_ptr<OUTLINE_FONT> font = std::make_unique<OUTLINE_FONT>();
59
60 wxString fontFile;
61 int faceIndex;
62 using fc = fontconfig::FONTCONFIG;
63
64 fc::FF_RESULT retval = Fontconfig()->FindFont( aFontName, fontFile, faceIndex, aBold, aItalic );
65
66 if( retval == fc::FF_RESULT::FF_ERROR )
67 return nullptr;
68
69 if( retval == fc::FF_RESULT::FF_MISSING_BOLD || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
70 font->SetFakeBold();
71
72 if( retval == fc::FF_RESULT::FF_MISSING_ITAL || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
73 font->SetFakeItal();
74
75 if( font->loadFace( fontFile, faceIndex ) != 0 )
76 return nullptr;
77
78 font->m_fontName = aFontName; // Keep asked-for name, even if we substituted.
79 font->m_fontFileName = fontFile;
80
81 return font.release();
82}
83
84
85FT_Error OUTLINE_FONT::loadFace( const wxString& aFontFileName, int aFaceIndex )
86{
87 std::lock_guard<std::mutex> guard( m_freeTypeMutex );
88
89 FT_Error e = FT_New_Face( m_freeType, aFontFileName.mb_str( wxConvUTF8 ), aFaceIndex, &m_face );
90
91 if( !e )
92 {
93 FT_Select_Charmap( m_face, FT_Encoding::FT_ENCODING_UNICODE );
94 // params:
95 // m_face = handle to face object
96 // 0 = char width in 1/64th of points ( 0 = same as char height )
97 // faceSize() = char height in 1/64th of points
98 // GLYPH_RESOLUTION = horizontal device resolution (288dpi, 4x default)
99 // 0 = vertical device resolution ( 0 = same as horizontal )
100 FT_Set_Char_Size( m_face, 0, faceSize(), GLYPH_RESOLUTION, 0 );
101 }
102
103 return e;
104}
105
106
111double OUTLINE_FONT::GetInterline( double aGlyphHeight, const METRICS& aFontMetrics ) const
112{
113 double glyphToFontHeight = 1.0;
114
115 if( GetFace()->units_per_EM )
116 glyphToFontHeight = GetFace()->height / GetFace()->units_per_EM;
117
118 return aFontMetrics.GetInterline( aGlyphHeight * glyphToFontHeight );
119}
120
121
122static bool contourIsFilled( const CONTOUR& c )
123{
124 switch( c.m_Orientation )
125 {
126 case FT_ORIENTATION_TRUETYPE: return c.m_Winding == 1;
127 case FT_ORIENTATION_POSTSCRIPT: return c.m_Winding == -1;
128 default: return false;
129 }
130}
131
132
133static bool contourIsHole( const CONTOUR& c )
134{
135 return !contourIsFilled( c );
136}
137
138
139BOX2I OUTLINE_FONT::getBoundingBox( const std::vector<std::unique_ptr<GLYPH>>& aGlyphs ) const
140{
141 int minX = INT_MAX;
142 int minY = INT_MAX;
143 int maxX = INT_MIN;
144 int maxY = INT_MIN;
145
146 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
147 {
148 BOX2D bbox = glyph->BoundingBox();
149 bbox.Normalize();
150
151 if( minX > bbox.GetX() )
152 minX = bbox.GetX();
153
154 if( minY > bbox.GetY() )
155 minY = bbox.GetY();
156
157 if( maxX < bbox.GetRight() )
158 maxX = bbox.GetRight();
159
160 if( maxY < bbox.GetBottom() )
161 maxY = bbox.GetBottom();
162 }
163
164 BOX2I ret;
165 ret.SetOrigin( minX, minY );
166 ret.SetEnd( maxX, maxY );
167 return ret;
168}
169
170
171void OUTLINE_FONT::GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
172 const wxString& aText, const VECTOR2I& aPosition,
173 const TEXT_ATTRIBUTES& aAttrs,
174 const METRICS& aFontMetrics ) const
175{
176 wxArrayString strings;
177 std::vector<VECTOR2I> positions;
178 std::vector<VECTOR2I> extents;
179 TEXT_STYLE_FLAGS textStyle = 0;
180
181 if( aAttrs.m_Italic )
182 textStyle |= TEXT_STYLE::ITALIC;
183
184 getLinePositions( aText, aPosition, strings, positions, extents, aAttrs, aFontMetrics );
185
186 for( size_t i = 0; i < strings.GetCount(); i++ )
187 {
188 (void) drawMarkup( nullptr, aGlyphs, strings.Item( i ), positions[i], aAttrs.m_Size,
189 aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle, aFontMetrics );
190 }
191}
192
193
194VECTOR2I OUTLINE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
195 const wxString& aText, const VECTOR2I& aSize,
196 const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
197 bool aMirror, const VECTOR2I& aOrigin,
198 TEXT_STYLE_FLAGS aTextStyle ) const
199{
200 // HarfBuzz needs further processing to split tab-delimited text into text runs.
201
202 constexpr double TAB_WIDTH = 4 * 0.6;
203
204 VECTOR2I position = aPosition;
205 wxString textRun;
206
207 if( aBBox )
208 {
209 aBBox->SetOrigin( aPosition );
210 aBBox->SetEnd( aPosition );
211 }
212
213 for( wxUniChar c : aText )
214 {
215 // Handle tabs as locked to the nearest 4th column (in space-widths).
216 if( c == '\t' )
217 {
218 if( !textRun.IsEmpty() )
219 {
220 position = getTextAsGlyphs( aBBox, aGlyphs, textRun, aSize, position, aAngle,
221 aMirror, aOrigin, aTextStyle );
222 textRun.clear();
223 }
224
225 int tabWidth = KiROUND( aSize.x * TAB_WIDTH );
226 int currentIntrusion = ( position.x - aOrigin.x ) % tabWidth;
227
228 position.x += tabWidth - currentIntrusion;
229 }
230 else
231 {
232 textRun += c;
233 }
234 }
235
236 if( !textRun.IsEmpty() )
237 {
238 position = getTextAsGlyphs( aBBox, aGlyphs, textRun, aSize, position, aAngle, aMirror,
239 aOrigin, aTextStyle );
240 }
241
242 return position;
243}
244
245
246VECTOR2I OUTLINE_FONT::getTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
247 const wxString& aText, const VECTOR2I& aSize,
248 const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
249 bool aMirror, const VECTOR2I& aOrigin,
250 TEXT_STYLE_FLAGS aTextStyle ) const
251{
252 std::lock_guard<std::mutex> guard( m_freeTypeMutex );
253
254 return getTextAsGlyphsUnlocked( aBBox, aGlyphs, aText, aSize, aPosition, aAngle, aMirror,
255 aOrigin, aTextStyle );
256}
257
258
260 FT_Face face;
261 hb_codepoint_t codepoint;
262 double scaler;
265 bool mirror;
267
268 bool operator==(const GLYPH_CACHE_KEY& rhs ) const
269 {
270 return face == rhs.face && codepoint == rhs.codepoint && scaler == rhs.scaler
271 && fakeItalic == rhs.fakeItalic && fakeBold == rhs.fakeBold
272 && mirror == rhs.mirror && angle == rhs.angle;
273 }
274};
275
276namespace std
277{
278 template <>
279 struct hash<GLYPH_CACHE_KEY>
280 {
281 std::size_t operator()( const GLYPH_CACHE_KEY& k ) const
282 {
283 return hash<const void*>()( k.face ) ^ hash<unsigned>()( k.codepoint )
284 ^ hash<double>()( k.scaler )
285 ^ hash<int>()( k.fakeItalic ) ^ hash<int>()( k.fakeBold )
286 ^ hash<int>()( k.mirror ) ^ hash<int>()( k.angle.AsTenthsOfADegree() );
287 }
288 };
289}
290
291
293 std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
294 const wxString& aText, const VECTOR2I& aSize,
295 const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
296 bool aMirror, const VECTOR2I& aOrigin,
297 TEXT_STYLE_FLAGS aTextStyle ) const
298{
299 VECTOR2D glyphSize = aSize;
300 FT_Face face = m_face;
301 double scaler = faceSize();
302
303 if( IsSubscript( aTextStyle ) || IsSuperscript( aTextStyle ) )
304 {
305 scaler = subscriptSize();
306 }
307
308 // set glyph resolution so that FT_Load_Glyph() results are good enough for decomposing
309 FT_Set_Char_Size( face, 0, scaler, GLYPH_RESOLUTION, 0 );
310
311 hb_buffer_t* buf = hb_buffer_create();
312 hb_buffer_add_utf8( buf, UTF8( aText ).c_str(), -1, 0, -1 );
313 hb_buffer_guess_segment_properties( buf ); // guess direction, script, and language based on
314 // contents
315
316 hb_font_t* referencedFont = hb_ft_font_create_referenced( face );
317 hb_ft_font_set_funcs( referencedFont );
318 hb_shape( referencedFont, buf, nullptr, 0 );
319
320 unsigned int glyphCount;
321 hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount );
322 hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount );
323
324 VECTOR2D scaleFactor( glyphSize.x / faceSize(), -glyphSize.y / faceSize() );
325 scaleFactor = scaleFactor * m_outlineFontSizeCompensation;
326
327 VECTOR2I cursor( 0, 0 );
328
329 if( aGlyphs )
330 aGlyphs->reserve( glyphCount );
331
332 // GLYPH_DATA is a collection of all outlines in the glyph; for example the 'o' glyph
333 // generally contains 2 contours, one for the glyph outline and one for the hole
334 static std::unordered_map<GLYPH_CACHE_KEY, GLYPH_DATA> s_glyphCache;
335
336 for( unsigned int i = 0; i < glyphCount; i++ )
337 {
338 // Don't process glyphs that were already included in a previous cluster
339 if( i > 0 && glyphInfo[i].cluster == glyphInfo[i-1].cluster )
340 continue;
341
342 if( aGlyphs )
343 {
344 GLYPH_CACHE_KEY key = { face, glyphInfo[i].codepoint, scaler, m_fakeItal, m_fakeBold,
345 aMirror, aAngle };
346 GLYPH_DATA& glyphData = s_glyphCache[ key ];
347
348 if( glyphData.m_Contours.empty() )
349 {
350 if( m_fakeItal )
351 {
352 FT_Matrix matrix;
353 // Create a 12 degree slant
354 const float angle = (float)( -M_PI * 12.0f ) / 180.0f;
355 matrix.xx = (FT_Fixed) ( cos( angle ) * 0x10000L );
356 matrix.xy = (FT_Fixed) ( -sin( angle ) * 0x10000L );
357 matrix.yx = (FT_Fixed) ( 0 * 0x10000L ); // Don't rotate in the y direction
358 matrix.yy = (FT_Fixed) ( 1 * 0x10000L );
359
360 FT_Set_Transform( face, &matrix, nullptr );
361 }
362
363 FT_Load_Glyph( face, glyphInfo[i].codepoint, FT_LOAD_NO_BITMAP );
364
365 if( m_fakeBold )
366 FT_Outline_Embolden( &face->glyph->outline, 1 << 6 );
367
368 OUTLINE_DECOMPOSER decomposer( face->glyph->outline );
369
370 if( !decomposer.OutlineToSegments( &glyphData.m_Contours ) )
371 {
372 double hb_advance = glyphPos[i].x_advance * GLYPH_SIZE_SCALER;
373 BOX2D tofuBox( { scaler * 0.03, 0.0 },
374 { hb_advance - scaler * 0.02, scaler * 0.72 } );
375
376 glyphData.m_Contours.clear();
377
378 CONTOUR outline;
379 outline.m_Winding = 1;
380 outline.m_Orientation = FT_ORIENTATION_TRUETYPE;
381 outline.m_Points.push_back( tofuBox.GetPosition() );
382 outline.m_Points.push_back( { tofuBox.GetSize().x, tofuBox.GetPosition().y } );
383 outline.m_Points.push_back( tofuBox.GetSize() );
384 outline.m_Points.push_back( { tofuBox.GetPosition().x, tofuBox.GetSize().y } );
385 glyphData.m_Contours.push_back( outline );
386
387 CONTOUR hole;
388 tofuBox.Move( { scaler * 0.06, scaler * 0.06 } );
389 tofuBox.SetSize( { tofuBox.GetWidth() - scaler * 0.06,
390 tofuBox.GetHeight() - scaler * 0.06 } );
391 hole.m_Winding = 1;
392 hole.m_Orientation = FT_ORIENTATION_NONE;
393 hole.m_Points.push_back( tofuBox.GetPosition() );
394 hole.m_Points.push_back( { tofuBox.GetSize().x, tofuBox.GetPosition().y } );
395 hole.m_Points.push_back( tofuBox.GetSize() );
396 hole.m_Points.push_back( { tofuBox.GetPosition().x, tofuBox.GetSize().y } );
397 glyphData.m_Contours.push_back( hole );
398 }
399 }
400
401 std::unique_ptr<OUTLINE_GLYPH> glyph = std::make_unique<OUTLINE_GLYPH>();
402 std::vector<SHAPE_LINE_CHAIN> holes;
403
404 for( CONTOUR& c : glyphData.m_Contours )
405 {
406 std::vector<VECTOR2D> points = c.m_Points;
407 SHAPE_LINE_CHAIN shape;
408
409 shape.ReservePoints( points.size() );
410
411 for( const VECTOR2D& v : points )
412 {
413 VECTOR2D pt( v + cursor );
414
415 if( IsSubscript( aTextStyle ) )
416 pt.y += m_subscriptVerticalOffset * scaler;
417 else if( IsSuperscript( aTextStyle ) )
418 pt.y += m_superscriptVerticalOffset * scaler;
419
420 pt *= scaleFactor;
421 pt += aPosition;
422
423 if( aMirror )
424 pt.x = aOrigin.x - ( pt.x - aOrigin.x );
425
426 if( !aAngle.IsZero() )
427 RotatePoint( pt, aOrigin, aAngle );
428
429 shape.Append( pt.x, pt.y );
430 }
431
432 shape.SetClosed( true );
433
434 if( contourIsHole( c ) )
435 holes.push_back( std::move( shape ) );
436 else
437 glyph->AddOutline( std::move( shape ) );
438 }
439
440 for( SHAPE_LINE_CHAIN& hole : holes )
441 {
442 if( hole.PointCount() )
443 {
444 for( int ii = 0; ii < glyph->OutlineCount(); ++ii )
445 {
446 if( glyph->Outline( ii ).PointInside( hole.GetPoint( 0 ) ) )
447 {
448 glyph->AddHole( std::move( hole ), ii );
449 break;
450 }
451 }
452 }
453 }
454
455 if( glyphData.m_TriangulationData.empty() )
456 {
457 glyph->CacheTriangulation( false, false );
458 glyphData.m_TriangulationData = glyph->GetTriangulationData();
459 }
460 else
461 {
462 glyph->CacheTriangulation( glyphData.m_TriangulationData );
463 }
464
465 aGlyphs->push_back( std::move( glyph ) );
466 }
467
468 hb_glyph_position_t& pos = glyphPos[i];
469 cursor.x += ( pos.x_advance * GLYPH_SIZE_SCALER );
470 cursor.y += ( pos.y_advance * GLYPH_SIZE_SCALER );
471 }
472
473 int ascender = abs( face->size->metrics.ascender * GLYPH_SIZE_SCALER );
474 int descender = abs( face->size->metrics.descender * GLYPH_SIZE_SCALER );
475 VECTOR2I extents( cursor.x * scaleFactor.x, ( ascender + descender ) * abs( scaleFactor.y ) );
476
477 hb_buffer_destroy( buf );
478 hb_font_destroy( referencedFont );
479
480 VECTOR2I cursorDisplacement( cursor.x * scaleFactor.x, -cursor.y * scaleFactor.y );
481
482 if( aBBox )
483 aBBox->Merge( aPosition + extents );
484
485 return VECTOR2I( aPosition.x + cursorDisplacement.x, aPosition.y + cursorDisplacement.y );
486}
487
488
489#undef OUTLINEFONT_RENDER_AS_PIXELS
490#ifdef OUTLINEFONT_RENDER_AS_PIXELS
491/*
492 * WIP: eeschema (and PDF output?) should use pixel rendering instead of linear segmentation
493 */
494void OUTLINE_FONT::RenderToOpenGLCanvas( KIGFX::OPENGL_GAL& aGal, const wxString& aString,
495 const VECTOR2D& aGlyphSize, const VECTOR2I& aPosition,
496 const EDA_ANGLE& aOrientation, bool aIsMirrored ) const
497{
498 hb_buffer_t* buf = hb_buffer_create();
499 hb_buffer_add_utf8( buf, UTF8( aString ).c_str(), -1, 0, -1 );
500 hb_buffer_guess_segment_properties( buf ); // guess direction, script, and language based on contents
501
502 unsigned int glyphCount;
503 hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount );
504 hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount );
505
506 std::lock_guard<std::mutex> guard( m_freeTypeMutex );
507
508 hb_font_t* referencedFont = hb_ft_font_create_referenced( m_face );
509
510 hb_ft_font_set_funcs( referencedFont );
511 hb_shape( referencedFont, buf, nullptr, 0 );
512
513 const double mirror_factor = ( aIsMirrored ? 1 : -1 );
514 const double x_scaleFactor = mirror_factor * aGlyphSize.x / mScaler;
515 const double y_scaleFactor = aGlyphSize.y / mScaler;
516
517 hb_position_t cursor_x = 0;
518 hb_position_t cursor_y = 0;
519
520 for( unsigned int i = 0; i < glyphCount; i++ )
521 {
522 hb_glyph_position_t& pos = glyphPos[i];
523 int codepoint = glyphInfo[i].codepoint;
524
525 FT_Error e = FT_Load_Glyph( m_face, codepoint, FT_LOAD_DEFAULT );
526 // TODO handle FT_Load_Glyph error
527
528 FT_Glyph glyph;
529 e = FT_Get_Glyph( m_face->glyph, &glyph );
530 // TODO handle FT_Get_Glyph error
531
532 wxPoint pt( aPosition );
533 pt.x += ( cursor_x >> 6 ) * x_scaleFactor;
534 pt.y += ( cursor_y >> 6 ) * y_scaleFactor;
535
536 cursor_x += pos.x_advance;
537 cursor_y += pos.y_advance;
538 }
539
540 hb_buffer_destroy( buf );
541}
542#endif //OUTLINEFONT_RENDER_AS_PIXELS
void SetOrigin(const Vec &pos)
Definition: box2.h:227
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
coord_type GetY() const
Definition: box2.h:198
coord_type GetX() const
Definition: box2.h:197
coord_type GetRight() const
Definition: box2.h:207
coord_type GetBottom() const
Definition: box2.h:212
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:280
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:623
int AsTenthsOfADegree() const
Definition: eda_angle.h:157
bool IsZero() const
Definition: eda_angle.h:175
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
Definition: font.cpp:178
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
Definition: font.cpp:383
double GetInterline(double aFontHeight) const
Definition: font.h:114
bool OutlineToSegments(std::vector< CONTOUR > *aContours)
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:52
VECTOR2I getTextAsGlyphsUnlocked(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
static std::mutex m_freeTypeMutex
Mutex for freetype access, FT_Library and FT_Face are not thread safe.
Definition: outline_font.h:131
double GetInterline(double aGlyphHeight, const METRICS &aFontMetrics) const override
Compute the distance (interline) between 2 lines of text (for multiline texts).
static FT_Library m_freeType
Definition: outline_font.h:132
BOX2I getBoundingBox(const std::vector< std::unique_ptr< GLYPH > > &aGlyphs) const
FT_Error loadFace(const wxString &aFontFileName, int aFaceIndex)
static constexpr double m_superscriptVerticalOffset
Definition: outline_font.h:176
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
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.
const FT_Face & GetFace() const
Definition: outline_font.h:99
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs, const METRICS &aFontMetrics) const
int faceSize() const
Definition: outline_font.h:166
static constexpr double m_outlineFontSizeCompensation
Definition: outline_font.h:148
int subscriptSize() const
Definition: outline_font.h:173
static OUTLINE_FONT * LoadFont(const wxString &aFontFileName, bool aBold, bool aItalic)
Load an outline font.
static constexpr double m_subscriptVerticalOffset
Definition: outline_font.h:175
OpenGL implementation of the Graphics Abstraction Layer.
Definition: opengl_gal.h:71
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void ReservePoints(size_t aSize)
Allocate a number of points all at once (for performance).
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:72
unsigned int TEXT_STYLE_FLAGS
Definition: font.h:64
bool IsSuperscript(TEXT_STYLE_FLAGS aFlags)
Definition: font.h:79
bool IsSubscript(TEXT_STYLE_FLAGS aFlags)
Definition: font.h:85
FONTCONFIG * Fontconfig()
Definition: fontconfig.cpp:90
constexpr int GLYPH_RESOLUTION
Definition: glyph.h:46
constexpr double GLYPH_SIZE_SCALER
Definition: glyph.h:47
STL namespace.
static bool contourIsHole(const CONTOUR &c)
static bool contourIsFilled(const CONTOUR &c)
hb_codepoint_t codepoint
bool operator==(const GLYPH_CACHE_KEY &rhs) const
std::vector< VECTOR2D > m_Points
FT_Orientation m_Orientation
std::vector< CONTOUR > m_Contours
std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > m_TriangulationData
std::size_t operator()(const GLYPH_CACHE_KEY &k) const
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:228
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:118
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602