mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Merge branch 'ebassi/hint-font-lodpi' into 'main'
Enable subpixel positioning for text only on high scaling factors See merge request GNOME/gtk!6190
This commit is contained in:
commit
f663617724
32
.gitlab-ci/run-single-test.sh
Executable file
32
.gitlab-ci/run-single-test.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/sh
|
||||
#
|
||||
builddir=$1
|
||||
suite=$2
|
||||
unit=$3
|
||||
|
||||
echo "** builddir: ${builddir}"
|
||||
echo "** suite: ${suite}"
|
||||
echo "** unit: ${unit}"
|
||||
|
||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||
|
||||
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
||||
compositor=$!
|
||||
|
||||
export WAYLAND_DISPLAY=wayland-5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--print-errorlogs \
|
||||
--setup=wayland \
|
||||
--suite=${suite} \
|
||||
--no-suite=failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=wayland_failing \
|
||||
--no-suite=gsk-compare-broadway \
|
||||
--verbose \
|
||||
"${unit}"
|
||||
|
||||
exit_code=$?
|
||||
kill ${compositor}
|
||||
|
||||
exit ${exit_code}
|
@ -245,11 +245,11 @@ update_pango_alignment (GtkInscription *self)
|
||||
ltr = _gtk_widget_get_direction (GTK_WIDGET (self)) != GTK_TEXT_DIR_RTL;
|
||||
|
||||
if (self->xalign < 0.33)
|
||||
align = ltr ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
|
||||
align = ltr ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
|
||||
else if (self->xalign < 0.67)
|
||||
align = PANGO_ALIGN_CENTER;
|
||||
align = PANGO_ALIGN_CENTER;
|
||||
else
|
||||
align = ltr ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
|
||||
align = ltr ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
|
||||
|
||||
pango_layout_set_alignment (self->layout, align);
|
||||
}
|
||||
|
@ -1313,8 +1313,8 @@ gtk_label_measure (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
get_layout_location (GtkLabel *self,
|
||||
int *xp,
|
||||
int *yp)
|
||||
float *xp,
|
||||
float *yp)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (self);
|
||||
const int widget_width = gtk_widget_get_width (widget);
|
||||
@ -1322,7 +1322,7 @@ get_layout_location (GtkLabel *self,
|
||||
PangoRectangle logical;
|
||||
float xalign;
|
||||
int baseline;
|
||||
int x, y;
|
||||
float x, y;
|
||||
|
||||
g_assert (xp);
|
||||
g_assert (yp);
|
||||
@ -1334,6 +1334,8 @@ get_layout_location (GtkLabel *self,
|
||||
|
||||
pango_layout_get_pixel_extents (self->layout, NULL, &logical);
|
||||
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
|
||||
if (x < 0)
|
||||
x = 0.f;
|
||||
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
if (baseline != -1)
|
||||
@ -1382,7 +1384,7 @@ gtk_label_snapshot (GtkWidget *widget,
|
||||
GtkLabel *self = GTK_LABEL (widget);
|
||||
GtkLabelSelectionInfo *info;
|
||||
GtkCssStyle *style;
|
||||
int lx, ly;
|
||||
float lx, ly;
|
||||
int width, height;
|
||||
GtkCssBoxes boxes;
|
||||
|
||||
@ -1705,7 +1707,7 @@ get_layout_index (GtkLabel *self,
|
||||
const char *cluster;
|
||||
const char *cluster_end;
|
||||
gboolean inside;
|
||||
int lx, ly;
|
||||
float lx, ly;
|
||||
|
||||
*index = 0;
|
||||
|
||||
@ -5247,17 +5249,17 @@ gtk_label_get_layout_offsets (GtkLabel *self,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
int local_x, local_y;
|
||||
float local_x, local_y;
|
||||
g_return_if_fail (GTK_IS_LABEL (self));
|
||||
|
||||
gtk_label_ensure_layout (self);
|
||||
get_layout_location (self, &local_x, &local_y);
|
||||
|
||||
if (x)
|
||||
*x = local_x;
|
||||
*x = (int) local_x;
|
||||
|
||||
if (y)
|
||||
*y = local_y;
|
||||
*y = (int) local_y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6463,6 +6463,8 @@ gtk_widget_update_pango_context (GtkWidget *widget,
|
||||
GtkSettings *settings;
|
||||
cairo_font_options_t *font_options;
|
||||
guint old_serial;
|
||||
gboolean hint_font_metrics = FALSE;
|
||||
int scale;
|
||||
|
||||
old_serial = pango_context_get_serial (context);
|
||||
|
||||
@ -6470,14 +6472,18 @@ gtk_widget_update_pango_context (GtkWidget *widget,
|
||||
pango_context_set_font_description (context, font_desc);
|
||||
pango_font_description_free (font_desc);
|
||||
|
||||
scale = gtk_widget_get_scale_factor (widget);
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
|
||||
if (settings &&
|
||||
if (settings != NULL &&
|
||||
cairo_version () >= CAIRO_VERSION_ENCODE (1, 17, 4))
|
||||
{
|
||||
gboolean hint_font_metrics;
|
||||
|
||||
g_object_get (settings, "gtk-hint-font-metrics", &hint_font_metrics, NULL);
|
||||
|
||||
/* Override the user setting on non-HiDPI */
|
||||
if (scale == 1)
|
||||
hint_font_metrics = TRUE;
|
||||
|
||||
pango_context_set_round_glyph_positions (context, hint_font_metrics);
|
||||
}
|
||||
|
||||
@ -6495,13 +6501,25 @@ gtk_widget_update_pango_context (GtkWidget *widget,
|
||||
|
||||
options = cairo_font_options_copy (gtk_settings_get_font_options (settings));
|
||||
cairo_font_options_merge (options, font_options);
|
||||
|
||||
cairo_font_options_set_hint_metrics (options,
|
||||
hint_font_metrics == 1 ? CAIRO_HINT_METRICS_ON
|
||||
: CAIRO_HINT_METRICS_OFF);
|
||||
|
||||
pango_cairo_context_set_font_options (context, options);
|
||||
cairo_font_options_destroy (options);
|
||||
}
|
||||
else if (settings)
|
||||
{
|
||||
pango_cairo_context_set_font_options (context,
|
||||
gtk_settings_get_font_options (settings));
|
||||
cairo_font_options_t *options;
|
||||
|
||||
options = cairo_font_options_copy (gtk_settings_get_font_options (settings));
|
||||
cairo_font_options_set_hint_metrics (options,
|
||||
hint_font_metrics == 1 ? CAIRO_HINT_METRICS_ON
|
||||
: CAIRO_HINT_METRICS_OFF);
|
||||
|
||||
pango_cairo_context_set_font_options (context, options);
|
||||
cairo_font_options_destroy (options);
|
||||
}
|
||||
|
||||
pango_context_set_font_map (context, gtk_widget_get_effective_font_map (widget));
|
||||
@ -6801,6 +6819,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_SCALE_FACTOR]);
|
||||
|
||||
gtk_widget_forall (widget, (GtkCallback)_gtk_widget_scale_changed, NULL);
|
||||
|
@ -8,6 +8,7 @@
|
||||
<object class="GtkLabel">
|
||||
<property name="use-markup">1</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Text sizes: <span size="xx-small">tiny </span><span size="x-small">very small </span><span size="small">small </span><span size="medium">normal </span><span size="large">large </span><span size="x-large">very large </span><span size="xx-large">huge</span>
|
||||
Text styles: <span style="normal">Normal</span> <span style="italic">Italic</span> <span style="oblique">Olique</span>
|
||||
Text weights: <span weight="thin">thin</span> <span weight="light">light</span> <span weight="normal">normal</span> <span weight="bold">bold</span> <span weight="ultraheavy">ultraheavy</span>
|
||||
|
Loading…
Reference in New Issue
Block a user