mirror of
https://github.com/swaywm/sway.git
synced 2026-03-22 05:34:04 -04:00
common/pango: use pangocairo directly instead of cairo_create(NULL)
We never need a cairo context for anything here. Use pango_cairo_font_map_get_default() and pango_font_map_create_context() directly instead of bootstrapping via a nil cairo context. Same as last commit, but just a cosmetic fix in this case since we don't actually use the cairo context for anything
This commit is contained in:
parent
e4870d84a2
commit
dea166a27c
1 changed files with 2 additions and 3 deletions
|
|
@ -123,8 +123,8 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_text_metrics(const PangoFontDescription *description, int *height, int *baseline) {
|
void get_text_metrics(const PangoFontDescription *description, int *height, int *baseline) {
|
||||||
cairo_t *cairo = cairo_create(NULL);
|
PangoFontMap *fontmap = pango_cairo_font_map_get_default();
|
||||||
PangoContext *pango = pango_cairo_create_context(cairo);
|
PangoContext *pango = pango_font_map_create_context(fontmap);
|
||||||
pango_context_set_round_glyph_positions(pango, false);
|
pango_context_set_round_glyph_positions(pango, false);
|
||||||
// When passing NULL as a language, pango uses the current locale.
|
// When passing NULL as a language, pango uses the current locale.
|
||||||
PangoFontMetrics *metrics = pango_context_get_metrics(pango, description, NULL);
|
PangoFontMetrics *metrics = pango_context_get_metrics(pango, description, NULL);
|
||||||
|
|
@ -134,7 +134,6 @@ void get_text_metrics(const PangoFontDescription *description, int *height, int
|
||||||
|
|
||||||
pango_font_metrics_unref(metrics);
|
pango_font_metrics_unref(metrics);
|
||||||
g_object_unref(pango);
|
g_object_unref(pango);
|
||||||
cairo_destroy(cairo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_text(cairo_t *cairo, const PangoFontDescription *desc,
|
void render_text(cairo_t *cairo, const PangoFontDescription *desc,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue