forked from AuroraMiddleware/gtk
Merge branch 'text-fixes' into 'master'
textview: fix pango context invalidation See merge request GNOME/gtk!3922
This commit is contained in:
commit
a3ccff3773
@ -492,19 +492,6 @@ GskRenderNode * gsk_text_node_new (PangoFont
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset);
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
GskRenderNode * gsk_text_node_new_with_font_options (const cairo_font_options_t *options,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset);
|
||||
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
gboolean gsk_text_node_get_hint_metrics (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
gboolean gsk_text_node_get_antialias (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_6
|
||||
cairo_hint_style_t gsk_text_node_get_hint_style (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
PangoFont * gsk_text_node_get_font (const GskRenderNode *node) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -4336,10 +4336,7 @@ struct _GskTextNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
PangoFont *font;
|
||||
guint has_color_glyphs : 1;
|
||||
guint hint_metrics : 1;
|
||||
guint antialias : 1;
|
||||
guint hint_style : 3;
|
||||
gboolean has_color_glyphs;
|
||||
|
||||
GdkRGBA color;
|
||||
graphene_point_t offset;
|
||||
@ -4366,7 +4363,6 @@ gsk_text_node_draw (GskRenderNode *node,
|
||||
{
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
PangoGlyphString glyphs;
|
||||
cairo_font_options_t *options;
|
||||
|
||||
glyphs.num_glyphs = self->num_glyphs;
|
||||
glyphs.glyphs = self->glyphs;
|
||||
@ -4374,13 +4370,6 @@ gsk_text_node_draw (GskRenderNode *node,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
options = cairo_font_options_create ();
|
||||
cairo_font_options_set_hint_metrics (options, self->hint_metrics ? CAIRO_HINT_METRICS_ON : CAIRO_HINT_METRICS_OFF);
|
||||
cairo_font_options_set_antialias (options, self->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
|
||||
cairo_font_options_set_hint_style (options, self->hint_style);
|
||||
cairo_set_font_options (cr, options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &self->color);
|
||||
cairo_translate (cr, self->offset.x, self->offset.y);
|
||||
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
|
||||
@ -4435,12 +4424,25 @@ gsk_text_node_diff (GskRenderNode *node1,
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gsk_text_node_new_internal (const cairo_font_options_t *options,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset)
|
||||
/**
|
||||
* gsk_text_node_new:
|
||||
* @font: the `PangoFont` containing the glyphs
|
||||
* @glyphs: the `PangoGlyphString` to render
|
||||
* @color: the foreground color to render with
|
||||
* @offset: offset of the baseline
|
||||
*
|
||||
* Creates a render node that renders the given glyphs.
|
||||
*
|
||||
* Note that @color may not be used if the font contains
|
||||
* color glyphs.
|
||||
*
|
||||
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_text_node_new (PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset)
|
||||
{
|
||||
GskTextNode *self;
|
||||
GskRenderNode *node;
|
||||
@ -4462,16 +4464,6 @@ gsk_text_node_new_internal (const cairo_font_options_t *options,
|
||||
self->color = *color;
|
||||
self->offset = *offset;
|
||||
self->has_color_glyphs = FALSE;
|
||||
self->antialias = TRUE;
|
||||
self->hint_style = CAIRO_HINT_STYLE_NONE;
|
||||
self->hint_metrics = FALSE;
|
||||
|
||||
if (options)
|
||||
{
|
||||
self->antialias = cairo_font_options_get_antialias (options) != CAIRO_ANTIALIAS_NONE;
|
||||
self->hint_metrics = cairo_font_options_get_hint_metrics (options) == CAIRO_HINT_METRICS_ON;
|
||||
self->hint_style = cairo_font_options_get_hint_style (options);
|
||||
}
|
||||
|
||||
glyph_infos = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
|
||||
|
||||
@ -4502,117 +4494,6 @@ gsk_text_node_new_internal (const cairo_font_options_t *options,
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_new_with_font_options:
|
||||
* @options: `cairo_font_options_t` to render with
|
||||
* @font: the `PangoFont` containing the glyphs
|
||||
* @glyphs: the `PangoGlyphString` to render
|
||||
* @color: the foreground color to render with
|
||||
* @offset: offset of the baseline
|
||||
*
|
||||
* Creates a render node that renders the given glyphs.
|
||||
*
|
||||
* Note that @color may not be used if the font contains
|
||||
* color glyphs.
|
||||
*
|
||||
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_text_node_new_with_font_options (const cairo_font_options_t *options,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset)
|
||||
{
|
||||
return gsk_text_node_new_internal (options, font, glyphs, color, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_new:
|
||||
* @font: the `PangoFont` containing the glyphs
|
||||
* @glyphs: the `PangoGlyphString` to render
|
||||
* @color: the foreground color to render with
|
||||
* @offset: offset of the baseline
|
||||
*
|
||||
* Creates a render node that renders the given glyphs.
|
||||
*
|
||||
* Note that @color may not be used if the font contains
|
||||
* color glyphs.
|
||||
*
|
||||
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_text_node_new (PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset)
|
||||
{
|
||||
return gsk_text_node_new_internal (NULL, font, glyphs, color, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_get_hint_metrics:
|
||||
* @node: (type GskTextNode): a text `GskRenderNode`
|
||||
*
|
||||
* Retrieves whether metrics hinting is enabled for rendering.
|
||||
*
|
||||
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-metrics-t).
|
||||
*
|
||||
* Returns: whether metrics hinting is enabled
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
gboolean
|
||||
gsk_text_node_get_hint_metrics (const GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
|
||||
return self->hint_metrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_get_antialias:
|
||||
* @node: (type GskTextNode): a text `GskRenderNode`
|
||||
*
|
||||
* Retrieves whether antialiasing is enabled for rendering.
|
||||
*
|
||||
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t).
|
||||
* Note that GSK only supports grayscale antialiasing.
|
||||
*
|
||||
* Returns: whether antialiasing is enabled
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
gboolean
|
||||
gsk_text_node_get_antialias (const GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
|
||||
return self->antialias;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_get_hint_style:
|
||||
* @node: (type GskTextNode): a text `GskRenderNode`
|
||||
*
|
||||
* Retrieves what style of font hinting is used for rendering.
|
||||
*
|
||||
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-style-t).
|
||||
*
|
||||
* Returns: what style of hinting is used
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
cairo_hint_style_t
|
||||
gsk_text_node_get_hint_style (const GskRenderNode *node)
|
||||
{
|
||||
const GskTextNode *self = (const GskTextNode *) node;
|
||||
|
||||
return self->hint_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_get_color:
|
||||
* @node: (type GskTextNode): a text `GskRenderNode`
|
||||
|
@ -166,19 +166,11 @@ render_glyph (cairo_surface_t *surface,
|
||||
{
|
||||
cairo_t *cr;
|
||||
cairo_glyph_t glyph;
|
||||
cairo_font_options_t *options;
|
||||
|
||||
g_assert (surface != NULL);
|
||||
g_assert (scaled_font != NULL);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
options = cairo_font_options_create ();
|
||||
cairo_font_options_set_hint_metrics (options, key->hint_metrics ? CAIRO_HINT_METRICS_ON : CAIRO_HINT_METRICS_OFF);
|
||||
cairo_font_options_set_antialias (options, key->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
|
||||
cairo_font_options_set_hint_style (options, key->hint_style);
|
||||
cairo_set_font_options (cr, options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
cairo_set_scaled_font (cr, scaled_font);
|
||||
cairo_set_source_rgba (cr, 1, 1, 1, 1);
|
||||
|
||||
|
@ -35,10 +35,7 @@ typedef struct _GskNglGlyphKey
|
||||
PangoGlyph glyph;
|
||||
guint xshift : 2;
|
||||
guint yshift : 2;
|
||||
guint hint_metrics : 1;
|
||||
guint antialias : 1;
|
||||
guint hint_style : 3;
|
||||
guint scale : 23; /* times 1024 */
|
||||
guint scale : 28; /* times 1024 */
|
||||
} GskNglGlyphKey;
|
||||
|
||||
typedef struct _GskNglGlyphValue
|
||||
|
@ -2875,16 +2875,9 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
|
||||
|
||||
rgba_to_half (color, cc);
|
||||
|
||||
/* We have 23 bits in the key for the scale */
|
||||
g_assert (text_scale * 1024 < (1 << 24));
|
||||
|
||||
lookup.font = (PangoFont *)font;
|
||||
lookup.scale = (guint) (text_scale * 1024);
|
||||
|
||||
lookup.hint_metrics = gsk_text_node_get_hint_metrics (node);
|
||||
lookup.antialias = gsk_text_node_get_antialias (node);
|
||||
lookup.hint_style = gsk_text_node_get_hint_style (node);
|
||||
|
||||
yshift = compute_phase_and_pos (y, &ypos);
|
||||
|
||||
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
|
||||
|
@ -100,7 +100,6 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
|
||||
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
|
||||
|
||||
gtk_snapshot_append_text (crenderer->snapshot,
|
||||
crenderer->options,
|
||||
glyph_item->item->analysis.font,
|
||||
glyph_item->glyphs,
|
||||
&color,
|
||||
@ -468,18 +467,14 @@ gtk_snapshot_append_layout (GtkSnapshot *snapshot,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GskPangoRenderer *crenderer;
|
||||
PangoContext *context;
|
||||
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
||||
|
||||
crenderer = gsk_pango_renderer_acquire ();
|
||||
|
||||
context = pango_layout_get_context (layout);
|
||||
|
||||
crenderer->snapshot = snapshot;
|
||||
crenderer->fg_color = color;
|
||||
crenderer->options = pango_cairo_context_get_font_options (context);
|
||||
|
||||
pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
|
||||
|
||||
|
@ -63,8 +63,6 @@ struct _GskPangoRenderer
|
||||
/* Error underline color for this widget */
|
||||
GdkRGBA *error_color;
|
||||
|
||||
const cairo_font_options_t *options;
|
||||
|
||||
GskPangoRendererState state;
|
||||
|
||||
guint is_cached_renderer : 1;
|
||||
|
@ -2121,24 +2121,22 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_snapshot_append_text (GtkSnapshot *snapshot,
|
||||
const cairo_font_options_t *options,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
float x,
|
||||
float y)
|
||||
gtk_snapshot_append_text (GtkSnapshot *snapshot,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
float x,
|
||||
float y)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
float dx, dy;
|
||||
|
||||
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
|
||||
|
||||
node = gsk_text_node_new_with_font_options (options,
|
||||
font,
|
||||
glyphs,
|
||||
color,
|
||||
&GRAPHENE_POINT_INIT (x + dx, y + dy));
|
||||
node = gsk_text_node_new (font,
|
||||
glyphs,
|
||||
color,
|
||||
&GRAPHENE_POINT_INIT (x + dx, y + dy));
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
|
@ -24,13 +24,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
|
||||
const cairo_font_options_t *options,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
float x,
|
||||
float y);
|
||||
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
const GdkRGBA *color,
|
||||
float x,
|
||||
float y);
|
||||
|
||||
void gtk_snapshot_push_collect (GtkSnapshot *snapshot);
|
||||
GskRenderNode * gtk_snapshot_pop_collect (GtkSnapshot *snapshot);
|
||||
|
@ -397,6 +397,8 @@ static void gtk_text_view_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_text_view_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection previous_direction);
|
||||
static void gtk_text_view_system_setting_changed (GtkWidget *widget,
|
||||
GtkSystemSetting setting);
|
||||
static void gtk_text_view_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state);
|
||||
|
||||
@ -573,6 +575,7 @@ static void gtk_text_view_update_im_spot_location (GtkTextView *text_view);
|
||||
static void gtk_text_view_insert_emoji (GtkTextView *text_view);
|
||||
|
||||
static void update_node_ordering (GtkWidget *widget);
|
||||
static void gtk_text_view_update_pango_contexts (GtkTextView *text_view);
|
||||
|
||||
/* GtkTextHandle handlers */
|
||||
static void gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
||||
@ -819,6 +822,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
||||
widget_class->map = gtk_text_view_map;
|
||||
widget_class->css_changed = gtk_text_view_css_changed;
|
||||
widget_class->direction_changed = gtk_text_view_direction_changed;
|
||||
widget_class->system_setting_changed = gtk_text_view_system_setting_changed;
|
||||
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
|
||||
widget_class->measure = gtk_text_view_measure;
|
||||
widget_class->size_allocate = gtk_text_view_size_allocate;
|
||||
@ -4984,7 +4988,6 @@ gtk_text_view_css_changed (GtkWidget *widget,
|
||||
{
|
||||
GtkTextView *text_view;
|
||||
GtkTextViewPrivate *priv;
|
||||
PangoContext *ltr_context, *rtl_context;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (widget);
|
||||
priv = text_view->priv;
|
||||
@ -5001,16 +5004,13 @@ gtk_text_view_css_changed (GtkWidget *widget,
|
||||
gtk_text_view_set_attributes_from_style (text_view,
|
||||
priv->layout->default_style);
|
||||
gtk_text_layout_default_style_changed (priv->layout);
|
||||
}
|
||||
|
||||
ltr_context = gtk_widget_create_pango_context (widget);
|
||||
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
|
||||
rtl_context = gtk_widget_create_pango_context (widget);
|
||||
pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
|
||||
|
||||
gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
|
||||
|
||||
g_object_unref (ltr_context);
|
||||
g_object_unref (rtl_context);
|
||||
if ((change == NULL ||
|
||||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT)) &&
|
||||
priv->layout)
|
||||
{
|
||||
gtk_text_view_update_pango_contexts (text_view);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5028,6 +5028,42 @@ gtk_text_view_direction_changed (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_update_pango_contexts (GtkTextView *text_view)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (text_view);
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
gboolean update_ltr, update_rtl;
|
||||
|
||||
if (!priv->layout)
|
||||
return;
|
||||
|
||||
update_ltr = gtk_widget_update_pango_context (widget, priv->layout->ltr_context, GTK_TEXT_DIR_LTR);
|
||||
|
||||
update_rtl = gtk_widget_update_pango_context (widget, priv->layout->rtl_context, GTK_TEXT_DIR_RTL);
|
||||
|
||||
if (update_ltr || update_rtl)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
gtk_text_buffer_get_bounds (get_buffer (text_view), &start, &end);
|
||||
gtk_text_layout_invalidate (priv->layout, &start, &end);
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_system_setting_changed (GtkWidget *widget,
|
||||
GtkSystemSetting setting)
|
||||
{
|
||||
if (setting == GTK_SYSTEM_SETTING_DPI ||
|
||||
setting == GTK_SYSTEM_SETTING_FONT_NAME ||
|
||||
setting == GTK_SYSTEM_SETTING_FONT_CONFIG)
|
||||
{
|
||||
gtk_text_view_update_pango_contexts (GTK_TEXT_VIEW (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state)
|
||||
@ -7809,8 +7845,8 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
|
||||
if (priv->layout == NULL)
|
||||
{
|
||||
GtkTextAttributes *style;
|
||||
PangoContext *ltr_context, *rtl_context;
|
||||
const GList *iter;
|
||||
PangoContext *ltr_context, *rtl_context;
|
||||
|
||||
DV(g_print(G_STRLOC"\n"));
|
||||
|
||||
@ -7843,15 +7879,15 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
|
||||
priv->overwrite_mode && priv->editable);
|
||||
|
||||
ltr_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
|
||||
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
|
||||
rtl_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
|
||||
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
|
||||
pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
|
||||
|
||||
gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
|
||||
|
||||
g_object_unref (ltr_context);
|
||||
g_object_unref (rtl_context);
|
||||
|
||||
gtk_text_view_update_pango_contexts (text_view);
|
||||
|
||||
gtk_text_view_check_keymap_direction (text_view);
|
||||
|
||||
style = gtk_text_attributes_new ();
|
||||
|
@ -572,7 +572,7 @@ static void gtk_widget_pop_verify_invariants (GtkWidget
|
||||
#define gtk_widget_pop_verify_invariants(widget)
|
||||
#endif
|
||||
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
|
||||
static void gtk_widget_update_pango_context (GtkWidget *widget);
|
||||
static void gtk_widget_update_default_pango_context (GtkWidget *widget);
|
||||
static void gtk_widget_propagate_state (GtkWidget *widget,
|
||||
const GtkStateData *data);
|
||||
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
|
||||
@ -4957,7 +4957,7 @@ gtk_widget_real_css_changed (GtkWidget *widget,
|
||||
const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
|
||||
|
||||
if (has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
if (priv->root)
|
||||
{
|
||||
@ -4980,7 +4980,7 @@ gtk_widget_real_css_changed (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
if (priv->root)
|
||||
gtk_widget_queue_resize (widget);
|
||||
@ -4997,7 +4997,7 @@ gtk_widget_real_system_setting_changed (GtkWidget *widget,
|
||||
setting == GTK_SYSTEM_SETTING_FONT_NAME ||
|
||||
setting == GTK_SYSTEM_SETTING_FONT_CONFIG)
|
||||
{
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
if (gtk_widget_peek_pango_context (widget))
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
@ -6427,9 +6427,10 @@ gtk_widget_get_effective_font_map (GtkWidget *widget)
|
||||
return pango_cairo_font_map_get_default ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_pango_context (GtkWidget *widget,
|
||||
PangoContext *context)
|
||||
gboolean
|
||||
gtk_widget_update_pango_context (GtkWidget *widget,
|
||||
PangoContext *context,
|
||||
GtkTextDirection direction)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkCssStyle *style = gtk_css_node_get_style (priv->cssnode);
|
||||
@ -6455,9 +6456,10 @@ update_pango_context (GtkWidget *widget,
|
||||
pango_context_set_round_glyph_positions (context, hint_font_metrics);
|
||||
}
|
||||
|
||||
pango_context_set_base_dir (context,
|
||||
_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
|
||||
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
|
||||
if (direction != GTK_TEXT_DIR_NONE)
|
||||
pango_context_set_base_dir (context, direction == GTK_TEXT_DIR_LTR
|
||||
? PANGO_DIRECTION_LTR
|
||||
: PANGO_DIRECTION_RTL);
|
||||
|
||||
pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100));
|
||||
|
||||
@ -6483,14 +6485,14 @@ update_pango_context (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_update_pango_context (GtkWidget *widget)
|
||||
gtk_widget_update_default_pango_context (GtkWidget *widget)
|
||||
{
|
||||
PangoContext *context = gtk_widget_peek_pango_context (widget);
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
if (update_pango_context (widget, context))
|
||||
if (gtk_widget_update_pango_context (widget, context, _gtk_widget_get_direction (widget)))
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
|
||||
@ -6522,7 +6524,7 @@ gtk_widget_set_font_options (GtkWidget *widget,
|
||||
options ? cairo_font_options_copy (options) : NULL,
|
||||
(GDestroyNotify)cairo_font_options_destroy);
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6551,7 +6553,7 @@ gtk_widget_set_font_map_recurse (GtkWidget *widget, gpointer user_data)
|
||||
if (g_object_get_qdata (G_OBJECT (widget), quark_font_map))
|
||||
return;
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, user_data);
|
||||
}
|
||||
@ -6588,7 +6590,7 @@ gtk_widget_set_font_map (GtkWidget *widget,
|
||||
g_object_ref (font_map),
|
||||
g_object_unref);
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, NULL);
|
||||
}
|
||||
@ -6631,7 +6633,7 @@ gtk_widget_create_pango_context (GtkWidget *widget)
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
|
||||
update_pango_context (widget, context);
|
||||
gtk_widget_update_pango_context (widget, context, _gtk_widget_get_direction (widget));
|
||||
pango_context_set_language (context, gtk_get_default_language ());
|
||||
|
||||
return context;
|
||||
@ -7216,7 +7218,7 @@ gtk_widget_emit_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection direction;
|
||||
GtkStateFlags state;
|
||||
|
||||
gtk_widget_update_pango_context (widget);
|
||||
gtk_widget_update_default_pango_context (widget);
|
||||
|
||||
direction = _gtk_widget_get_direction (widget);
|
||||
|
||||
|
@ -370,6 +370,10 @@ void gtk_widget_update_orientation (GtkWidget *widget,
|
||||
void gtk_widget_realize_at_context (GtkWidget *widget);
|
||||
void gtk_widget_unrealize_at_context (GtkWidget *widget);
|
||||
|
||||
gboolean gtk_widget_update_pango_context (GtkWidget *widget,
|
||||
PangoContext *context,
|
||||
GtkTextDirection direction);
|
||||
|
||||
/* inline getters */
|
||||
|
||||
static inline GtkWidget *
|
||||
|
Loading…
Reference in New Issue
Block a user