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;
264 bool mirror;
266
267 bool operator==(const GLYPH_CACHE_KEY& rhs ) const
268 {
269 return face == rhs.face && codepoint == rhs.codepoint
270 && fakeItalic == rhs.fakeItalic && fakeBold == rhs.fakeBold
271 && mirror == rhs.mirror && angle == rhs.angle;
272 }
273};
274
275namespace std
276{
277 template <>
278 struct hash<GLYPH_CACHE_KEY>
279 {
280 std::size_t operator()( const GLYPH_CACHE_KEY& k ) const
281 {
282 return hash<const void*>()( k.face ) ^ hash<unsigned>()( k.codepoint )
283 ^ hash<int>()( k.fakeItalic ) ^ hash<int>()( k.fakeBold )
284 ^ hash<int>()( k.mirror ) ^ hash<int>()( k.angle.AsTenthsOfADegree() );
285 }
286 };
287}
288
289
291 std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
292 const wxString& aText, const VECTOR2I& aSize,
293 const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
294 bool aMirror, const VECTOR2I& aOrigin,
295 TEXT_STYLE_FLAGS aTextStyle ) const
296{
297 VECTOR2D glyphSize = aSize;
298 FT_Face face = m_face;
299 double scaler = faceSize();
300
301 if( IsSubscript( aTextStyle ) || IsSuperscript( aTextStyle ) )
302 {
303 scaler = subscriptSize();
304 }
305
306 // set glyph resolution so that FT_Load_Glyph() results are good enough for decomposing
307 FT_Set_Char_Size( face, 0, scaler, GLYPH_RESOLUTION, 0 );
308
309 hb_buffer_t* buf = hb_buffer_create();
310 hb_buffer_add_utf8( buf, UTF8( aText ).c_str(), -1, 0, -1 );
311 hb_buffer_guess_segment_properties( buf ); // guess direction, script, and language based on
312 // contents
313
314 hb_font_t* referencedFont = hb_ft_font_create_referenced( face );
315 hb_ft_font_set_funcs( referencedFont );
316 hb_shape( referencedFont, buf, nullptr, 0 );
317
318 unsigned int glyphCount;
319 hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount );
320 hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount );
321
322 VECTOR2D scaleFactor( glyphSize.x / faceSize(), -glyphSize.y / faceSize() );
323 scaleFactor = scaleFactor * m_outlineFontSizeCompensation;
324
325 VECTOR2I cursor( 0, 0 );
326
327 if( aGlyphs )
328 aGlyphs->reserve( glyphCount );
329
330 // GLYPH_DATA is a collection of all outlines in the glyph; for example the 'o' glyph
331 // generally contains 2 contours, one for the glyph outline and one for the hole
332 static std::unordered_map<GLYPH_CACHE_KEY, GLYPH_DATA> s_glyphCache;
333
334 for( unsigned int i = 0; i < glyphCount; i++ )
335 {
336 // Don't process glyphs that were already included in a previous cluster
337 if( i > 0 && glyphInfo[i].cluster == glyphInfo[i-1].cluster )
338 continue;
339
340 if( aGlyphs )
341 {
342 GLYPH_CACHE_KEY key = { face, glyphInfo[i].codepoint, m_fakeItal, m_fakeBold,
343 aMirror, aAngle };
344 GLYPH_DATA& glyphData = s_glyphCache[ key ];
345
346 if( glyphData.m_Contours.empty() )
347 {
348 if( m_fakeItal )
349 {
350 FT_Matrix matrix;
351 // Create a 12 degree slant
352 const float angle = (float)( -M_PI * 12.0f ) / 180.0f;
353 matrix.xx = (FT_Fixed) ( cos( angle ) * 0x10000L );
354 matrix.xy = (FT_Fixed) ( -sin( angle ) * 0x10000L );
355 matrix.yx = (FT_Fixed) ( 0 * 0x10000L ); // Don't rotate in the y direction
356 matrix.yy = (FT_Fixed) ( 1 * 0x10000L );
357
358 FT_Set_Transform( face, &matrix, nullptr );
359 }
360
361 FT_Load_Glyph( face, glyphInfo[i].codepoint, FT_LOAD_NO_BITMAP );
362
363 if( m_fakeBold )
364 FT_Outline_Embolden( &face->glyph->outline, 1 << 6 );
365
366 OUTLINE_DECOMPOSER decomposer( face->glyph->outline );
367
368 if( !decomposer.OutlineToSegments( &glyphData.m_Contours ) )
369 {
370 double hb_advance = glyphPos[i].x_advance * GLYPH_SIZE_SCALER;
371 BOX2D tofuBox( { scaler * 0.03, 0.0 },
372 { hb_advance - scaler * 0.02, scaler * 0.72 } );
373
374 glyphData.m_Contours.clear();
375
376 CONTOUR outline;
377 outline.m_Winding = 1;
378 outline.m_Orientation = FT_ORIENTATION_TRUETYPE;
379 outline.m_Points.push_back( tofuBox.GetPosition() );
380 outline.m_Points.push_back( { tofuBox.GetSize().x, tofuBox.GetPosition().y } );
381 outline.m_Points.push_back( tofuBox.GetSize() );
382 outline.m_Points.push_back( { tofuBox.GetPosition().x, tofuBox.GetSize().y } );
383 glyphData.m_Contours.push_back( outline );
384
385 CONTOUR hole;
386 tofuBox.Move( { scaler * 0.06, scaler * 0.06 } );
387 tofuBox.SetSize( { tofuBox.GetWidth() - scaler * 0.06,
388 tofuBox.GetHeight() - scaler * 0.06 } );
389 hole.m_Winding = 1;
390 hole.m_Orientation = FT_ORIENTATION_NONE;
391 hole.m_Points.push_back( tofuBox.GetPosition() );
392 hole.m_Points.push_back( { tofuBox.GetSize().x, tofuBox.GetPosition().y } );
393 hole.m_Points.push_back( tofuBox.GetSize() );
394 hole.m_Points.push_back( { tofuBox.GetPosition().x, tofuBox.GetSize().y } );
395 glyphData.m_Contours.push_back( hole );
396 }
397 }
398
399 std::unique_ptr<OUTLINE_GLYPH> glyph = std::make_unique<OUTLINE_GLYPH>();
400 std::vector<SHAPE_LINE_CHAIN> holes;
401
402 for( CONTOUR& c : glyphData.m_Contours )
403 {
404 std::vector<VECTOR2D> points = c.m_Points;
405 SHAPE_LINE_CHAIN shape;
406
407 shape.ReservePoints( points.size() );
408
409 for( const VECTOR2D& v : points )
410 {
411 VECTOR2D pt( v + cursor );
412
413 if( IsSubscript( aTextStyle ) )
414 pt.y += m_subscriptVerticalOffset * scaler;
415 else if( IsSuperscript( aTextStyle ) )
416 pt.y += m_superscriptVerticalOffset * scaler;
417
418 pt *= scaleFactor;
419 pt += aPosition;
420
421 if( aMirror )
422 pt.x = aOrigin.x - ( pt.x - aOrigin.x );
423
424 if( !aAngle.IsZero() )
425 RotatePoint( pt, aOrigin, aAngle );
426
427 shape.Append( pt.x, pt.y );
428 }
429
430 shape.SetClosed( true );
431
432 if( contourIsHole( c ) )
433 holes.push_back( std::move( shape ) );
434 else
435 glyph->AddOutline( std::move( shape ) );
436 }
437
438 for( SHAPE_LINE_CHAIN& hole : holes )
439 {
440 if( hole.PointCount() )
441 {
442 for( int ii = 0; ii < glyph->OutlineCount(); ++ii )
443 {
444 if( glyph->Outline( ii ).PointInside( hole.GetPoint( 0 ) ) )
445 {
446 glyph->AddHole( std::move( hole ), ii );
447 break;
448 }
449 }
450 }
451 }
452
453 if( glyphData.m_TriangulationData.empty() )
454 {
455 glyph->CacheTriangulation( false, false );
456 glyphData.m_TriangulationData = glyph->GetTriangulationData();
457 }
458 else
459 {
460 glyph->CacheTriangulation( glyphData.m_TriangulationData );
461 }
462
463 aGlyphs->push_back( std::move( glyph ) );
464 }
465
466 hb_glyph_position_t& pos = glyphPos[i];
467 cursor.x += ( pos.x_advance * GLYPH_SIZE_SCALER );
468 cursor.y += ( pos.y_advance * GLYPH_SIZE_SCALER );
469 }
470
471 int ascender = abs( face->size->metrics.ascender * GLYPH_SIZE_SCALER );
472 int descender = abs( face->size->metrics.descender * GLYPH_SIZE_SCALER );
473 VECTOR2I extents( cursor.x * scaleFactor.x, ( ascender + descender ) * abs( scaleFactor.y ) );
474
475 hb_buffer_destroy( buf );
476 hb_font_destroy( referencedFont );
477
478 VECTOR2I cursorDisplacement( cursor.x * scaleFactor.x, -cursor.y * scaleFactor.y );
479
480 if( aBBox )
481 aBBox->Merge( aPosition + extents );
482
483 return VECTOR2I( aPosition.x + cursorDisplacement.x, aPosition.y + cursorDisplacement.y );
484}
485
486
487#undef OUTLINEFONT_RENDER_AS_PIXELS
488#ifdef OUTLINEFONT_RENDER_AS_PIXELS
489/*
490 * WIP: eeschema (and PDF output?) should use pixel rendering instead of linear segmentation
491 */
492void OUTLINE_FONT::RenderToOpenGLCanvas( KIGFX::OPENGL_GAL& aGal, const wxString& aString,
493 const VECTOR2D& aGlyphSize, const VECTOR2I& aPosition,
494 const EDA_ANGLE& aOrientation, bool aIsMirrored ) const
495{
496 hb_buffer_t* buf = hb_buffer_create();
497 hb_buffer_add_utf8( buf, UTF8( aString ).c_str(), -1, 0, -1 );
498 hb_buffer_guess_segment_properties( buf ); // guess direction, script, and language based on contents
499
500 unsigned int glyphCount;
501 hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount );
502 hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount );
503
504 std::lock_guard<std::mutex> guard( m_freeTypeMutex );
505
506 hb_font_t* referencedFont = hb_ft_font_create_referenced( m_face );
507
508 hb_ft_font_set_funcs( referencedFont );
509 hb_shape( referencedFont, buf, nullptr, 0 );
510
511 const double mirror_factor = ( aIsMirrored ? 1 : -1 );
512 const double x_scaleFactor = mirror_factor * aGlyphSize.x / mScaler;
513 const double y_scaleFactor = aGlyphSize.y / mScaler;
514
515 hb_position_t cursor_x = 0;
516 hb_position_t cursor_y = 0;
517
518 for( unsigned int i = 0; i < glyphCount; i++ )
519 {
520 hb_glyph_position_t& pos = glyphPos[i];
521 int codepoint = glyphInfo[i].codepoint;
522
523 FT_Error e = FT_Load_Glyph( m_face, codepoint, FT_LOAD_DEFAULT );
524 // TODO handle FT_Load_Glyph error
525
526 FT_Glyph glyph;
527 e = FT_Get_Glyph( m_face->glyph, &glyph );
528 // TODO handle FT_Get_Glyph error
529
530 wxPoint pt( aPosition );
531 pt.x += ( cursor_x >> 6 ) * x_scaleFactor;
532 pt.y += ( cursor_y >> 6 ) * y_scaleFactor;
533
534 cursor_x += pos.x_advance;
535 cursor_y += pos.y_advance;
536 }
537
538 hb_buffer_destroy( buf );
539}
540#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:588