From 228a415470dec6c58b5543d00ca1fd7f72980be3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Dec 2022 18:19:06 -0700 Subject: [PATCH] [view-cairo] Minor subpixel-bits --- util/helper-cairo.hh | 4 ++-- util/view-cairo.hh | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index d82678738..556856e9b 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -585,13 +585,13 @@ struct helper_cairo_line_t { unsigned utf8_len_, hb_buffer_t *buffer, hb_bool_t utf8_clusters, - int scale_bits) : + unsigned subpixel_bits) : utf8 (utf8_ ? g_strndup (utf8_, utf8_len_) : nullptr), utf8_len (utf8_len_) { hb_cairo_glyphs_from_buffer (buffer, utf8_clusters, - 1 << -scale_bits, 1 << -scale_bits, + 1 << subpixel_bits, 1 << subpixel_bits, 0., 0., utf8, utf8_len, &glyphs, &num_glyphs, diff --git a/util/view-cairo.hh b/util/view-cairo.hh index a57e8209f..f30905d0d 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -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,7 +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 (text, text_len, buffer, utf8_clusters, scale_bits); + 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) @@ -87,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 @@ -106,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; }