@@ -318,29 +318,13 @@ void FT2Font::set_kerning_factor(int factor)
318
318
}
319
319
}
320
320
321
- void FT2Font::set_text (
322
- std::u32string_view text, double angle, FT_Int32 flags,
321
+ std::vector< raqm_glyph_t > FT2Font::layout (
322
+ std::u32string_view text, FT_Int32 flags,
323
323
std::optional<std::vector<std::string>> features, LanguageType languages,
324
- std::vector< double > &xys )
324
+ std::set<FT_String*>& glyph_seen_fonts )
325
325
{
326
- FT_Matrix matrix; /* transformation matrix */
327
-
328
- angle = angle * (2 * M_PI / 360.0 );
329
-
330
- // this computes width and height in subpixels so we have to multiply by 64
331
- double cosangle = cos (angle) * 0x10000L ;
332
- double sinangle = sin (angle) * 0x10000L ;
333
-
334
- matrix.xx = (FT_Fixed)cosangle;
335
- matrix.xy = (FT_Fixed)-sinangle;
336
- matrix.yx = (FT_Fixed)sinangle;
337
- matrix.yy = (FT_Fixed)cosangle;
338
-
339
326
clear ();
340
327
341
- bbox.xMin = bbox.yMin = 32000 ;
342
- bbox.xMax = bbox.yMax = -32000 ;
343
-
344
328
auto rq = raqm_create ();
345
329
if (!rq) {
346
330
throw std::runtime_error (" failed to compute text layout" );
@@ -387,7 +371,6 @@ void FT2Font::set_text(
387
371
}
388
372
389
373
std::vector<std::pair<size_t , const FT_Face&>> face_substitutions;
390
- std::set<FT_String*> glyph_seen_fonts;
391
374
glyph_seen_fonts.insert (face->family_name );
392
375
393
376
// Attempt to use fallback fonts if necessary.
@@ -474,9 +457,34 @@ void FT2Font::set_text(
474
457
size_t num_glyphs = 0 ;
475
458
auto const & rq_glyphs = raqm_get_glyphs (rq, &num_glyphs);
476
459
477
- for (size_t i = 0 ; i < num_glyphs; i++) {
478
- auto const & rglyph = rq_glyphs[i];
460
+ return std::vector<raqm_glyph_t >(rq_glyphs, rq_glyphs + num_glyphs);
461
+ }
462
+
463
+ void FT2Font::set_text (
464
+ std::u32string_view text, double angle, FT_Int32 flags,
465
+ std::optional<std::vector<std::string>> features, LanguageType languages,
466
+ std::vector<double > &xys)
467
+ {
468
+ FT_Matrix matrix; /* transformation matrix */
469
+
470
+ angle = angle * (2 * M_PI / 360.0 );
471
+
472
+ // this computes width and height in subpixels so we have to multiply by 64
473
+ double cosangle = cos (angle) * 0x10000L ;
474
+ double sinangle = sin (angle) * 0x10000L ;
475
+
476
+ matrix.xx = (FT_Fixed)cosangle;
477
+ matrix.xy = (FT_Fixed)-sinangle;
478
+ matrix.yx = (FT_Fixed)sinangle;
479
+ matrix.yy = (FT_Fixed)cosangle;
480
+
481
+ bbox.xMin = bbox.yMin = 32000 ;
482
+ bbox.xMax = bbox.yMax = -32000 ;
483
+
484
+ std::set<FT_String*> glyph_seen_fonts;
485
+ auto rq_glyphs = layout (text, flags, features, languages, glyph_seen_fonts);
479
486
487
+ for (auto const & rglyph : rq_glyphs) {
480
488
// Warn for missing glyphs.
481
489
if (rglyph.index == 0 ) {
482
490
ft_glyph_warn (text[rglyph.cluster ], glyph_seen_fonts);
0 commit comments