From e6e1186a7ed01d5c26c43ff7f02107a998caeb87 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 7 Jun 2003 03:19:35 +0000 Subject: [PATCH] Reconciled unit names with absolute unit names from CSS2 spec (section 4.3.2). Fixed comparison in gl_xml_get_prop_length(). git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@257 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/xml.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/glabels2/src/xml.c b/glabels2/src/xml.c index f0a210ec..a8c32f9b 100644 --- a/glabels2/src/xml.c +++ b/glabels2/src/xml.c @@ -27,11 +27,11 @@ /* Private macros and constants. */ /*========================================================*/ -#define POINTS_PER_POINT 1.0 +#define POINTS_PER_POINT 1.0 /* internal units are points. */ #define POINTS_PER_INCH 72.0 #define POINTS_PER_MM 2.83464566929 #define POINTS_PER_CM (10.0*POINTS_PER_MM) -#define POINTS_PER_M (1000.0*POINTS_PER_MM) +#define POINTS_PER_PICA (1.0/12.0) /*========================================================*/ /* Private types. */ @@ -46,23 +46,17 @@ typedef struct { /* Private globals. */ /*========================================================*/ -UnitTableEntry unit_table[] = { - {"point", POINTS_PER_POINT}, - {"points", POINTS_PER_POINT}, +static UnitTableEntry unit_table[] = { + + /* These names are identical to the absolute length units supported in + the CSS2 Specification (Section 4.3.2) */ + {"pt", POINTS_PER_POINT}, - {"pts", POINTS_PER_POINT}, {"in", POINTS_PER_INCH}, - {"inch", POINTS_PER_INCH}, - {"inches", POINTS_PER_INCH}, {"mm", POINTS_PER_MM}, - {"millimeter", POINTS_PER_MM}, - {"millimeters", POINTS_PER_MM}, {"cm", POINTS_PER_CM}, - {"centimeter", POINTS_PER_CM}, - {"centimeters", POINTS_PER_CM}, - {"m", POINTS_PER_M}, - {"meter", POINTS_PER_M}, - {"meters", POINTS_PER_M}, + {"pc", POINTS_PER_PICA}, + {NULL, 0} }; @@ -177,11 +171,13 @@ gl_xml_get_prop_length (xmlNodePtr node, g_free (string); switch (n) { + case 1: break; + case 2: for (i=0; unit_table[i].name != NULL; i++) { - if (xmlStrcasecmp (units, unit_table[i].name) != 0) { + if (xmlStrcasecmp (units, unit_table[i].name) == 0) { val *= unit_table[i].points_per_unit; break; } @@ -192,9 +188,11 @@ gl_xml_get_prop_length (xmlNodePtr node, units); } break; + default: val = 0.0; break; + } return val; } @@ -268,7 +266,7 @@ gl_xml_set_prop_length (xmlNodePtr node, { gchar *string; - string = g_strdup_printf ("%gpts", val); + string = g_strdup_printf ("%g pt", val); xmlSetProp (node, property, string); g_free (string); } -- 2.39.5