@@ -401,27 +401,12 @@ void FT2Font::set_kerning_factor(int factor)
401
401
}
402
402
}
403
403
404
- void FT2Font::set_text (
405
- std::u32string_view text, double angle, FT_Int32 flags, std::vector<double > &xys)
404
+ void FT2Font::layout (std::u32string_view text, FT_Int32 flags,
405
+ std::set<FT_String*>& glyph_seen_fonts,
406
+ std::vector<raqm_glyph_t >& glyphs)
406
407
{
407
- FT_Matrix matrix; /* transformation matrix */
408
-
409
- angle = angle * (2 * M_PI / 360.0 );
410
-
411
- // this computes width and height in subpixels so we have to multiply by 64
412
- double cosangle = cos (angle) * 0x10000L ;
413
- double sinangle = sin (angle) * 0x10000L ;
414
-
415
- matrix.xx = (FT_Fixed)cosangle;
416
- matrix.xy = (FT_Fixed)-sinangle;
417
- matrix.yx = (FT_Fixed)sinangle;
418
- matrix.yy = (FT_Fixed)cosangle;
419
-
420
408
clear ();
421
409
422
- bbox.xMin = bbox.yMin = 32000 ;
423
- bbox.xMax = bbox.yMax = -32000 ;
424
-
425
410
auto rq = raqm_create ();
426
411
if (!rq) {
427
412
throw std::runtime_error (" failed to compute text layout" );
@@ -449,7 +434,6 @@ void FT2Font::set_text(
449
434
}
450
435
451
436
std::vector<std::pair<size_t , const FT_Face&>> face_substitutions;
452
- std::set<FT_String*> glyph_seen_fonts;
453
437
glyph_seen_fonts.insert (face->family_name );
454
438
455
439
// Attempt to use fallback fonts if necessary.
@@ -503,9 +487,34 @@ void FT2Font::set_text(
503
487
size_t num_glyphs = 0 ;
504
488
auto const & rq_glyphs = raqm_get_glyphs (rq, &num_glyphs);
505
489
506
- for (size_t i = 0 ; i < num_glyphs; i++) {
507
- auto const & rglyph = rq_glyphs[i];
490
+ glyphs.resize (num_glyphs);
491
+ memcpy (glyphs.data (), rq_glyphs, sizeof (raqm_glyph_t ) * num_glyphs);
492
+ }
493
+
494
+ void FT2Font::set_text (
495
+ std::u32string_view text, double angle, FT_Int32 flags, std::vector<double > &xys)
496
+ {
497
+ FT_Matrix matrix; /* transformation matrix */
498
+
499
+ angle = angle * (2 * M_PI / 360.0 );
500
+
501
+ // this computes width and height in subpixels so we have to multiply by 64
502
+ double cosangle = cos (angle) * 0x10000L ;
503
+ double sinangle = sin (angle) * 0x10000L ;
504
+
505
+ matrix.xx = (FT_Fixed)cosangle;
506
+ matrix.xy = (FT_Fixed)-sinangle;
507
+ matrix.yx = (FT_Fixed)sinangle;
508
+ matrix.yy = (FT_Fixed)cosangle;
509
+
510
+ bbox.xMin = bbox.yMin = 32000 ;
511
+ bbox.xMax = bbox.yMax = -32000 ;
512
+
513
+ std::set<FT_String*> glyph_seen_fonts;
514
+ std::vector<raqm_glyph_t > rq_glyphs;
515
+ layout (text, flags, glyph_seen_fonts, rq_glyphs);
508
516
517
+ for (auto const & rglyph : rq_glyphs) {
509
518
// Warn for missing glyphs.
510
519
if (rglyph.index == 0 ) {
511
520
ft_glyph_warn (text[rglyph.cluster ], glyph_seen_fonts);
0 commit comments