KiCad PCB EDA Suite
stroke_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) 2012 Torsten Hueter, torstenhtr <at> gmx.de
5  * Copyright (C) 2013 CERN
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  * Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors.
8  *
9  * Stroke font class
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, you may find one here:
23  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24  * or you may search the http://www.gnu.org website for the version 2 license,
25  * or you may write to the Free Software Foundation, Inc.,
26  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27  */
28 
29 #include <gal/stroke_font.h>
31 #include <wx/string.h>
32 
33 
34 using namespace KIGFX;
35 
36 const double STROKE_FONT::INTERLINE_PITCH_RATIO = 1.61;
37 const double STROKE_FONT::OVERBAR_POSITION_FACTOR = 1.22;
38 const double STROKE_FONT::BOLD_FACTOR = 1.3;
39 const double STROKE_FONT::STROKE_FONT_SCALE = 1.0 / 21.0;
40 const double STROKE_FONT::ITALIC_TILT = 1.0 / 8;
41 
42 
44 std::vector<BOX2D>* g_newStrokeFontGlyphBoundingBoxes;
45 
46 
48  m_gal( aGal ), m_glyphs( nullptr ), m_glyphBoundingBoxes( nullptr )
49 {
50 }
51 
52 
53 bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize )
54 {
56  {
59  return true;
60  }
61 
63  g_newStrokeFontGlyphs->reserve( aNewStrokeFontSize );
64 
65  g_newStrokeFontGlyphBoundingBoxes = new std::vector<BOX2D>;
66  g_newStrokeFontGlyphBoundingBoxes->reserve( aNewStrokeFontSize );
67 
68  for( int j = 0; j < aNewStrokeFontSize; j++ )
69  {
70  GLYPH glyph;
71  double glyphStartX = 0.0;
72  double glyphEndX = 0.0;
73  double glyphWidth = 0.0;
74 
75  std::vector<VECTOR2D>* pointList = nullptr;
76 
77  int strokes = 0;
78  int i = 0;
79 
80  while( aNewStrokeFont[j][i] )
81  {
82 
83  if( aNewStrokeFont[j][i] == ' ' && aNewStrokeFont[j][i+1] == 'R' )
84  strokes++;
85 
86  i += 2;
87  }
88 
89  glyph.reserve( strokes + 1 );
90 
91  i = 0;
92 
93  while( aNewStrokeFont[j][i] )
94  {
95  VECTOR2D point( 0.0, 0.0 );
96  char coordinate[2] = { 0, };
97 
98  for( int k : { 0, 1 } )
99  coordinate[k] = aNewStrokeFont[j][i + k];
100 
101  if( i < 2 )
102  {
103  // The first two values contain the width of the char
104  glyphStartX = ( coordinate[0] - 'R' ) * STROKE_FONT_SCALE;
105  glyphEndX = ( coordinate[1] - 'R' ) * STROKE_FONT_SCALE;
106  glyphWidth = glyphEndX - glyphStartX;
107  }
108  else if( ( coordinate[0] == ' ' ) && ( coordinate[1] == 'R' ) )
109  {
110  if( pointList )
111  pointList->shrink_to_fit();
112 
113  // Raise pen
114  pointList = nullptr;
115  }
116  else
117  {
118  // In stroke font, coordinates values are coded as <value> + 'R',
119  // <value> is an ASCII char.
120  // therefore every coordinate description of the Hershey format has an offset,
121  // it has to be subtracted
122  // Note:
123  // * the stroke coordinates are stored in reduced form (-1.0 to +1.0),
124  // and the actual size is stroke coordinate * glyph size
125  // * a few shapes have a height slightly bigger than 1.0 ( like '{' '[' )
126  point.x = (double) ( coordinate[0] - 'R' ) * STROKE_FONT_SCALE - glyphStartX;
127  #define FONT_OFFSET -10
128  // FONT_OFFSET is here for historical reasons, due to the way the stroke font
129  // was built. It allows shapes coordinates like W M ... to be >= 0
130  // Only shapes like j y have coordinates < 0
131  point.y = (double) ( coordinate[1] - 'R' + FONT_OFFSET ) * STROKE_FONT_SCALE;
132 
133  if( !pointList )
134  {
135  glyph.emplace_back();
136  pointList = &glyph.back();
137  }
138 
139  pointList->push_back( point );
140  }
141 
142  i += 2;
143  }
144 
145  if( pointList )
146  pointList->shrink_to_fit();
147 
148  // Compute the bounding box of the glyph
149  g_newStrokeFontGlyphBoundingBoxes->emplace_back( computeBoundingBox( glyph, glyphWidth ) );
150  g_newStrokeFontGlyphs->push_back( glyph );
151  }
152 
155  return true;
156 }
157 
158 
159 // Static function:
160 double STROKE_FONT::GetInterline( double aGlyphHeight )
161 {
162  // Do not add the glyph thickness to the interline. This makes bold text line-spacing
163  // different from normal text, which is poor typography.
164  return ( aGlyphHeight * INTERLINE_PITCH_RATIO );
165 }
166 
167 
168 BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, double aGlyphWidth ) const
169 {
170  VECTOR2D min( 0, 0 );
171  VECTOR2D max( aGlyphWidth, 0 );
172 
173  for( const std::vector<VECTOR2D>& pointList : aGLYPH )
174  {
175  for( const VECTOR2D& point : pointList )
176  {
177  min.y = std::min( min.y, point.y );
178  max.y = std::max( max.y, point.y );
179  }
180  }
181 
182  return BOX2D( min, max - min );
183 }
184 
185 
186 void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRotationAngle,
187  int markupFlags )
188 {
189  if( aText.empty() )
190  return;
191 
192  // Context needs to be saved before any transformations
193  m_gal->Save();
194 
195  m_gal->Translate( aPosition );
196  m_gal->Rotate( -aRotationAngle );
197 
198  // Single line height
199  int lineHeight = KiROUND( GetInterline( m_gal->GetGlyphSize().y ) );
200  int lineCount = linesCount( aText );
201  const VECTOR2D& glyphSize = m_gal->GetGlyphSize();
202 
203  // align the 1st line of text
204  switch( m_gal->GetVerticalJustify() )
205  {
207  m_gal->Translate( VECTOR2D( 0, glyphSize.y ) );
208  break;
209 
211  m_gal->Translate( VECTOR2D( 0, glyphSize.y / 2.0 ) );
212  break;
213 
215  break;
216 
217  default:
218  break;
219  }
220 
221  if( lineCount > 1 )
222  {
223  switch( m_gal->GetVerticalJustify() )
224  {
226  break;
227 
229  m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) );
230  break;
231 
233  m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) );
234  break;
235  }
236  }
237 
238  m_gal->SetIsStroke( true );
239  //m_gal->SetIsFill( false );
240 
241  if( m_gal->IsFontBold() )
243 
244  // Split multiline strings into separate ones and draw them line by line
245  size_t begin = 0;
246  size_t newlinePos = aText.find( '\n' );
247 
248  while( newlinePos != aText.npos )
249  {
250  size_t length = newlinePos - begin;
251 
252  drawSingleLineText( aText.substr( begin, length ), markupFlags );
253  m_gal->Translate( VECTOR2D( 0.0, lineHeight ) );
254 
255  begin = newlinePos + 1;
256  newlinePos = aText.find( '\n', begin );
257  }
258 
259  // Draw the last (or the only one) line
260  if( !aText.empty() )
261  drawSingleLineText( aText.substr( begin ), markupFlags );
262 
263  m_gal->Restore();
264 }
265 
266 
267 void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
268 {
269  double xOffset;
270  double yOffset;
271  VECTOR2D baseGlyphSize( m_gal->GetGlyphSize() );
272  double overbar_italic_comp = computeOverbarVerticalPosition() * ITALIC_TILT;
273 
274  if( m_gal->IsTextMirrored() )
275  overbar_italic_comp = -overbar_italic_comp;
276 
277  // Compute the text size
278  VECTOR2D textSize = computeTextLineSize( aText, markupFlags );
279  double half_thickness = m_gal->GetLineWidth()/2;
280 
281  // Context needs to be saved before any transformations
282  m_gal->Save();
283 
284  // First adjust: the text X position is corrected by half_thickness
285  // because when the text with thickness is draw, its full size is textSize,
286  // but the position of lines is half_thickness to textSize - half_thickness
287  // so we must translate the coordinates by half_thickness on the X axis
288  // to place the text inside the 0 to textSize X area.
289  m_gal->Translate( VECTOR2D( half_thickness, 0 ) );
290 
291  // Adjust the text position to the given horizontal justification
292  switch( m_gal->GetHorizontalJustify() )
293  {
295  m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
296  break;
297 
299  if( !m_gal->IsTextMirrored() )
300  m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
301  break;
302 
304  if( m_gal->IsTextMirrored() )
305  m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
306  break;
307 
308  default:
309  break;
310  }
311 
312  if( m_gal->IsTextMirrored() )
313  {
314  // In case of mirrored text invert the X scale of points and their X direction
315  // (m_glyphSize.x) and start drawing from the position where text normally should end
316  // (textSize.x)
317  xOffset = textSize.x - m_gal->GetLineWidth();
318  baseGlyphSize.x = -baseGlyphSize.x;
319  }
320  else
321  {
322  xOffset = 0.0;
323  }
324 
325  // The overbar is indented inward at the beginning of an italicized section, but
326  // must not be indented on subsequent letters to ensure that the bar segments
327  // overlap.
328  bool last_had_overbar = false;
329  bool in_overbar = false;
330  VECTOR2D glyphSize = baseGlyphSize;
331 
332  yOffset = 0;
333 
334  for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
335  {
336  // Handle tabs as locked to the nearest 4th column (counting in spaces)
337  // The choice of spaces is somewhat arbitrary but sufficient for aligning text
338  if( *chIt == '\t' )
339  {
340  double space = glyphSize.x * m_glyphBoundingBoxes->at( 0 ).GetEnd().x;
341 
342  // We align to the 4th column (fmod) but only need to account for 3 of
343  // the four spaces here with the extra. This ensures that we have at
344  // least 1 space for the \t character
345  double addlSpace = 3.0 * space - std::fmod( xOffset, 4.0 * space );
346 
347  // Add the remaining space (between 0 and 3 spaces)
348  // The fourth space is added by the 'dd' character
349  xOffset += addlSpace;
350 
351  glyphSize = baseGlyphSize;
352  yOffset = 0;
353  }
354  else if( *chIt == '~' )
355  {
356  if( ++chIt == end )
357  break;
358 
359  if( *chIt == '~' )
360  {
361  // double ~ is really a ~ so go ahead and process the second one
362 
363  // so what's a triple ~? It could be a real ~ followed by an overbar, or
364  // it could be an overbar followed by a real ~. The old algorithm did the
365  // later so we will too....
366  auto tempIt = chIt;
367 
368  if( ++tempIt < end && *tempIt == '~' )
369  {
370  // eat the first two, toggle overbar, and then process the third
371  ++chIt;
372  in_overbar = !in_overbar;
373  }
374  }
375  else
376  {
377  in_overbar = !in_overbar;
378  }
379  }
380  else if( *chIt == '^' && ( markupFlags & ENABLE_SUPERSCRIPT_MARKUP ) )
381  {
382  if( ++chIt == end )
383  break;
384 
385  if( *chIt == '^' )
386  {
387  // double ^ is really a ^ so go ahead and process the second one
388  }
389  else
390  {
391  // single ^ starts a superscript
392  glyphSize = baseGlyphSize * 0.8;
393  yOffset = -baseGlyphSize.y * 0.3;
394  }
395  }
396  else if( *chIt == '#' && ( markupFlags & ENABLE_SUBSCRIPT_MARKUP ) )
397  {
398  if( ++chIt == end )
399  break;
400 
401  if( *chIt == '#' )
402  {
403  // double # is really a # so go ahead and process the second one
404  }
405  else
406  {
407  // single _ starts a subscript
408  glyphSize = baseGlyphSize * 0.8;
409  yOffset = baseGlyphSize.y * 0.1;
410  }
411  }
412  else if( *chIt == ' ' )
413  {
414  // space ends a super- or subscript
415  glyphSize = baseGlyphSize;
416  yOffset = 0;
417  }
418 
419  // Index into bounding boxes table
420  int dd = (signed) *chIt - ' ';
421 
422  if( dd >= (int) m_glyphBoundingBoxes->size() || dd < 0 )
423  {
424  int substitute = *chIt == '\t' ? ' ' : '?';
425  dd = substitute - ' ';
426  }
427 
428  const GLYPH& glyph = m_glyphs->at( dd );
429  const BOX2D& bbox = m_glyphBoundingBoxes->at( dd );
430 
431  if( in_overbar )
432  {
433  double overbar_start_x = xOffset;
434  double overbar_start_y = - computeOverbarVerticalPosition();
435  double overbar_end_x = xOffset + glyphSize.x * bbox.GetEnd().x;
436  double overbar_end_y = overbar_start_y;
437 
438  if( !last_had_overbar )
439  {
440  if( m_gal->IsFontItalic() )
441  overbar_start_x += overbar_italic_comp;
442 
443  last_had_overbar = true;
444  }
445 
446  VECTOR2D startOverbar( overbar_start_x, overbar_start_y );
447  VECTOR2D endOverbar( overbar_end_x, overbar_end_y );
448 
449  m_gal->DrawLine( startOverbar, endOverbar );
450  }
451  else
452  {
453  last_had_overbar = false;
454  }
455 
456  for( const std::vector<VECTOR2D>& ptList : glyph )
457  {
458  std::deque<VECTOR2D> ptListScaled;
459 
460  for( const VECTOR2D& pt : ptList )
461  {
462  VECTOR2D scaledPt( pt.x * glyphSize.x + xOffset, pt.y * glyphSize.y + yOffset );
463 
464  if( m_gal->IsFontItalic() )
465  {
466  // FIXME should be done other way - referring to the lowest Y value of point
467  // because now italic fonts are translated a bit
468  if( m_gal->IsTextMirrored() )
469  scaledPt.x += scaledPt.y * STROKE_FONT::ITALIC_TILT;
470  else
471  scaledPt.x -= scaledPt.y * STROKE_FONT::ITALIC_TILT;
472  }
473 
474  ptListScaled.push_back( scaledPt );
475  }
476 
477  m_gal->DrawPolyline( ptListScaled );
478  }
479 
480  xOffset += glyphSize.x * bbox.GetEnd().x;
481  }
482 
483  m_gal->Restore();
484 }
485 
486 
487 double STROKE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight, double aGlyphThickness ) const
488 {
489  // Static method.
490  // Compute the Y position of the overbar. This is the distance between
491  // the text base line and the overbar axis.
492  return aGlyphHeight * OVERBAR_POSITION_FACTOR + aGlyphThickness;
493 }
494 
495 
497 {
498  // Compute the Y position of the overbar. This is the distance between
499  // the text base line and the overbar axis.
501 }
502 
503 
504 VECTOR2D STROKE_FONT::computeTextLineSize( const UTF8& aText, int aMarkupFlags ) const
505 {
507  aMarkupFlags );
508 }
509 
510 
512  double aGlyphThickness, int markupFlags ) const
513 {
514  VECTOR2D string_bbox;
515  int line_count = 1;
516  double maxX = 0.0, curX = 0.0;
517 
518  double curScale = 1.0;
519  bool in_overbar = false;
520 
521  for( UTF8::uni_iter it = aText.ubegin(), end = aText.uend(); it < end; ++it )
522  {
523  if( *it == '\n' )
524  {
525  curX = 0.0;
526  maxX = std::max( maxX, curX );
527  ++line_count;
528  continue;
529  }
530 
531  // Handle tabs as locked to the nearest 4th column (counting in spaces)
532  // The choice of spaces is somewhat arbitrary but sufficient for aligning text
533  if( *it == '\t' )
534  {
535  double spaces = m_glyphBoundingBoxes->at( 0 ).GetEnd().x;
536  double addlSpace = 3.0 * spaces - std::fmod( curX, 4.0 * spaces );
537 
538  // Add the remaining space (between 0 and 3 spaces)
539  curX += addlSpace;
540 
541  // Tab ends a super- or subscript
542  curScale = 1.0;
543  }
544  else if( *it == '~' )
545  {
546  if( ++it == end )
547  break;
548 
549  if( *it == '~' )
550  {
551  // double ~ is really a ~ so go ahead and process the second one
552 
553  // so what's a triple ~? It could be a real ~ followed by an overbar, or
554  // it could be an overbar followed by a real ~. The old algorithm did the
555  // later so we will too....
556  auto tempIt = it;
557 
558  if( ++tempIt < end && *tempIt == '~' )
559  {
560  // eat the first two, toggle overbar, and then process the third
561  ++it;
562  in_overbar = !in_overbar;
563  }
564  }
565  else
566  {
567  // single ~ toggles overbar
568  in_overbar = !in_overbar;
569  }
570  }
571  else if( *it == '^' && ( markupFlags & ENABLE_SUPERSCRIPT_MARKUP ) )
572  {
573  if( ++it == end )
574  break;
575 
576  if( *it == '^' )
577  {
578  // double ^ is really a ^ so go ahead and process the second one
579  }
580  else
581  {
582  // single ^ starts a superscript
583  curScale = 0.8;
584  }
585  }
586  else if( *it == '#' && ( markupFlags & ENABLE_SUBSCRIPT_MARKUP ) )
587  {
588  if( ++it == end )
589  break;
590 
591  if( *it == '#' )
592  {
593  // double # is really a # so go ahead and process the second one
594  }
595  else
596  {
597  // single _ starts a subscript
598  curScale = 0.8;
599  }
600  }
601  else if( *it == ' ' )
602  {
603  // space ends a super- or subscript
604  curScale = 1.0;
605  }
606 
607  // Index in the bounding boxes table
608  int dd = (signed) *it - ' ';
609 
610  if( dd >= (int) m_glyphBoundingBoxes->size() || dd < 0 )
611  {
612  int substitute = *it == '\t' ? ' ' : '?';
613  dd = substitute - ' ';
614  }
615 
616  const BOX2D& box = m_glyphBoundingBoxes->at( dd );
617  curX += box.GetEnd().x * curScale;
618  }
619 
620  string_bbox.x = std::max( maxX, curX ) * aGlyphSize.x;
621  string_bbox.x += aGlyphThickness;
622  string_bbox.y = line_count * GetInterline( aGlyphSize.y );
623 
624  // For italic correction, take in account italic tilt
625  if( m_gal->IsFontItalic() )
626  string_bbox.x += string_bbox.y * STROKE_FONT::ITALIC_TILT;
627 
628  return string_bbox;
629 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
static constexpr std::string::size_type npos
Definition: utf8.h:155
float GetLineWidth() const
Get the line width.
BOX2D computeBoundingBox(const GLYPH &aGlyph, double aGlyphWidth) const
Compute the bounding box of a given glyph.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
const Vec GetEnd() const
Definition: box2.h:193
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
bool IsTextMirrored() const
Returns true if text should displayed mirrored.
static const double BOLD_FACTOR
Factor that determines relative line width for bold text.
Definition: stroke_font.h:180
VECTOR2D computeTextLineSize(const UTF8 &aText, int aMarkupFlags) const
Compute the X and Y size of a given text.
BOX2< VECTOR2D > BOX2D
Definition: box2.h:521
std::vector< GLYPH > GLYPH_LIST
Definition: stroke_font.h:46
uni_iter uend() const
Function uend returns a uni_iter initialized to the end of "this" UTF8 byte sequence.
Definition: utf8.h:294
bool LoadNewStrokeFont(const char *const aNewStrokeFont[], int aNewStrokeFontSize)
Load the new stroke font.
Definition: stroke_font.cpp:53
static const double ITALIC_TILT
Tilt factor for italic style (the is is the scaling factor on dY relative coordinates to give a tilst...
Definition: stroke_font.h:187
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
Returns current text horizontal justification setting.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
const VECTOR2D & GetGlyphSize() const
bool IsFontBold() const
Returns true if current font has 'bold' attribute enabled.
uni_iter ubegin() const
Function ubegin returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
Definition: utf8.h:285
std::string::size_type find(char c) const
Definition: utf8.h:110
double ComputeOverbarVerticalPosition(double aGlyphHeight, double aGlyphThickness) const
Compute the vertical position of an overbar, sometimes used in texts.
GAL * m_gal
Pointer to the GAL.
Definition: stroke_font.h:123
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D ComputeStringBoundaryLimits(const UTF8 &aText, const VECTOR2D &aGlyphSize, double aGlyphThickness, int markupFlags) const
Compute the boundary limits of aText (the bounding box of all shapes).
static const double INTERLINE_PITCH_RATIO
Factor that determines the pitch between 2 lines.
Definition: stroke_font.h:190
std::vector< std::vector< VECTOR2D > > GLYPH
Definition: stroke_font.h:43
std::vector< BOX2D > * g_newStrokeFontGlyphBoundingBoxes
Bounding boxes of the glyphs.
Definition: stroke_font.cpp:44
bool IsFontItalic() const
Returns true if current font has 'italic' attribute enabled.
class uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded ...
Definition: utf8.h:207
GLYPH_LIST * g_newStrokeFontGlyphs
Glyph list.
Definition: stroke_font.cpp:43
double computeOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
STROKE_FONT(GAL *aGal)
Constructor.
Definition: stroke_font.cpp:47
static const double STROKE_FONT_SCALE
Scale factor for a glyph
Definition: stroke_font.h:183
virtual void Restore()
Restore the context.
#define max(a, b)
Definition: auxiliary.h:86
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
unsigned linesCount(const UTF8 &aText) const
Returns number of lines for a given text.
Definition: stroke_font.h:167
#define FONT_OFFSET
size_t i
Definition: json11.cpp:649
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle, int markupFlags)
Draw a string.
static const double OVERBAR_POSITION_FACTOR
Factor that determines relative vertical position of the overbar.
Definition: stroke_font.h:177
const std::vector< BOX2D > * m_glyphBoundingBoxes
Bounding boxes of the glyphs.
Definition: stroke_font.h:125
std::string substr(size_t pos=0, size_t len=npos) const
Definition: utf8.h:182
virtual void Save()
Save the context.
const GLYPH_LIST * m_glyphs
Glyph list.
Definition: stroke_font.h:124
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void drawSingleLineText(const UTF8 &aText, int markupFlags)
Draws a single line of text.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
#define min(a, b)
Definition: auxiliary.h:85
Class GAL is the abstract interface for drawing on a 2D-surface.
bool empty() const
Definition: utf8.h:108