Comment 10 for bug 349914

Revision history for this message
Alexander Sack (asac) wrote :

bzr log -c2378
------------------------------------------------------------
revno: 2378
committer: behdad
timestamp: Wed 2009-01-28 22:07:38 +0000
message:
  2009-01-09 Behdad Esfahbod <email address hidden>

          * docs/pango-sections.txt:
          * docs/tmpl/pangofc-fontmap.sgml:
          * docs/tmpl/text-attributes.sgml:
          * pango/pangocairo-fc.h:
          * pango/pangocairo-fcfont.c (get_font_size), (get_gravity_class),
          (get_gravity), (_pango_cairo_fc_font_new):
          * pango/pangocairo-fcfontmap.c
          (pango_cairo_fc_font_map_font_key_substitute),
          (pango_cairo_fc_font_map_create_font),
          (pango_cairo_fc_font_map_class_init):
          * pango/pangofc-font.c (_pango_fc_font_get_font_key),
          (_pango_fc_font_set_font_key):
          * pango/pangofc-fontmap.c (pango_fc_font_key_equal),
          (pango_fc_font_key_hash), (pango_fc_font_key_free),
          (pango_fc_font_key_copy), (get_context_matrix),
          (pango_fc_font_key_init), (pango_fc_font_key_get_pattern),
          (pango_fc_font_key_get_matrix),
          (pango_fc_font_key_get_context_key), (pango_fc_font_map_init),
          (pango_fc_font_map_class_init), (pango_fc_font_map_add),
          (_pango_fc_font_map_remove), (pango_fc_make_pattern),
          (pango_fc_font_map_new_font), (pango_fc_default_substitute),
          (pango_fc_font_map_get_patterns), (pango_fc_font_map_load_fontset):
          * pango/pangofc-fontmap.h:
          * pango/pangofc-private.h:
          Change PangoFc font loading API such that PangoContext is not passed
          down. We use a new opaque struct called PangoFcFontKey. This struct
          is in fact our font hash key. This avoids problems where previously
          we were using context members that were not necessarily considered
          by the pangofc layer when caching.
          This is in preparation for lazy loading of fonts in the pangofc fontmap.
asac@hector3:~/gnome/pango.trunk.bzr$ bzr diff -c2378 pango/pangofc-fontmap.h
=== modified file 'pango/pangofc-fontmap.h'
--- a/pango/pangofc-fontmap.h 2008-12-08 03:28:29 +0000
+++ b/pango/pangofc-fontmap.h 2009-01-28 22:07:38 +0000
@@ -24,16 +24,34 @@

 #include <fontconfig/fontconfig.h>
 #include <pango/pango-fontmap.h>
 #include <pango/pangofc-decoder.h>
 #include <pango/pangofc-font.h>

 G_BEGIN_DECLS

+/**
+ * PangoFcFontKey:
+ *
+ * An opaque structure containing all the information needed for
+ * loading a font #PangoFcFont.
+ *
+ * Since: 1.24
+ **/
+typedef struct _PangoFcFontKey PangoFcFontKey;
+
+const FcPattern *pango_fc_font_key_get_pattern (const PangoFcFontKey *key);
+const PangoMatrix *pango_fc_font_key_get_matrix (const PangoFcFontKey *key);
+gpointer pango_fc_font_key_get_context_key (const PangoFcFontKey *key);
+
+/*
+ * PangoFcFontMap
+ */
+
 #define PANGO_TYPE_FC_FONT_MAP (pango_fc_font_map_get_type ())
 #define PANGO_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMap))
 #define PANGO_IS_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FC_FONT_MAP))

 typedef struct _PangoFcFontMap PangoFcFontMap;
 typedef struct _PangoFcFontMapClass PangoFcFontMapClass;
 typedef struct _PangoFcFontMapPrivate PangoFcFontMapPrivate;

@@ -59,17 +77,17 @@ struct _PangoFcFontMap
   PangoFcFontMapPrivate *priv;
 };

 /**
  * PangoFcFontMapClass:
  * @default_substitute: Substitutes in default values for
  * unspecified fields in a #FcPattern. This will be called
  * prior to creating a font for the pattern. May be %NULL.
- * Deprecated in favor of @context_substitute().
+ * Deprecated in favor of @font_key_substitute().
  * @new_font: Creates a new #PangoFcFont for the specified
  * pattern of the appropriate type for this font map. The
  * @pattern argument must be passed to the "pattern" property
  * of #PangoFcFont when you call g_object_new(). Deprecated
  * in favor of @create_font().
  * @get_resolution: Gets the resolution (the scale factor
  * between logical and absolute font sizes) that the backend
  * will use for a particular fontmap and context. @context
@@ -82,35 +100,38 @@ struct _PangoFcFontMap
  * and fonts.
  * @context_key_copy: Copies a context key. Pango uses this
  * to make a persistant copy of the value returned from
  * @context_key_get.
  * @context_key_free: Frees a context key copied with
  * @context_key_copy.
  * @context_key_hash: Gets a hash value for a context key
  * @context_key_equal: Compares two context keys for equality.
- * @create_font: Creates a new #PangoFcFont for the specified
- * pattern of the appropriate type for this font map using
- * information from the context that is passed in. The
- * @pattern argument must be passed to the "pattern" property
- * of #PangoFcFont when you call g_object_new(). Deprecated
- * in favor of @create_font(). If %NULL, new_font() is used.
- * @context_substitute: Substitutes in default values for
+ * @font_key_substitute: Substitutes in default values for
  * unspecified fields in a #FcPattern. This will be called
  * prior to creating a font for the pattern. May be %NULL.
+ * (Since: 1.24)
+ * @create_font: Creates a new #PangoFcFont for the specified
+ * pattern of the appropriate type for this font map using
+ * information from the font key that is passed in. The
+ * @pattern member of @font_key can be retrieved using
+ * pango_fc_font_key_get_pattern() and must be passed to
+ * the "pattern" property of #PangoFcFont when you call
+ * g_object_new(). If %NULL, new_font() is used.
+ * (Since: 1.24)
  *
  * Class structure for #PangoFcFontMap.
  **/
 struct _PangoFcFontMapClass
 {
   /*< private >*/
   PangoFontMapClass parent_class;

   /*< public >*/
- /* Deprecated in favor of context_substitute */
+ /* Deprecated in favor of font_key_substitute */
   void (*default_substitute) (PangoFcFontMap *fontmap,
           FcPattern *pattern);
   /* Deprecated in favor of create_font */
   PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
           FcPattern *pattern);

   double (*get_resolution) (PangoFcFontMap *fcfontmap,
           PangoContext *context);
@@ -122,23 +143,21 @@ struct _PangoFcFontMapClass
   void (*context_key_free) (PangoFcFontMap *fcfontmap,
           gpointer key);
   guint32 (*context_key_hash) (PangoFcFontMap *fcfontmap,
           gconstpointer key);
   gboolean (*context_key_equal) (PangoFcFontMap *fcfontmap,
           gconstpointer key_a,
           gconstpointer key_b);

- void (*context_substitute) (PangoFcFontMap *fontmap,
- PangoContext *context,
+ void (*font_key_substitute)(PangoFcFontMap *fontmap,
+ PangoFcFontKey *fontkey,
           FcPattern *pattern);
   PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
- PangoContext *context,
- const PangoFontDescription *desc,
- FcPattern *pattern);
+ PangoFcFontKey *fontkey);
   /*< private >*/

   /* Padding for future expansion */
   void (*_pango_reserved1) (void);
   void (*_pango_reserved2) (void);
   void (*_pango_reserved3) (void);
   void (*_pango_reserved4) (void);
 };