@@ -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
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" );
@@ -375,7 +359,6 @@ void FT2Font::set_text(
375
359
}
376
360
377
361
std::vector<std::pair<size_t , const FT_Face&>> face_substitutions;
378
- std::set<FT_String*> glyph_seen_fonts;
379
362
glyph_seen_fonts.insert (face->family_name );
380
363
381
364
// Attempt to use fallback fonts if necessary.
@@ -452,9 +435,34 @@ void FT2Font::set_text(
452
435
size_t num_glyphs = 0 ;
453
436
auto const & rq_glyphs = raqm_get_glyphs (rq, &num_glyphs);
454
437
455
- for (size_t i = 0 ; i < num_glyphs; i++) {
456
- auto const & rglyph = rq_glyphs[i];
438
+ return std::vector<raqm_glyph_t >(rq_glyphs, rq_glyphs + num_glyphs);
439
+ }
440
+
441
+ void FT2Font::set_text (
442
+ std::u32string_view text, double angle, FT_Int32 flags,
443
+ LanguageType languages,
444
+ std::vector<double > &xys)
445
+ {
446
+ FT_Matrix matrix; /* transformation matrix */
447
+
448
+ angle = angle * (2 * M_PI / 360.0 );
449
+
450
+ // this computes width and height in subpixels so we have to multiply by 64
451
+ double cosangle = cos (angle) * 0x10000L ;
452
+ double sinangle = sin (angle) * 0x10000L ;
453
+
454
+ matrix.xx = (FT_Fixed)cosangle;
455
+ matrix.xy = (FT_Fixed)-sinangle;
456
+ matrix.yx = (FT_Fixed)sinangle;
457
+ matrix.yy = (FT_Fixed)cosangle;
458
+
459
+ std::set<FT_String*> glyph_seen_fonts;
460
+ auto rq_glyphs = layout (text, flags, languages, glyph_seen_fonts);
461
+
462
+ bbox.xMin = bbox.yMin = 32000 ;
463
+ bbox.xMax = bbox.yMax = -32000 ;
457
464
465
+ for (auto const & rglyph : rq_glyphs) {
458
466
// Warn for missing glyphs.
459
467
if (rglyph.index == 0 ) {
460
468
ft_glyph_warn (text[rglyph.cluster ], glyph_seen_fonts);
0 commit comments