mirror of
https://github.com/love2d/megasource.git
synced 2026-08-22 05:25:20 +02:00
update harfbuzz to 10.1.0
This commit is contained in:
@@ -48,7 +48,7 @@ struct view_cairo_t : view_options_t, output_options_t<>
|
||||
void init (hb_buffer_t *buffer, const font_options_t *font_opts)
|
||||
{
|
||||
lines = g_array_new (false, false, sizeof (helper_cairo_line_t));
|
||||
scale_bits = - (int) font_opts->subpixel_bits;
|
||||
subpixel_bits = font_opts->subpixel_bits;
|
||||
}
|
||||
void new_line () {}
|
||||
void consume_text (hb_buffer_t *buffer,
|
||||
@@ -63,8 +63,7 @@ struct view_cairo_t : view_options_t, output_options_t<>
|
||||
hb_bool_t utf8_clusters)
|
||||
{
|
||||
direction = hb_buffer_get_direction (buffer);
|
||||
helper_cairo_line_t l;
|
||||
helper_cairo_line_from_buffer (&l, buffer, text, text_len, scale_bits, utf8_clusters);
|
||||
helper_cairo_line_t l (text, text_len, buffer, utf8_clusters, subpixel_bits);
|
||||
g_array_append_val (lines, l);
|
||||
}
|
||||
void finish (hb_buffer_t *buffer, const font_options_t *font_opts)
|
||||
@@ -88,7 +87,7 @@ struct view_cairo_t : view_options_t, output_options_t<>
|
||||
|
||||
hb_direction_t direction = HB_DIRECTION_INVALID; // Remove this, make segment_properties accessible
|
||||
GArray *lines = nullptr;
|
||||
int scale_bits = 0;
|
||||
unsigned subpixel_bits = 0;
|
||||
};
|
||||
|
||||
inline void
|
||||
@@ -107,9 +106,9 @@ view_cairo_t::render (const font_options_t *font_opts)
|
||||
{
|
||||
hb_font_extents_t hb_extents;
|
||||
hb_font_get_extents_for_direction (font, direction, &hb_extents);
|
||||
font_extents.ascent = scalbn ((double) hb_extents.ascender, scale_bits);
|
||||
font_extents.descent = -scalbn ((double) hb_extents.descender, scale_bits);
|
||||
font_extents.line_gap = scalbn ((double) hb_extents.line_gap, scale_bits);
|
||||
font_extents.ascent = scalbn ((double) hb_extents.ascender, - (int) subpixel_bits);
|
||||
font_extents.descent = -scalbn ((double) hb_extents.descender, - (int) subpixel_bits);
|
||||
font_extents.line_gap = scalbn ((double) hb_extents.line_gap, - (int) subpixel_bits);
|
||||
have_font_extents = true;
|
||||
}
|
||||
|
||||
@@ -132,7 +131,8 @@ view_cairo_t::render (const font_options_t *font_opts)
|
||||
w = MAX (w, x_sign * x_advance);
|
||||
}
|
||||
|
||||
cairo_scaled_font_t *scaled_font = helper_cairo_create_scaled_font (font_opts);
|
||||
cairo_scaled_font_t *scaled_font = helper_cairo_create_scaled_font (font_opts,
|
||||
this);
|
||||
|
||||
/* See if font needs color. */
|
||||
cairo_content_t content = CAIRO_CONTENT_ALPHA;
|
||||
@@ -168,12 +168,12 @@ view_cairo_t::render (const font_options_t *font_opts)
|
||||
|
||||
cairo_translate (cr, -vert * leading, +horiz * leading);
|
||||
|
||||
if (annotate) {
|
||||
if (show_extents)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
/* Draw actual glyph origins */
|
||||
cairo_set_source_rgba (cr, 1., 0., 0., .5);
|
||||
cairo_set_line_width (cr, 5);
|
||||
cairo_set_line_width (cr, 10);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
||||
for (unsigned i = 0; i < l.num_glyphs; i++) {
|
||||
cairo_move_to (cr, l.glyphs[i].x, l.glyphs[i].y);
|
||||
@@ -181,20 +181,37 @@ view_cairo_t::render (const font_options_t *font_opts)
|
||||
}
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_source_rgba (cr, 1., 0., 1., .5);
|
||||
cairo_set_line_width (cr, 3);
|
||||
for (unsigned i = 0; i < l.num_glyphs; i++)
|
||||
{
|
||||
hb_glyph_extents_t hb_extents;
|
||||
hb_font_get_glyph_extents (font, l.glyphs[i].index, &hb_extents);
|
||||
double x1 = scalbn ((double) hb_extents.x_bearing, - (int) subpixel_bits);
|
||||
double y1 = -scalbn ((double) hb_extents.y_bearing, - (int) subpixel_bits);
|
||||
double width = scalbn ((double) hb_extents.width, - (int) subpixel_bits);
|
||||
double height = -scalbn ((double) hb_extents.height, - (int) subpixel_bits);
|
||||
|
||||
cairo_rectangle (cr, l.glyphs[i].x + x1, l.glyphs[i].y + y1, width, height);
|
||||
}
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (0 && cairo_surface_get_type (cairo_get_target (cr)) == CAIRO_SURFACE_TYPE_IMAGE) {
|
||||
/* cairo_show_glyphs() doesn't support subpixel positioning */
|
||||
cairo_glyph_path (cr, l.glyphs, l.num_glyphs);
|
||||
cairo_fill (cr);
|
||||
} else if (l.num_clusters)
|
||||
// https://github.com/harfbuzz/harfbuzz/issues/4378
|
||||
#if CAIRO_VERSION >= 11705
|
||||
if (l.num_clusters)
|
||||
cairo_show_text_glyphs (cr,
|
||||
l.utf8, l.utf8_len,
|
||||
l.glyphs, l.num_glyphs,
|
||||
l.clusters, l.num_clusters,
|
||||
l.cluster_flags);
|
||||
else
|
||||
#endif
|
||||
cairo_show_glyphs (cr, l.glyphs, l.num_glyphs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user