summaryrefslogtreecommitdiff
path: root/pango/pangocairo-coretextfontmap.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@lanedo.com>2011-10-14 11:25:21 +0200
committerKristian Rietveld <kris@lanedo.com>2012-01-28 11:24:26 +0100
commit37e74619215ede8a4fa7f5edabab14b517e673b2 (patch)
treeda27a427e7fe293451bddd0cde4d9f4d8b1e67d0 /pango/pangocairo-coretextfontmap.c
parent2edc014f3c244be31deab6e584db54f87d223965 (diff)
downloadpango-37e74619215ede8a4fa7f5edabab14b517e673b2.tar.gz
CoreText backend: implement font fallbacks
We implement font fallbacks by making use of CTFontCopyDefaultCascadeList, a public, non-exposed, symbol in the CoreText library. We might want to handle this differently. The code now also uses a PangoCoreTextFontsetKey and PangoCoreTextFontKey, similar to the font config backend. This has also helped to clean up the code in general. This patch contains two fixes by Michael Natterer: 1. Fix a bug in pango_core_text_font_key_equal() where the return value of memcmp() was wrongly interpreted. 2. Cache PangoCoverage in PangoCoreTextFont.
Diffstat (limited to 'pango/pangocairo-coretextfontmap.c')
-rw-r--r--pango/pangocairo-coretextfontmap.c72
1 files changed, 66 insertions, 6 deletions
diff --git a/pango/pangocairo-coretextfontmap.c b/pango/pangocairo-coretextfontmap.c
index e05a1d40..107c8289 100644
--- a/pango/pangocairo-coretextfontmap.c
+++ b/pango/pangocairo-coretextfontmap.c
@@ -44,7 +44,7 @@ pango_cairo_core_text_font_map_set_resolution (PangoCairoFontMap *cfontmap,
}
static double
-pango_cairo_core_text_font_map_get_resolution (PangoCairoFontMap *cfontmap)
+pango_cairo_core_text_font_map_get_resolution_cairo (PangoCairoFontMap *cfontmap)
{
PangoCairoCoreTextFontMap *cafontmap = PANGO_CAIRO_CORE_TEXT_FONT_MAP (cfontmap);
@@ -64,7 +64,7 @@ static void
cairo_font_map_iface_init (PangoCairoFontMapIface *iface)
{
iface->set_resolution = pango_cairo_core_text_font_map_set_resolution;
- iface->get_resolution = pango_cairo_core_text_font_map_get_resolution;
+ iface->get_resolution = pango_cairo_core_text_font_map_get_resolution_cairo;
iface->get_font_type = pango_cairo_core_text_font_map_get_font_type;
}
@@ -74,13 +74,11 @@ G_DEFINE_TYPE_WITH_CODE (PangoCairoCoreTextFontMap, pango_cairo_core_text_font_m
static PangoCoreTextFont *
pango_cairo_core_text_font_map_create_font (PangoCoreTextFontMap *fontmap,
- PangoContext *context,
- PangoCoreTextFace *face,
- const PangoFontDescription *desc)
+ PangoCoreTextFontKey *key)
{
return _pango_cairo_core_text_font_new (PANGO_CAIRO_CORE_TEXT_FONT_MAP (fontmap),
- context, face, desc);
+ key);
}
static void
@@ -89,6 +87,62 @@ pango_cairo_core_text_font_map_finalize (GObject *object)
G_OBJECT_CLASS (pango_cairo_core_text_font_map_parent_class)->finalize (object);
}
+static double
+pango_cairo_core_text_font_map_get_resolution_core_text (PangoCoreTextFontMap *ctfontmap,
+ PangoContext *context)
+{
+ PangoCairoCoreTextFontMap *cafontmap = PANGO_CAIRO_CORE_TEXT_FONT_MAP (ctfontmap);
+ double dpi;
+
+ if (context)
+ {
+ dpi = pango_cairo_context_get_resolution (context);
+
+ if (dpi <= 0)
+ dpi = cafontmap->dpi;
+ }
+ else
+ dpi = cafontmap->dpi;
+
+ return dpi;
+}
+
+static gconstpointer
+pango_cairo_core_text_font_map_context_key_get (PangoCoreTextFontMap *fontmap G_GNUC_UNUSED,
+ PangoContext *context)
+{
+ return _pango_cairo_context_get_merged_font_options (context);
+}
+
+static gpointer
+pango_cairo_core_text_font_map_context_key_copy (PangoCoreTextFontMap *fontmap G_GNUC_UNUSED,
+ gconstpointer key)
+{
+ return cairo_font_options_copy (key);
+}
+
+static void
+pango_cairo_core_text_font_map_context_key_free (PangoCoreTextFontMap *fontmap G_GNUC_UNUSED,
+ gpointer key)
+{
+ cairo_font_options_destroy (key);
+}
+
+static guint32
+pango_cairo_core_text_font_map_context_key_hash (PangoCoreTextFontMap *fontmap G_GNUC_UNUSED,
+ gconstpointer key)
+{
+ return (guint32)cairo_font_options_hash (key);
+}
+
+static gboolean
+pango_cairo_core_text_font_map_context_key_equal (PangoCoreTextFontMap *fontmap G_GNUC_UNUSED,
+ gconstpointer key_a,
+ gconstpointer key_b)
+{
+ return cairo_font_options_equal (key_a, key_b);
+}
+
static void
pango_cairo_core_text_font_map_class_init (PangoCairoCoreTextFontMapClass *class)
{
@@ -97,7 +151,13 @@ pango_cairo_core_text_font_map_class_init (PangoCairoCoreTextFontMapClass *class
object_class->finalize = pango_cairo_core_text_font_map_finalize;
+ ctfontmapclass->get_resolution = pango_cairo_core_text_font_map_get_resolution_core_text;
ctfontmapclass->create_font = pango_cairo_core_text_font_map_create_font;
+ ctfontmapclass->context_key_get = pango_cairo_core_text_font_map_context_key_get;
+ ctfontmapclass->context_key_copy = pango_cairo_core_text_font_map_context_key_copy;
+ ctfontmapclass->context_key_free = pango_cairo_core_text_font_map_context_key_free;
+ ctfontmapclass->context_key_hash = pango_cairo_core_text_font_map_context_key_hash;
+ ctfontmapclass->context_key_equal = pango_cairo_core_text_font_map_context_key_equal;
}
static void