From c2efaa5ced8d0625b020a2144f87fcb58eee04d1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 3 Mar 2026 17:19:15 -0300 Subject: [PATCH] Unify view extents defaults --- util/hb-vector.cc | 2 +- util/raster-output.hh | 4 ++-- util/vector-output.hh | 7 +++---- util/view-cairo.hh | 4 ++-- util/view-options.hh | 2 ++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/util/hb-vector.cc b/util/hb-vector.cc index 059e89c8d..a042ebc92 100644 --- a/util/hb-vector.cc +++ b/util/hb-vector.cc @@ -29,7 +29,7 @@ #include "shape-consumer.hh" #include "text-options.hh" -const unsigned DEFAULT_FONT_SIZE = 256; +const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM; const unsigned SUBPIXEL_BITS = 6; int diff --git a/util/raster-output.hh b/util/raster-output.hh index 2fc8e942f..b7d0ab6b9 100644 --- a/util/raster-output.hh +++ b/util/raster-output.hh @@ -455,8 +455,8 @@ struct raster_output_t : output_options_t, view_options_t bool compute_extents (float sx, float sy, float step, bool vertical, hb_raster_extents_t *ext) { /* Compute bounding box in pixel space from logical and/or ink extents. */ - const bool include_logical = logical || !ink; - const bool include_ink = ink || !logical; + const bool include_logical = include_logical_extents (); + const bool include_ink = include_ink_extents (); float pmin_x = 1e30f, pmin_y = 1e30f; float pmax_x = -1e30f, pmax_y = -1e30f; diff --git a/util/vector-output.hh b/util/vector-output.hh index 3881abb69..b6a260d9d 100644 --- a/util/vector-output.hh +++ b/util/vector-output.hh @@ -197,8 +197,7 @@ struct vector_output_t : output_options_t<>, view_options_t bool had_draw = false; bool had_paint = false; - hb_vector_extents_mode_t extents_mode = ink ? HB_VECTOR_EXTENTS_MODE_EXPAND - : HB_VECTOR_EXTENTS_MODE_NONE; + hb_vector_extents_mode_t extents_mode = HB_VECTOR_EXTENTS_MODE_NONE; const bool use_foreground_palette = foreground_use_palette && foreground_palette && foreground_palette->len; unsigned palette_glyph_index = 0; @@ -320,8 +319,8 @@ struct vector_output_t : output_options_t<>, view_options_t bool valid = false; float x1 = 0, y1 = 0, x2 = 0, y2 = 0; - bool include_logical = logical || (!logical && !ink); - bool include_ink = ink; + bool include_logical = include_logical_extents (); + bool include_ink = include_ink_extents (); auto include_point = [&] (float x, float y) { diff --git a/util/view-cairo.hh b/util/view-cairo.hh index ee106684b..fd407165a 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -239,8 +239,8 @@ view_cairo_t::render (const font_options_t *font_opts) double surface_w = logical_w, surface_h = logical_h; double surface_shift_x = 0, surface_shift_y = 0; - bool include_logical = logical || !ink; - bool include_ink = ink || !logical; + bool include_logical = include_logical_extents (); + bool include_ink = include_ink_extents (); if (include_ink) { cairo_surface_t *ink_surface = cairo_recording_surface_create (content, nullptr); diff --git a/util/view-options.hh b/util/view-options.hh index 728566d0f..06dfce7e2 100644 --- a/util/view-options.hh +++ b/util/view-options.hh @@ -50,6 +50,8 @@ struct view_options_t } void add_options (option_parser_t *parser); + bool include_logical_extents () const { return logical || !ink; } + bool include_ink_extents () const { return ink || !logical; } void post_parse (GError **error G_GNUC_UNUSED) { stroke_enabled = false;