mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-27 16:49:42 +01:00
[BASE] Saturate synthesized baselines
Baseline fallback combines full-range BASE coordinates and font scales. Widen proportional formulas and saturate additions and subtractions so the synthesized coordinates remain defined at extreme scales. Tested with: meson test -C build --print-errorlogs Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
d09f9bbc21
commit
60a0632472
1 file changed
+12
-8
+12
-8
@@ -2421,9 +2421,11 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
&embox_bottom);
|
||||
|
||||
if (baseline_tag == HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT)
|
||||
*coord = embox_top + (embox_bottom - embox_top) / 10;
|
||||
*coord = hb_saturate_add (embox_top,
|
||||
hb_clamp_to<hb_position_t> (((int64_t) embox_bottom - embox_top) / 10));
|
||||
else
|
||||
*coord = embox_bottom + (embox_top - embox_bottom) / 10;
|
||||
*coord = hb_saturate_add (embox_bottom,
|
||||
hb_clamp_to<hb_position_t> (((int64_t) embox_top - embox_bottom) / 10));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2434,7 +2436,8 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
script_tag,
|
||||
language_tag,
|
||||
coord))
|
||||
*coord += HB_DIRECTION_IS_HORIZONTAL (direction) ? font->y_scale : font->x_scale;
|
||||
*coord = hb_saturate_add (*coord,
|
||||
HB_DIRECTION_IS_HORIZONTAL (direction) ? font->y_scale : font->x_scale);
|
||||
else
|
||||
{
|
||||
hb_font_extents_t font_extents;
|
||||
@@ -2450,7 +2453,8 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
script_tag,
|
||||
language_tag,
|
||||
coord))
|
||||
*coord -= HB_DIRECTION_IS_HORIZONTAL (direction) ? font->y_scale : font->x_scale;
|
||||
*coord = hb_saturate_sub (*coord,
|
||||
HB_DIRECTION_IS_HORIZONTAL (direction) ? font->y_scale : font->x_scale);
|
||||
else
|
||||
{
|
||||
hb_font_extents_t font_extents;
|
||||
@@ -2510,10 +2514,10 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
hb_font_get_glyph_extents (font, glyph, &extents))
|
||||
*coord = extents.y_bearing;
|
||||
else
|
||||
*coord = font->y_scale * 6 / 10; // FIXME makes assumptions about origin
|
||||
*coord = hb_clamp_to<hb_position_t> ((int64_t) font->y_scale * 6 / 10); // FIXME makes assumptions about origin
|
||||
}
|
||||
else
|
||||
*coord = font->x_scale * 6 / 10; // FIXME makes assumptions about origin
|
||||
*coord = hb_clamp_to<hb_position_t> ((int64_t) font->x_scale * 6 / 10); // FIXME makes assumptions about origin
|
||||
break;
|
||||
|
||||
case HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_CENTRAL:
|
||||
@@ -2531,7 +2535,7 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
script_tag,
|
||||
language_tag,
|
||||
&bottom);
|
||||
*coord = (top + bottom) / 2;
|
||||
*coord = hb_clamp_to<hb_position_t> (((int64_t) top + bottom) / 2);
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -2551,7 +2555,7 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font,
|
||||
script_tag,
|
||||
language_tag,
|
||||
&bottom);
|
||||
*coord = (top + bottom) / 2;
|
||||
*coord = hb_clamp_to<hb_position_t> (((int64_t) top + bottom) / 2);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user