struct hb_coretext_shaper_font_data_t {
CTFontRef ct_font;
+ CGFloat x_mult, y_mult; /* From CT space to HB space. */
};
hb_coretext_shaper_font_data_t *
hb_face_t *face = font->face;
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
- data->ct_font = CTFontCreateWithGraphicsFont (face_data, font->y_scale, NULL, NULL);
+ /* Choose a CoreText font size and calculate multipliers to convert to HarfBuzz space. */
+ CGFloat font_size = 36.; /* Default... */
+ /* No idea if the following is even a good idea. */
+ if (font->y_ppem)
+ font_size = font->y_ppem;
+
+ if (font_size < 0)
+ font_size = -font_size;
+ data->x_mult = (CGFloat) font->x_scale / font_size;
+ data->y_mult = (CGFloat) font->y_scale / font_size;
+ data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL);
if (unlikely (!data->ct_font)) {
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
free (data);
double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL);
DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance);
hb_glyph_info_t *info = run_info;
+ CGFloat x_mult = font_data->x_mult, y_mult = font_data->y_mult;
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
{
for (unsigned int j = 0; j < num_glyphs; j++)
{
double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_advance) - positions[j].x;
- info->mask = advance;
- info->var1.u32 = positions[0].x; /* Yes, zero. */
- info->var2.u32 = positions[j].y;
+ info->mask = advance * x_mult;
+ info->var1.u32 = positions[0].x * x_mult; /* Yes, zero. */
+ info->var2.u32 = positions[j].y * y_mult;
info++;
}
}
for (unsigned int j = 0; j < num_glyphs; j++)
{
double advance = (j + 1 < num_glyphs ? positions[j + 1].y : positions[0].y + run_advance) - positions[j].y;
- info->mask = advance;
- info->var1.u32 = positions[j].x;
- info->var2.u32 = positions[0].y; /* Yes, zero. */
+ info->mask = advance * y_mult;
+ info->var1.u32 = positions[j].x * x_mult;
+ info->var2.u32 = positions[0].y * y_mult; /* Yes, zero. */
info++;
}
}