mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-19 21:40:22 +00:00
Merge branch 'serialize-hint-metrics' into 'main'
gsk: Serialize hint metrics too See merge request GNOME/gtk!7215
This commit is contained in:
commit
d6892c85dc
@ -330,6 +330,7 @@ stroke bounds of the path.
|
|||||||
| offset | `<point>` | 0 0 | non-default |
|
| offset | `<point>` | 0 0 | non-default |
|
||||||
| hint-style | `<hint style>` | slight | non-default |
|
| hint-style | `<hint style>` | slight | non-default |
|
||||||
| antialias | `<antialias>` | gray | non-default |
|
| antialias | `<antialias>` | gray | non-default |
|
||||||
|
| hint-metrics | `<hint metrics>` | off | non-default |
|
||||||
|
|
||||||
Creates a node like `gsk_text_node_new()` with the given properties.
|
Creates a node like `gsk_text_node_new()` with the given properties.
|
||||||
|
|
||||||
@ -346,6 +347,7 @@ font, an error node will be returned.
|
|||||||
|
|
||||||
Possible values for hint-style are none, slight or full.
|
Possible values for hint-style are none, slight or full.
|
||||||
Possible value for antialias are none or gray.
|
Possible value for antialias are none or gray.
|
||||||
|
Possible value for hint-metrics are on or off.
|
||||||
|
|
||||||
### texture
|
### texture
|
||||||
|
|
||||||
|
@ -2312,6 +2312,25 @@ parse_antialias (GtkCssParser *parser,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_hint_metrics (GtkCssParser *parser,
|
||||||
|
Context *context,
|
||||||
|
gpointer out)
|
||||||
|
{
|
||||||
|
if (!parse_enum (parser, CAIRO_GOBJECT_TYPE_HINT_METRICS, out))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_OFF &&
|
||||||
|
*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_ON)
|
||||||
|
{
|
||||||
|
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
|
||||||
|
g_type_name (CAIRO_GOBJECT_TYPE_HINT_METRICS));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GskRenderNode *
|
static GskRenderNode *
|
||||||
parse_text_node (GtkCssParser *parser,
|
parse_text_node (GtkCssParser *parser,
|
||||||
Context *context)
|
Context *context)
|
||||||
@ -2322,6 +2341,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
PangoGlyphString *glyphs = NULL;
|
PangoGlyphString *glyphs = NULL;
|
||||||
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
||||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
||||||
|
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
|
||||||
PangoFont *hinted;
|
PangoFont *hinted;
|
||||||
const Declaration declarations[] = {
|
const Declaration declarations[] = {
|
||||||
{ "font", parse_font, clear_font, &font },
|
{ "font", parse_font, clear_font, &font },
|
||||||
@ -2330,6 +2350,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
||||||
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
||||||
{ "antialias", parse_antialias, NULL, &antialias },
|
{ "antialias", parse_antialias, NULL, &antialias },
|
||||||
|
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
|
||||||
};
|
};
|
||||||
GskRenderNode *result;
|
GskRenderNode *result;
|
||||||
|
|
||||||
@ -2341,7 +2362,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
g_assert (font);
|
g_assert (font);
|
||||||
}
|
}
|
||||||
|
|
||||||
hinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF, hint_style, antialias);
|
hinted = gsk_reload_font (font, 1.0, hint_metrics, hint_style, antialias);
|
||||||
g_object_unref (font);
|
g_object_unref (font);
|
||||||
font = hinted;
|
font = hinted;
|
||||||
|
|
||||||
@ -3623,11 +3644,13 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
|||||||
cairo_font_options_t *options;
|
cairo_font_options_t *options;
|
||||||
cairo_hint_style_t hint_style;
|
cairo_hint_style_t hint_style;
|
||||||
cairo_antialias_t antialias;
|
cairo_antialias_t antialias;
|
||||||
|
cairo_hint_metrics_t hint_metrics;
|
||||||
|
|
||||||
options = cairo_font_options_create ();
|
options = cairo_font_options_create ();
|
||||||
cairo_scaled_font_get_font_options (sf, options);
|
cairo_scaled_font_get_font_options (sf, options);
|
||||||
hint_style = cairo_font_options_get_hint_style (options);
|
hint_style = cairo_font_options_get_hint_style (options);
|
||||||
antialias = cairo_font_options_get_antialias (options);
|
antialias = cairo_font_options_get_antialias (options);
|
||||||
|
hint_metrics = cairo_font_options_get_hint_metrics (options);
|
||||||
cairo_font_options_destroy (options);
|
cairo_font_options_destroy (options);
|
||||||
|
|
||||||
/* medium and full are identical in the absence of subpixel modes */
|
/* medium and full are identical in the absence of subpixel modes */
|
||||||
@ -3643,6 +3666,12 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
|||||||
*/
|
*/
|
||||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||||
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
||||||
|
|
||||||
|
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,
|
||||||
|
* and we don't accept any other values.
|
||||||
|
*/
|
||||||
|
if (hint_metrics == CAIRO_HINT_METRICS_ON)
|
||||||
|
append_enum_param (p, "hint-metrics", CAIRO_GOBJECT_TYPE_HINT_METRICS, CAIRO_HINT_METRICS_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user