[dia] general: assorted cleanups from debugging tests



commit 519ab3a93345267fc063fa74f6ef8b572d002a9d
Author: Zander Brown <zbrown gnome org>
Date:   Tue Sep 21 15:50:51 2021 +0100

    general: assorted cleanups from debugging tests
    
    Of course 138/140 export tests still fail but at least none of them
    crash

 app/load_save.c                           | 69 +++++++++++++++++--------------
 lib/create.c                              | 30 +++++++-------
 lib/dia_xml.c                             | 45 +++++++++++---------
 lib/diaimportrenderer.c                   | 18 +++++---
 lib/font.c                                | 36 ++++++++++------
 lib/text.c                                | 15 ++++---
 plug-ins/cgm/cgm.c                        | 44 ++++++++++----------
 plug-ins/drs/dia-render-script-renderer.c | 23 ++++++-----
 plug-ins/svg/render_svg.c                 | 33 ++++++++-------
 plug-ins/wpg/wpg.c                        | 34 +++++++++------
 10 files changed, 198 insertions(+), 149 deletions(-)
---
diff --git a/app/load_save.c b/app/load_save.c
index 0f977c848..414337488 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -143,8 +143,8 @@ read_objects (xmlNodePtr objects,
 
   obj_node = objects->xmlChildrenNode;
 
-  while ( obj_node != NULL) {
-    if (xmlIsBlankNode(obj_node)) {
+  while (obj_node != NULL) {
+    if (xmlIsBlankNode (obj_node)) {
       obj_node = obj_node->next;
       continue;
     }
@@ -158,54 +158,59 @@ read_objects (xmlNodePtr objects,
 
       version = 0;
       if (versionstr != NULL) {
-       version = atoi(versionstr);
-       xmlFree(versionstr);
+        version = atoi (versionstr);
+        dia_clear_xml_string (&versionstr);
       }
 
-      type = object_get_type((char *)typestr);
+      type = object_get_type ((char *) typestr);
 
       if (!type) {
-       if (g_utf8_validate (typestr, -1, NULL) &&
-           NULL == g_hash_table_lookup(unknown_objects_hash, typestr))
-           g_hash_table_insert(unknown_objects_hash, g_strdup(typestr), 0);
-      }
-      else
-      {
-        obj = type->ops->load(obj_node, version, ctx);
-        list = g_list_append(list, obj);
+        if (g_utf8_validate (typestr, -1, NULL) &&
+            g_hash_table_lookup (unknown_objects_hash, typestr) == NULL) {
+          g_hash_table_insert (unknown_objects_hash, g_strdup (typestr), 0);
+        }
+      } else {
+        obj = type->ops->load (obj_node, version, ctx);
+        list = g_list_append (list, obj);
 
-        if (parent)
-        {
+        if (parent) {
           obj->parent = parent;
-          parent->children = g_list_append(parent->children, obj);
+          parent->children = g_list_append (parent->children, obj);
         }
 
-        g_hash_table_insert(objects_hash, g_strdup((char *)id), obj);
+        g_hash_table_insert (objects_hash, g_strdup ((char *) id), obj);
 
         child_node = obj_node->children;
 
-        while(child_node)
-        {
-          if (xmlStrcmp(child_node->name, (const xmlChar *)"children") == 0)
-          {
-           GList *children_read = read_objects(child_node, objects_hash, ctx, obj, unknown_objects_hash);
-            list = g_list_concat(list, children_read);
+        while (child_node) {
+          if (xmlStrcmp (child_node->name, (const xmlChar *) "children") == 0) {
+            GList *children_read = read_objects (child_node,
+                                                 objects_hash,
+                                                 ctx,
+                                                 obj,
+                                                 unknown_objects_hash);
+            list = g_list_concat (list, children_read);
             break;
           }
           child_node = child_node->next;
         }
       }
-      if (typestr) xmlFree(typestr);
-      if (id) xmlFree (id);
-    } else if (xmlStrcmp(obj_node->name, (const xmlChar *)"group")==0
-               && obj_node->children) {
+
+      dia_clear_xml_string (&typestr);
+      dia_clear_xml_string (&id);
+    } else if (xmlStrcmp (obj_node->name, (const xmlChar *) "group") == 0 &&
+               obj_node->children) {
       /* don't create empty groups */
-      GList *inner_objects = read_objects(obj_node, objects_hash, ctx, NULL, unknown_objects_hash);
+      GList *inner_objects = read_objects (obj_node,
+                                           objects_hash,
+                                           ctx,
+                                           NULL,
+                                           unknown_objects_hash);
 
       if (inner_objects) {
-        obj = group_create(inner_objects);
-       object_load_props(obj, obj_node, ctx);
-       list = g_list_append(list, obj);
+        obj = group_create (inner_objects);
+        object_load_props (obj, obj_node, ctx);
+        list = g_list_append (list, obj);
       }
     } else {
       /* silently ignore other nodes */
@@ -213,9 +218,11 @@ read_objects (xmlNodePtr objects,
 
     obj_node = obj_node->next;
   }
+
   return list;
 }
 
+
 static void
 read_connections(GList *objects, xmlNodePtr layer_node,
                 GHashTable *objects_hash)
diff --git a/lib/create.c b/lib/create.c
index c339ff735..b9dda4b9f 100644
--- a/lib/create.c
+++ b/lib/create.c
@@ -40,27 +40,29 @@
 #include "group.h"
 #include "create.h"
 
+
 DiaObject *
-create_standard_text(real xpos, real ypos) {
-    DiaObjectType *otype = object_get_type("Standard - Text");
-    DiaObject *new_obj;
-    Handle *h1, *h2;
-    Point point;
+create_standard_text (double xpos, double ypos)
+{
+  DiaObjectType *otype = object_get_type ("Standard - Text");
+  DiaObject *new_obj;
+  Handle *h1, *h2;
+  Point point;
 
-    if (otype == NULL){
-       message_error(_("Can't find standard object"));
-       return NULL;
-    }
+  if (otype == NULL) {
+    message_error (_("Can't find standard object"));
+    return NULL;
+  }
 
-    point.x = xpos;
-    point.y = ypos;
+  point.x = xpos;
+  point.y = ypos;
 
-    new_obj = otype->ops->create(&point, otype->default_user_data,
-                                &h1, &h2);
+  new_obj = otype->ops->create (&point, otype->default_user_data, &h1, &h2);
 
-    return new_obj;
+  return new_obj;
 }
 
+
 static PropDescription create_element_prop_descs[] = {
     { "elem_corner", PROP_TYPE_POINT },
     { "elem_width", PROP_TYPE_REAL },
diff --git a/lib/dia_xml.c b/lib/dia_xml.c
index b1fcf9496..e7f4be3f3 100644
--- a/lib/dia_xml.c
+++ b/lib/dia_xml.c
@@ -1010,44 +1010,49 @@ data_filename(DataNode data, DiaContext *ctx)
 }
 
 
-/*!
- * \brief Return the value of a font-type data node.
+/**
+ * data_font:
+ * @data: The data node to read from.
+ * @ctx: The context in which this function is called
  *
- * This handles both the current format (family and style) and the old format (name).
- * @param data The data node to read from.
- * @param ctx The context in which this function is called
- * @return The font value found in the node.  If the node is not a
- *  font node, an error message is registered and NULL is returned.  The
- *  resulting value should be freed after use.
- * \ingroup DiagramXmlIn
+ * This handles both the current format (family and style) and the old
+ * format (name).
+ *
+ * Returns: The font value found in the node. If the node is not a font node,
+ *          an error message is registered and %NULL is returned. The resulting
+ *          value should be freed after use.
  */
 DiaFont *
-data_font(DataNode data, DiaContext *ctx)
+data_font (DataNode data, DiaContext *ctx)
 {
   xmlChar *family;
   DiaFont *font;
 
-  if (data_type(data, ctx)!=DATATYPE_FONT) {
+  if (data_type (data, ctx) != DATATYPE_FONT) {
     dia_context_add_message (ctx, _("Taking font value of non-font node."));
     return NULL;
   }
 
-  family = xmlGetProp(data, (const xmlChar *)"family");
+  family = xmlGetProp (data, (const xmlChar *) "family");
   /* always prefer the new format */
   if (family) {
     DiaFontStyle style;
-    char* style_name = (char *) xmlGetProp(data, (const xmlChar *)"style");
-    style = style_name ? atoi(style_name) : 0;
+    char *style_name = (char *) xmlGetProp (data, (const xmlChar *) "style");
+    style = style_name ? atoi (style_name) : 0;
 
-    font = dia_font_new ((char *)family, style, 1.0);
-    if (family) free(family);
-    if (style_name) xmlFree(style_name);
+    font = dia_font_new ((char *) family, style, 1.0);
+
+    dia_clear_xml_string (&family);
+    dia_clear_xml_string (&style_name);
   } else {
     /* Legacy format support */
-    char *name = (char *)xmlGetProp(data, (const xmlChar *)"name");
-    font = dia_font_new_from_legacy_name(name);
-    free(name);
+    char *name = (char *) xmlGetProp (data, (const xmlChar *) "name");
+
+    font = dia_font_new_from_legacy_name (name);
+
+    dia_clear_xml_string (&name);
   }
+
   return font;
 }
 
diff --git a/lib/diaimportrenderer.c b/lib/diaimportrenderer.c
index a07ccf43f..8c199435e 100644
--- a/lib/diaimportrenderer.c
+++ b/lib/diaimportrenderer.c
@@ -417,23 +417,31 @@ fill_arc (DiaRenderer *renderer, Point *center,
 #endif
 }
 
+
 /*!
  * \brief Draw an ellipse
  * Creates a hollow _Ellipse object.
  * \memberof _DiaImportRenderer
  */
 static void
-draw_ellipse (DiaRenderer *renderer, Point *center,
-              real width, real height,
-              Color *fill, Color *stroke)
+draw_ellipse (DiaRenderer *renderer,
+              Point       *center,
+              double       width,
+              double       height,
+              Color       *fill,
+              Color       *stroke)
 {
   DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
-  DiaObject *object = create_standard_ellipse (center->x - width / 2, center->y - height / 2, width, height);
+  DiaObject *object = create_standard_ellipse (center->x - width / 2,
+                                               center->y - height / 2,
+                                               width,
+                                               height);
 
   _apply_style (self, object, fill, stroke, 0.0);
   _push_object (self, object);
 }
 
+
 /*!
  * \brief Draw a string
  * Creates a _Text object with the properties given by _DiaImportRenderer::set_font().
@@ -441,7 +449,7 @@ draw_ellipse (DiaRenderer *renderer, Point *center,
  */
 static void
 draw_string (DiaRenderer *renderer,
-             const gchar *text,
+             const char  *text,
              Point       *pos,
              Alignment    alignment,
              Color       *color)
diff --git a/lib/font.c b/lib/font.c
index 5e406bcbb..afdda960d 100644
--- a/lib/font.c
+++ b/lib/font.c
@@ -414,34 +414,46 @@ dia_font_get_style(const DiaFont* font)
 }
 
 
-const char*
-dia_font_get_family(const DiaFont* font)
+const char *
+dia_font_get_family (const DiaFont *font)
 {
+  g_return_val_if_fail (font != NULL, NULL);
+
   return pango_font_description_get_family(font->pfd);
 }
 
 
 const PangoFontDescription *
-dia_font_get_description (const DiaFont* font)
+dia_font_get_description (const DiaFont *font)
 {
+  g_return_val_if_fail (font != NULL, NULL);
+
   return font->pfd;
 }
 
 
-real
-dia_font_get_height(const DiaFont* font)
+double
+dia_font_get_height (const DiaFont *font)
 {
+  g_return_val_if_fail (font != NULL, 0.0);
+
   return font->height;
 }
 
-real
-dia_font_get_size(const DiaFont* font)
+
+double
+dia_font_get_size (const DiaFont *font)
 {
-  if (!pango_font_description_get_size_is_absolute (font->pfd))
+  g_return_val_if_fail (font != NULL, 0.0);
+
+  if (!pango_font_description_get_size_is_absolute (font->pfd)) {
     g_warning ("dia_font_get_size() : no absolute size");
-  return pdu_to_dcm(pango_font_description_get_size(font->pfd));
+  }
+
+  return pdu_to_dcm (pango_font_description_get_size (font->pfd));
 }
 
+
 void
 dia_font_set_height(DiaFont* font, real height)
 {
@@ -956,13 +968,13 @@ DiaFont*
 dia_font_new_from_legacy_name (const char* name)
 {
   /* do NOT translate anything here !!! */
-  DiaFont* retval;
+  DiaFont *retval = NULL;
   struct _legacy_font* found = NULL;
   real height = 1.0;
   int i;
 
-  for (i = 0; i < G_N_ELEMENTS(legacy_fonts); i++) {
-    if (!strcmp(name, legacy_fonts[i].oldname)) {
+  for (i = 0; i < G_N_ELEMENTS (legacy_fonts); i++) {
+    if (!g_strcmp0 (name, legacy_fonts[i].oldname)) {
       found = &legacy_fonts[i];
       break;
     }
diff --git a/lib/text.c b/lib/text.c
index 837a19f81..1e926098f 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -376,7 +376,7 @@ new_text (const char *string,
 {
   Text *text;
 
-  text = g_new(Text, 1);
+  text = g_new0 (Text, 1);
 
   text->font = g_object_ref (font);
   text->height = height;
@@ -430,11 +430,11 @@ text_copy (Text *text)
   Text *copy;
   int i;
 
-  copy = g_new(Text, 1);
+  copy = g_new0 (Text, 1);
   copy->numlines = text->numlines;
-  copy->lines = g_new(TextLine *, text->numlines);
+  copy->lines = g_new0 (TextLine *, text->numlines);
 
-  copy->font = dia_font_copy(text->font);
+  copy->font = dia_font_copy (text->font);
   copy->height = text->height;
   copy->position = text->position;
   copy->color = text->color;
@@ -493,10 +493,7 @@ text_get_height (const Text *text)
 void
 text_set_font (Text *text, DiaFont *font)
 {
-  DiaFont *old_font = text->font;
-
-  text->font = g_object_ref (font);
-  g_clear_object (&old_font);
+  g_set_object (&text->font, font);
 
   for (int i = 0; i < text->numlines; i++) {
     text_line_set_font (text->lines[i], font);
@@ -1292,8 +1289,10 @@ data_text (AttributeNode text_attr, DiaContext *ctx)
   }
 
   text = new_text (string ? string : "", font, height, &pos, &col, align);
+
   g_clear_object (&font);
   g_clear_pointer (&string, g_free);
+
   return text;
 }
 
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index 17bb28bf0..d78e12762 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -678,34 +678,37 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
 #endif
 }
 
+
 static void
-set_font (DiaRenderer *self, DiaFont *font, real height)
+wpg_renderer_set_font (DiaRenderer *self, DiaFont *font, double height)
 {
   CgmRenderer *renderer = CGM_RENDERER(self);
-  DiaFont *oldfont = renderer->font;
 
-  renderer->font = g_object_ref (font);
-  g_clear_object (&oldfont);
+  g_set_object (&renderer->font, font);
+
   renderer->tcurrent.font_num = FONT_NUM (font);
   renderer->tcurrent.font_height = height;
 }
 
+
 static void
-draw_line(DiaRenderer *self,
-         Point *start, Point *end,
-         Color *line_colour)
+draw_line (DiaRenderer *self,
+           Point       *start,
+           Point       *end,
+           Color       *line_colour)
 {
-    CgmRenderer *renderer = CGM_RENDERER(self);
+  CgmRenderer *renderer = CGM_RENDERER (self);
 
-    write_line_attributes(renderer, line_colour);
+  write_line_attributes (renderer, line_colour);
+  write_elhead (renderer->file, CGM_ELEMENT, CGM_POLYLINE, 2 * 2 * REALSIZE);
 
-    write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYLINE, 2 * 2 * REALSIZE);
-    write_real(renderer->file, start->x);
-    write_real(renderer->file, swap_y(renderer, start->y));
-    write_real(renderer->file, end->x);
-    write_real(renderer->file, swap_y(renderer, end->y));
+  write_real (renderer->file, start->x);
+  write_real (renderer->file, swap_y (renderer, start->y));
+  write_real (renderer->file, end->x);
+  write_real (renderer->file, swap_y (renderer, end->y));
 }
 
+
 static void
 draw_polyline(DiaRenderer *self,
              Point *points, int num_points,
@@ -1212,7 +1215,6 @@ export_cgm(DiagramData *data, DiaContext *ctx,
 
   data_render (data, DIA_RENDERER (renderer), NULL, NULL, NULL);
 
-  g_clear_object (&renderer->font);
   g_clear_object (&renderer);
 
   return TRUE;
@@ -1261,14 +1263,14 @@ cgm_renderer_set_property (GObject      *object,
 
   switch (property_id) {
     case PROP_FONT:
-      set_font (DIA_RENDERER (self),
-                g_value_get_object (value),
-                self->tcurrent.font_height);
+      wpg_renderer_set_font (DIA_RENDERER (self),
+                             g_value_get_object (value),
+                             self->tcurrent.font_height);
       break;
     case PROP_FONT_HEIGHT:
-      set_font (DIA_RENDERER (self),
-                self->font,
-                g_value_get_double (value));
+      wpg_renderer_set_font (DIA_RENDERER (self),
+                             self->font,
+                             g_value_get_double (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
diff --git a/plug-ins/drs/dia-render-script-renderer.c b/plug-ins/drs/dia-render-script-renderer.c
index f77929ebd..4970717c8 100644
--- a/plug-ins/drs/dia-render-script-renderer.c
+++ b/plug-ins/drs/dia-render-script-renderer.c
@@ -59,16 +59,16 @@ _node_set_real (xmlNodePtr node, const char *name, real v)
   xmlSetProp (node, (const xmlChar *) name, (xmlChar *) value);
 }
 
+
 static void
-set_font (DiaRenderer *self, DiaFont *font, real height)
+drs_renderer_set_font (DiaRenderer *self, DiaFont *font, double height)
 {
   DrsRenderer *renderer = DRS_RENDERER (self);
   xmlNodePtr node;
   const PangoFontDescription *pfd = dia_font_get_description (font);
   char *desc = pango_font_description_to_string (pfd);
 
-  g_clear_object (&renderer->font);
-  renderer->font = font;
+  g_set_object (&renderer->font, font);
   renderer->font_height = height;
 
   node =  xmlNewChild (renderer->root, NULL, (const xmlChar *) "set-font", NULL);
@@ -83,6 +83,7 @@ set_font (DiaRenderer *self, DiaFont *font, real height)
   g_clear_pointer (&desc, g_free);
 }
 
+
 static void
 drs_renderer_set_property (GObject      *object,
                            guint         property_id,
@@ -93,14 +94,14 @@ drs_renderer_set_property (GObject      *object,
 
   switch (property_id) {
     case PROP_FONT:
-      set_font (DIA_RENDERER (self),
-                DIA_FONT (g_value_get_object (value)),
-                self->font_height);
+      drs_renderer_set_font (DIA_RENDERER (self),
+                             DIA_FONT (g_value_get_object (value)),
+                             self->font_height);
       break;
     case PROP_FONT_HEIGHT:
-      set_font (DIA_RENDERER (self),
-                self->font,
-                g_value_get_double (value));
+      drs_renderer_set_font (DIA_RENDERER (self),
+                             self->font,
+                             g_value_get_double (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -129,6 +130,7 @@ drs_renderer_get_property (GObject    *object,
   }
 }
 
+
 /* destructor */
 static void
 drs_renderer_finalize (GObject *object)
@@ -139,8 +141,7 @@ drs_renderer_finalize (GObject *object)
 
   g_queue_free (renderer->parents);
   g_queue_free (renderer->matrices);
-  if (renderer->ctx)
-    dia_context_release (renderer->ctx);
+  g_clear_object (&renderer->ctx);
 
   G_OBJECT_CLASS (drs_renderer_parent_class)->finalize (object);
 }
diff --git a/plug-ins/svg/render_svg.c b/plug-ins/svg/render_svg.c
index fe084553e..1f285eae3 100644
--- a/plug-ins/svg/render_svg.c
+++ b/plug-ins/svg/render_svg.c
@@ -410,25 +410,26 @@ draw_object(DiaRenderer *self,
 #define dia_svg_dtostr(buf,d) \
   g_ascii_formatd(buf,sizeof(buf),"%g",(d)*renderer->scale)
 
+
 static void
 node_set_text_style (xmlNodePtr      node,
-                    DiaSvgRenderer *renderer,
-                    const DiaFont  *font,
-                    real            font_height,
-                    Alignment       alignment,
-                    Color          *colour)
+                     DiaSvgRenderer *renderer,
+                     const DiaFont  *font,
+                     double          font_height,
+                     Alignment       alignment,
+                     Color          *colour)
 {
-  real saved_width;
-  gchar d_buf[G_ASCII_DTOSTR_BUF_SIZE];
+  double saved_width;
+  char d_buf[G_ASCII_DTOSTR_BUF_SIZE];
   DiaSvgRendererClass *svg_renderer_class = DIA_SVG_RENDERER_GET_CLASS (renderer);
   GString *style;
   /* SVG font-size is the (line-) height, from SVG Spec:
    * ... property refers to the size of the font from baseline to baseline when multiple lines of text are 
set ...
   so we should be able to use font_height directly instead of:
    */
-  real font_size = dia_font_get_size (font) * (font_height / dia_font_get_height (font));
+  double font_size = dia_font_get_size (font) * (font_height / dia_font_get_height (font));
   /* ... but at least Inkscape and Firefox would produce the wrong font-size */
-  const gchar *family = dia_font_get_family(font);
+  const char *family = dia_font_get_family (font);
 
   saved_width = renderer->linewidth;
   renderer->linewidth = 0.001;
@@ -489,6 +490,8 @@ _adjust_space_preserve (xmlNodePtr node,
   if (g_unichar_isspace (uc))
     xmlSetProp (node, (const xmlChar *)"xml:space", (const xmlChar *)"preserve");
 }
+
+
 /*!
  * \brief Support rendering of raw text
  *
@@ -498,14 +501,15 @@ _adjust_space_preserve (xmlNodePtr node,
  * \memberof _SvgRenderer
  */
 static void
-draw_string(DiaRenderer *self,
-           const char *text,
-           Point *pos, Alignment alignment,
-           Color *colour)
+draw_string (DiaRenderer *self,
+             const char  *text,
+             Point       *pos,
+             Alignment    alignment,
+             Color       *colour)
 {
   DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
   xmlNodePtr node;
-  gchar d_buf[G_ASCII_DTOSTR_BUF_SIZE];
+  char d_buf[G_ASCII_DTOSTR_BUF_SIZE];
   DiaFont *font;
   double font_height;
 
@@ -525,6 +529,7 @@ draw_string(DiaRenderer *self,
   xmlSetProp (node, (xmlChar *) "y", (xmlChar *)d_buf);
 }
 
+
 /*!
  * \brief Support rendering of the _TextLine object
  * \memberof _SvgRenderer
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index 77210c2f5..f739e685a 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -432,8 +432,9 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
   }
 }
 
+
 static void
-set_font(DiaRenderer *self, DiaFont *font, real height)
+wpg_renderer_set_font (DiaRenderer *self, DiaFont *font, double height)
 {
   WpgRenderer *renderer = WPG_RENDERER (self);
 
@@ -441,19 +442,24 @@ set_font(DiaRenderer *self, DiaFont *font, real height)
 
   const char *family_name;
   DIAG_NOTE(g_message("set_font %f %s", height, font->name));
-  renderer->TextStyle.Height = SC(height);
+  renderer->TextStyle.Height = SC (height);
+
+  g_print ("f: %p h: %f\n", font, height);
+
+  g_set_object (&renderer->font, font);
 
-  family_name = dia_font_get_family(font);
+  family_name = dia_font_get_family (font);
 
-  if ((strstr(family_name, "courier")) || (strstr(family_name, "monospace")))
+  if ((strstr (family_name, "courier")) || (strstr (family_name, "monospace"))) {
     renderer->TextStyle.Font = 0x0DF0;
-  else if ((strstr(family_name, "times")) || (strstr(family_name, "serif")))
+  } else if ((strstr (family_name, "times")) || (strstr (family_name, "serif"))) {
     renderer->TextStyle.Font = 0x1950;
-  else
+  } else {
     renderer->TextStyle.Font = 0x1150; /* Helv */
-
+  }
 }
 
+
 /* Need to translate coord system:
  *
  *   Dia x,y -> Wpg x,-y
@@ -1011,6 +1017,7 @@ wpg_renderer_get_type (void)
   return object_type;
 }
 
+
 static void
 wpg_renderer_set_property (GObject      *object,
                            guint         property_id,
@@ -1021,14 +1028,14 @@ wpg_renderer_set_property (GObject      *object,
 
   switch (property_id) {
     case PROP_FONT:
-      set_font (DIA_RENDERER (self),
-                DIA_FONT (g_value_get_object (value)),
-                self->font_height);
+      wpg_renderer_set_font (DIA_RENDERER (self),
+                             DIA_FONT (g_value_get_object (value)),
+                             self->font_height);
       break;
     case PROP_FONT_HEIGHT:
-      set_font (DIA_RENDERER (self),
-                self->font,
-                g_value_get_double (value));
+      wpg_renderer_set_font (DIA_RENDERER (self),
+                             self->font,
+                             g_value_get_double (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1036,6 +1043,7 @@ wpg_renderer_set_property (GObject      *object,
   }
 }
 
+
 static void
 wpg_renderer_get_property (GObject    *object,
                            guint       property_id,


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