[dia] [path] text_to_path() might fail, make it silently



commit 402165faee6d3b9c866f8204a613e155549b4201
Author: Hans Breuer <hans breuer org>
Date:   Sun Nov 11 16:34:45 2012 +0100

    [path] text_to_path() might fail, make it silently
    
    The current implementation of text-to-path relies on PangoCairo
    being used. If the layout is not created for pango-cairo the code
    would fail with g_warnings from Pango - or worse.
    For the time being only the win32 GUI case is using a
    pango-cairo-context got by gdk_pango_context_get() - the non-GUI
    code falls back to pango_win32_get_context (). And the non-win32
    version uses pango_ft2_get_context() - i.e. freetype - when
    available.
    We might change the global font context of Dia to use pango_cairo_font_map_create_context() with
    pango_cairo_font_map_get_default() but messing with Dia's
    global font context needs to be carefully evaluated.

 lib/diapathrenderer.c |    4 +---
 lib/standard-path.c   |    3 +++
 2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/lib/diapathrenderer.c b/lib/diapathrenderer.c
index ed8329b..eb595a2 100644
--- a/lib/diapathrenderer.c
+++ b/lib/diapathrenderer.c
@@ -516,14 +516,12 @@ draw_text (DiaRenderer *self,
   GArray *path = _get_current_path (renderer, NULL, &text->color);
   int n0 = path->len;
 
-  if (!text_is_empty (text)) {
+  if (!text_is_empty (text) && text_to_path (text, path)) {
     Rectangle bz_bb, tx_bb;
     PolyBBExtras extra = { 0, };
     real dx, dy, sx, sy;
     guint i;
     
-    text_to_path (text, path);
-
     polybezier_bbox (&g_array_index (path, BezPoint, n0), path->len - n0, &extra, TRUE, &bz_bb);
     text_calc_boundingbox (text, &tx_bb);
     sx = (tx_bb.right - tx_bb.left) / (bz_bb.right - bz_bb.left);
diff --git a/lib/standard-path.c b/lib/standard-path.c
index ec2a7ab..7bfd349 100644
--- a/lib/standard-path.c
+++ b/lib/standard-path.c
@@ -767,6 +767,9 @@ text_to_path (const Text *text, GArray *points)
   char *str;
   gboolean ret = FALSE;
 
+  if (!PANGO_IS_CAIRO_FONT_MAP (pango_context_get_font_map (dia_font_get_context())))
+    return FALSE;
+
   layout = pango_layout_new(dia_font_get_context());
   pango_layout_set_font_description (layout, dia_font_get_description (text->font));
   pango_layout_set_indent (layout, 0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]