Kerning Patch



This does a lot of the preliminary work for making kerning work.  The
mark up would be <span kern="%82">some_char></span> or <span
kern="12">some_char</span>

The 12 would be absolute kerning, I don't know what type yet, probably
in em or pica.  The other is percentage.  The kerning works on the space
before the character.  If multiple characters are mentioned, it works on
the space before each one.

There are currently two problems:
1) pango_fc_font_kern_glyphs (PangoFcFont *font, PangoGlyphString
*glyphs) never gets called

and

2) I am not sure how to retreive the kerning data created in the patch
in that function anyway.

Please, let me know what you all think.

Trever
--
"My spelling is Wobbly. It's good spelling but it Wobbles, and the
letters get in the wrong places." -- A. A. Milne (1882-1958)
diff -ur pango-1.3.0/pango/Makefile.am pango-kern/pango/Makefile.am
--- pango-1.3.0/pango/Makefile.am	2003-10-23 23:54:36.000000000 -0400
+++ pango-kern/pango/Makefile.am	2003-11-07 03:13:52.968483493 -0500
@@ -67,6 +67,7 @@
 	pango-glyph-item.c     \
 	pango-impl-utils.h     \
 	pango-item.c	       \
+	pango-kern.c           \
 	pango-layout.c	       \
 	pango-markup.c	       \
 	pango-script.c	       \
diff -ur pango-1.3.0/pango/Makefile.in pango-kern/pango/Makefile.in
--- pango-1.3.0/pango/Makefile.in	2003-10-23 23:56:54.000000000 -0400
+++ pango-kern/pango/Makefile.in	2003-11-07 03:17:33.166010948 -0500
@@ -303,6 +303,7 @@
 	pango-glyph-item.c     \
 	pango-impl-utils.h     \
 	pango-item.c	       \
+	pango-kern.c           \
 	pango-layout.c	       \
 	pango-markup.c	       \
 	pango-script.c	       \
@@ -446,7 +447,7 @@
 am_libpango_1_0_la_OBJECTS = break.lo fonts.lo glyphstring.lo mapping.lo \
 	modules.lo pango-attributes.lo pango-color.lo pango-context.lo \
 	pango-coverage.lo pango-engine.lo pango-fontmap.lo \
-	pango-fontset.lo pango-glyph-item.lo pango-item.lo \
+	pango-fontset.lo pango-glyph-item.lo pango-item.lo pango-kern.lo \
 	pango-layout.lo pango-markup.lo pango-script.lo pango-tabs.lo \
 	pango-utils.lo reorder-items.lo shape.lo pango-enum-types.lo
 libpango_1_0_la_OBJECTS = $(am_libpango_1_0_la_OBJECTS)
diff -ur pango-1.3.0/pango/pango-attributes.c pango-kern/pango/pango-attributes.c
--- pango-1.3.0/pango/pango-attributes.c	2003-07-24 14:31:23.000000000 -0400
+++ pango-kern/pango/pango-attributes.c	2003-11-07 03:12:44.703109885 -0500
@@ -1611,3 +1611,30 @@
 
   return attrs;
 }
+
+/**
+ * pango_kern_new:
+ * @scale_factor: factor to modify kerning
+ * 
+ * Create a new kerning attribute. The base kerning will
+ * multiplied by the kern_factor if it is of perecentage type.
+ * Otherwise, it is the new absolute kerning value.
+ *
+ * Return value: the new #PangoAttribute.
+ **/
+PangoAttribute*
+pango_attr_kern_new (double kern_factor, PangoKern kern_type)
+{
+  static const PangoAttrClass klass = {
+    PANGO_ATTR_KERN,
+    pango_attr_float_copy,
+    pango_attr_float_destroy,
+    pango_attr_float_equal
+  };
+
+  PangoAttrKern *result = g_new (PangoAttrKern, 1);
+  result->attr.klass = &klass;
+  result->kern_type = kern_type;
+
+  return (PangoAttribute *)result;
+}
diff -ur pango-1.3.0/pango/pango-attributes.h pango-kern/pango/pango-attributes.h
--- pango-1.3.0/pango/pango-attributes.h	2002-12-10 18:45:26.000000000 -0500
+++ pango-kern/pango/pango-attributes.h	2003-11-07 02:50:20.994219049 -0500
@@ -58,6 +58,7 @@
 typedef struct _PangoAttrColor    PangoAttrColor;
 typedef struct _PangoAttrFontDesc PangoAttrFontDesc;
 typedef struct _PangoAttrShape    PangoAttrShape;
+typedef struct _PangoAttrKern     PangoAttrKern;
 
 #define PANGO_TYPE_ATTR_LIST pango_attr_list_get_type ()
 typedef struct _PangoAttrList     PangoAttrList;
@@ -80,7 +81,8 @@
   PANGO_ATTR_STRIKETHROUGH,	/* PangoAttrInt */
   PANGO_ATTR_RISE,		/* PangoAttrInt */
   PANGO_ATTR_SHAPE,		/* PangoAttrShape */
-  PANGO_ATTR_SCALE              /* PangoAttrFloat */
+  PANGO_ATTR_SCALE,             /* PangoAttrFloat */
+  PANGO_ATTR_KERN,              /* PangoAttrKern */
 } PangoAttrType;
 
 typedef enum {
@@ -90,6 +92,12 @@
   PANGO_UNDERLINE_LOW
 } PangoUnderline;
 
+typedef enum {
+  PANGO_KERN_NONE,
+  PANGO_KERN_PERCENT,
+  PANGO_KERN_ABSOLUTE,
+} PangoKern;
+
 struct _PangoAttribute
 {
   const PangoAttrClass *klass;
@@ -152,6 +160,12 @@
   PangoFontDescription *desc;
 };
 
+struct _PangoAttrKern
+{
+  PangoAttribute attr;
+  PangoKern kern_type;
+};
+
 PangoAttrType    pango_attr_type_register (const gchar          *name);
 
 PangoAttribute * pango_attribute_copy          (const PangoAttribute *attr);
@@ -215,6 +229,8 @@
 						 PangoLanguage        **language,
                                                  GSList               **extra_attrs);
 GSList *          pango_attr_iterator_get_attrs (PangoAttrIterator     *iterator);
+PangoAttribute *pango_attr_kern_new (double kern_factor, PangoKern kern_type);
+
 
 
 gboolean pango_parse_markup (const char                 *markup_text,
diff -ur pango-1.3.0/pango/pango-enum-types.c pango-kern/pango/pango-enum-types.c
--- pango-1.3.0/pango/pango-enum-types.c	2003-10-23 23:48:48.000000000 -0400
+++ pango-kern/pango/pango-enum-types.c	2003-11-07 02:37:11.715570279 -0500
@@ -26,6 +26,7 @@
       { PANGO_ATTR_RISE, "PANGO_ATTR_RISE", "rise" },
       { PANGO_ATTR_SHAPE, "PANGO_ATTR_SHAPE", "shape" },
       { PANGO_ATTR_SCALE, "PANGO_ATTR_SCALE", "scale" },
+      { PANGO_ATTR_KERN, "PANGO_ATTR_KERN", "kern" },
       { 0, NULL, NULL }
     };
     etype = g_enum_register_static ("PangoAttrType", values);
@@ -50,6 +51,22 @@
   return etype;
 }
 
+GType
+pango_kern_get_type (void)
+{
+  static GType etype = 0;
+  if (etype == 0) {
+    static const GEnumValue values[] = {
+      { PANGO_KERN_NONE, "PANGO_KERN_NONE", "none" },
+      { PANGO_KERN_PERCENT, "PANGO_KERN_PERCENT", "percent" },
+      { PANGO_KERN_ABSOLUTE, "PANGO_KERN_ABSOLUTE", "absolute" },
+      { 0, NULL, NULL }
+    };
+    etype = g_enum_register_static ("PangoKern", values);
+  }
+  return etype;
+}
+
 
 /* enumerations from "pango-coverage.h" */
 GType
diff -ur pango-1.3.0/pango/pango-enum-types.h pango-kern/pango/pango-enum-types.h
--- pango-1.3.0/pango/pango-enum-types.h	2003-10-23 23:48:48.000000000 -0400
+++ pango-kern/pango/pango-enum-types.h	2003-11-07 02:37:11.795556355 -0500
@@ -16,6 +16,9 @@
 GType pango_underline_get_type (void);
 #define PANGO_TYPE_UNDERLINE (pango_underline_get_type())
 
+GType pango_kern_get_type (void);
+#define PANGO_TYPE_KERN (pango_kern_get_type())
+
 /* enumerations from "pango-coverage.h" */
 
 GType pango_coverage_level_get_type (void);
diff -ur pango-1.3.0/pango/pango-markup.c pango-kern/pango/pango-markup.c
--- pango-1.3.0/pango/pango-markup.c	2002-07-02 13:15:22.000000000 -0400
+++ pango-kern/pango/pango-markup.c	2003-11-07 02:49:27.778153933 -0500
@@ -854,6 +854,7 @@
   const char *strikethrough = NULL;
   const char *rise = NULL;
   const char *lang = NULL;
+  const char *kern = NULL;
   
   g_markup_parse_context_get_position (context,
                                        &line_number, &char_number);
@@ -928,6 +929,11 @@
           CHECK_DUPLICATE (lang);
           lang = values[i];
         }
+      else if (strcmp (names[i], "kern") == 0)
+        {
+          CHECK_DUPLICATE (kern);
+          kern = values[i];
+        }
       else
         {
           g_set_error (error, G_MARKUP_ERROR,
@@ -1197,7 +1203,26 @@
       add_attribute (tag,
 		     pango_attr_language_new (pango_language_from_string (lang)));
     }
-  
+
+  if (kern)
+    {
+      double kern_factor;
+      PangoKern kern_type;
+
+      if (!pango_kern_parse (&kern_factor, &kern_type, kern))
+        {
+          g_set_error (error,
+                       G_MARKUP_ERROR,
+                       G_MARKUP_ERROR_INVALID_CONTENT,
+                       _("Could not parse foreground kerning specification "
+                         "'%s' on line %d"),
+                       kern, line_number);
+          goto error;
+        }
+
+      add_attribute (tag, pango_attr_kern_new (kern_factor, kern_type));
+    }
+ 
   return TRUE;
 
  error:
diff -ur pango-1.3.0/pango-zip.sh pango-kern/pango-zip.sh
--- pango-1.3.0/pango-zip.sh	2003-10-23 23:43:40.000000000 -0400
+++ pango-kern/pango-zip.sh	2003-11-07 03:17:59.991448394 -0500
@@ -4,7 +4,7 @@
 
 ZIP=/tmp/pango-1.3.0-`date +%Y%m%d`.zip
 DEVZIP=/tmp/pango-dev-1.3.0-`date +%Y%m%d`.zip
-cd /usr
+cd /usr/local
 
 DLLDIR=lib
 [ -f bin/libpango-1.0-0.dll ] && DLLDIR=bin


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