@@ -314,27 +314,12 @@ void FT2Font::set_kerning_factor(int factor)
314
314
}
315
315
}
316
316
317
- void FT2Font::set_text (
318
- std::u32string_view text, double angle, FT_Int32 flags, std::vector<double > &xys)
317
+ void FT2Font::layout (std::u32string_view text, FT_Int32 flags,
318
+ std::set<FT_String*>& glyph_seen_fonts,
319
+ std::vector<raqm_glyph_t >& glyphs)
319
320
{
320
- FT_Matrix matrix; /* transformation matrix */
321
-
322
- angle = angle * (2 * M_PI / 360.0 );
323
-
324
- // this computes width and height in subpixels so we have to multiply by 64
325
- double cosangle = cos (angle) * 0x10000L ;
326
- double sinangle = sin (angle) * 0x10000L ;
327
-
328
- matrix.xx = (FT_Fixed)cosangle;
329
- matrix.xy = (FT_Fixed)-sinangle;
330
- matrix.yx = (FT_Fixed)sinangle;
331
- matrix.yy = (FT_Fixed)cosangle;
332
-
333
321
clear ();
334
322
335
- bbox.xMin = bbox.yMin = 32000 ;
336
- bbox.xMax = bbox.yMax = -32000 ;
337
-
338
323
auto rq = raqm_create ();
339
324
if (!rq) {
340
325
throw std::runtime_error (" failed to compute text layout" );
@@ -362,7 +347,6 @@ void FT2Font::set_text(
362
347
}
363
348
364
349
std::vector<std::pair<size_t , const FT_Face&>> face_substitutions;
365
- std::set<FT_String*> glyph_seen_fonts;
366
350
glyph_seen_fonts.insert (face->family_name );
367
351
368
352
// Attempt to use fallback fonts if necessary.
@@ -416,9 +400,34 @@ void FT2Font::set_text(
416
400
size_t num_glyphs = 0 ;
417
401
auto const & rq_glyphs = raqm_get_glyphs (rq, &num_glyphs);
418
402
419
- for (size_t i = 0 ; i < num_glyphs; i++) {
420
- auto const & rglyph = rq_glyphs[i];
403
+ glyphs.resize (num_glyphs);
404
+ memcpy (glyphs.data (), rq_glyphs, sizeof (raqm_glyph_t ) * num_glyphs);
405
+ }
406
+
407
+ void FT2Font::set_text (
408
+ std::u32string_view text, double angle, FT_Int32 flags, std::vector<double > &xys)
409
+ {
410
+ FT_Matrix matrix; /* transformation matrix */
411
+
412
+ angle = angle * (2 * M_PI / 360.0 );
413
+
414
+ // this computes width and height in subpixels so we have to multiply by 64
415
+ double cosangle = cos (angle) * 0x10000L ;
416
+ double sinangle = sin (angle) * 0x10000L ;
417
+
418
+ matrix.xx = (FT_Fixed)cosangle;
419
+ matrix.xy = (FT_Fixed)-sinangle;
420
+ matrix.yx = (FT_Fixed)sinangle;
421
+ matrix.yy = (FT_Fixed)cosangle;
422
+
423
+ bbox.xMin = bbox.yMin = 32000 ;
424
+ bbox.xMax = bbox.yMax = -32000 ;
425
+
426
+ std::set<FT_String*> glyph_seen_fonts;
427
+ std::vector<raqm_glyph_t > rq_glyphs;
428
+ layout (text, flags, glyph_seen_fonts, rq_glyphs);
421
429
430
+ for (auto const & rglyph : rq_glyphs) {
422
431
// Warn for missing glyphs.
423
432
if (rglyph.index == 0 ) {
424
433
ft_glyph_warn (text[rglyph.cluster ], glyph_seen_fonts);
0 commit comments