diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-07-18 22:58:02 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-07-18 22:58:02 +0200 |
| commit | 536c32ee99362c592db0ac2850c90bdabfd68038 (patch) | |
| tree | c06a14dd0ccc5e8fedde93a638a53b54a8dba8a2 /src/drivers/PostScript | |
| parent | 3560ff450fc297c668b9ebf9d6292d4db2c19eaf (diff) | |
Fl_Cairo_Graphics_Driver: simpler way to construct the PangoLayout object.
Diffstat (limited to 'src/drivers/PostScript')
| -rw-r--r-- | src/drivers/PostScript/Fl_PostScript.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 918dbcd6c..1d86a67f2 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -1506,18 +1506,23 @@ int Fl_PostScript_Graphics_Driver::start_eps(int width, int height) { void Fl_PostScript_Graphics_Driver::transformed_draw(const char* str, int n, double x, double y) { if (!n) return; + if (!pango_context_) { + PangoFontMap *def_font_map = pango_cairo_font_map_get_default(); // 1.10 + pango_context_ = pango_font_map_create_context(def_font_map); // 1.22 + pango_layout_ = pango_layout_new(pango_context_); + } PangoFontDescription *pfd = Fl_Graphics_Driver::default_driver().pango_font_description(font()); - pango_layout_set_font_description(pango_layout(), pfd); + pango_layout_set_font_description(pango_layout_, pfd); int pwidth, pheight; cairo_save(cairo_); - pango_layout_set_text(pango_layout(), str, n); - pango_layout_get_size(pango_layout(), &pwidth, &pheight); + pango_layout_set_text(pango_layout_, str, n); + pango_layout_get_size(pango_layout_, &pwidth, &pheight); if (pwidth > 0) { double s = width(str, n); cairo_translate(cairo_, x, y - height() + descent()); s = (s/pwidth) * PANGO_SCALE; cairo_scale(cairo_, s, s); - pango_cairo_show_layout(cairo_, pango_layout()); + pango_cairo_show_layout(cairo_, pango_layout_); } cairo_restore(cairo_); check_status(); |
