summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2009-12-22 12:26:12 +0100
committerKristian Rietveld <kris@gtk.org>2009-12-22 12:32:38 +0100
commit0f06d7758bc37a4942342d2c17a88944cbc88adb (patch)
treefd16c312793da79c5d92e850faea92ac799bebf6
parentc39acaa75e118261838f74ce568c23f6643f9352 (diff)
downloadpango-0f06d7758bc37a4942342d2c17a88944cbc88adb.tar.gz
Revert usage of CoreText in ATSUI backend
Next to CGFontRef we also store an ATSFontRef now. This required the addition of the public for backends function pango_atsui_font_get_atsfont(). I have marked this call to be available starting version 1.27, as Pango is now in the midst of the 1.26 series. Since we now store the ATSFontRef next to CGFontRef, we can continue to make use of the ATS API in pango_cairo_atsui_font_create_metrics_for_context(). The CoreText calls have been removed. Both Tiger and earlier, and Leopard and later machines will now use the ATS API. It is well known that the ATS API has been deprecated in Leopard. In the near future a brand-new CoreText backend has to be written (from scratch) that should be installed and used on Macs running Leopard and later. This patch has been tested on 32-bit Tiger and 64-bit Snow Leopard and found to be functioning correctly. The build should now work again fine on Tiger machines, as it has been broken since the introduction of the CoreText calls.
-rw-r--r--pango/pangoatsui-private.h2
-rw-r--r--pango/pangoatsui.c30
-rw-r--r--pango/pangoatsui.h3
-rw-r--r--pango/pangocairo-atsuifont.c23
4 files changed, 44 insertions, 14 deletions
diff --git a/pango/pangoatsui-private.h b/pango/pangoatsui-private.h
index 8c734f00..a5ab0cb7 100644
--- a/pango/pangoatsui-private.h
+++ b/pango/pangoatsui-private.h
@@ -95,6 +95,8 @@ void _pango_atsui_font_set_context_key (PangoATSUIFont
gpointer context_key);
void _pango_atsui_font_set_cgfont (PangoATSUIFont *font,
CGFontRef font_id);
+void _pango_atsui_font_set_atsfont (PangoATSUIFont *font,
+ ATSFontRef font_ref);
G_END_DECLS
diff --git a/pango/pangoatsui.c b/pango/pangoatsui.c
index 6aa970ed..e8029559 100644
--- a/pango/pangoatsui.c
+++ b/pango/pangoatsui.c
@@ -33,6 +33,7 @@ struct _PangoATSUIFontPrivate
gpointer context_key;
CGFontRef font_id;
+ ATSFontRef font_ref;
PangoFontMap *fontmap;
};
@@ -177,13 +178,22 @@ _pango_atsui_font_set_context_key (PangoATSUIFont *afont,
void
_pango_atsui_font_set_cgfont (PangoATSUIFont *font,
- CGFontRef font_id)
+ CGFontRef font_id)
{
PangoATSUIFontPrivate *priv = font->priv;
priv->font_id = font_id;
}
+void
+_pango_atsui_font_set_atsfont (PangoATSUIFont *font,
+ ATSFontRef font_ref)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ priv->font_ref = font_ref;
+}
+
/**
* pango_atsui_font_get_cgfont:
* @font: A #PangoATSUIFont
@@ -201,3 +211,21 @@ pango_atsui_font_get_cgfont (PangoATSUIFont *font)
return priv->font_id;
}
+
+/**
+ * pango_atsui_font_get_atsfont:
+ * @font: A #PangoATSUIFont
+ *
+ * Returns the ATSFontRef of a font.
+ *
+ * Return value: the ATSFontRef associated to @font.
+ *
+ * Since: 1.27
+ */
+ATSFontRef
+pango_atsui_font_get_atsfont (PangoATSUIFont *font)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ return priv->font_ref;
+}
diff --git a/pango/pangoatsui.h b/pango/pangoatsui.h
index 12db6de3..3ca558e2 100644
--- a/pango/pangoatsui.h
+++ b/pango/pangoatsui.h
@@ -68,7 +68,8 @@ struct _PangoATSUIFontClass
#endif /* PANGO_ENABLE_BACKEND */
-CGFontRef pango_atsui_font_get_cgfont (PangoATSUIFont *font);
+CGFontRef pango_atsui_font_get_cgfont (PangoATSUIFont *font);
+ATSFontRef pango_atsui_font_get_atsfont (PangoATSUIFont *font);
#endif /* PANGO_ENABLE_ENGINE || PANGO_ENABLE_BACKEND */
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c
index 91391e7e..057cc76c 100644
--- a/pango/pangocairo-atsuifont.c
+++ b/pango/pangocairo-atsuifont.c
@@ -119,8 +119,8 @@ pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
{
PangoCairoATSUIFont *cafont = (PangoCairoATSUIFont *) font;
PangoATSUIFont *afont = (PangoATSUIFont *) font;
- CGFontRef cg_font;
- CTFontRef ct_font;
+ ATSFontRef ats_font;
+ ATSFontMetrics ats_metrics;
PangoFontMetrics *metrics;
PangoFontDescription *font_desc;
PangoLayout *layout;
@@ -128,19 +128,19 @@ pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
PangoLanguage *language = pango_context_get_language (context);
const char *sample_str = pango_language_get_sample_string (language);
- cg_font = pango_atsui_font_get_cgfont (afont);
- ct_font = CTFontCreateWithGraphicsFont(cg_font, cafont->size, NULL, NULL);
-
metrics = pango_font_metrics_new ();
- metrics->ascent = CTFontGetAscent(ct_font) * PANGO_SCALE;
- metrics->descent = CTFontGetDescent(ct_font) * PANGO_SCALE;
+ ats_font = pango_atsui_font_get_atsfont (afont);
+ ATSFontGetHorizontalMetrics (ats_font, kATSOptionFlagsDefault, &ats_metrics);
+
+ metrics->ascent = ats_metrics.ascent * cafont->size * PANGO_SCALE;
+ metrics->descent = -ats_metrics.descent * cafont->size * PANGO_SCALE;
- metrics->underline_position = CTFontGetUnderlinePosition(ct_font) * PANGO_SCALE;
- metrics->underline_thickness = CTFontGetUnderlineThickness(ct_font) * PANGO_SCALE;
+ metrics->underline_position = ats_metrics.underlinePosition * cafont->size * PANGO_SCALE;
+ metrics->underline_thickness = ats_metrics.underlineThickness * cafont->size * PANGO_SCALE;
metrics->strikethrough_position = metrics->ascent / 3;
- metrics->strikethrough_thickness = metrics->underline_thickness * PANGO_SCALE;
+ metrics->strikethrough_thickness = ats_metrics.underlineThickness * cafont->size * PANGO_SCALE;
layout = pango_layout_new (context);
font_desc = pango_font_describe_with_absolute_size ((PangoFont *) font);
@@ -155,8 +155,6 @@ pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
pango_font_description_free (font_desc);
g_object_unref (layout);
-
-
return metrics;
}
@@ -270,6 +268,7 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
size = (double) pango_font_description_get_size (desc) / PANGO_SCALE;
_pango_atsui_font_set_cgfont (afont, font_id);
+ _pango_atsui_font_set_atsfont (afont, font_ref);
if (context)
{