[pango] Revert usage of CoreText in ATSUI backend
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pango] Revert usage of CoreText in ATSUI backend
- Date: Tue, 22 Dec 2009 11:35:19 +0000 (UTC)
commit 0f06d7758bc37a4942342d2c17a88944cbc88adb
Author: Kristian Rietveld <kris gtk org>
Date: Tue Dec 22 12:26:12 2009 +0100
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.
pango/pangoatsui-private.h | 2 ++
pango/pangoatsui.c | 30 +++++++++++++++++++++++++++++-
pango/pangoatsui.h | 3 ++-
pango/pangocairo-atsuifont.c | 23 +++++++++++------------
4 files changed, 44 insertions(+), 14 deletions(-)
---
diff --git a/pango/pangoatsui-private.h b/pango/pangoatsui-private.h
index 8c734f0..a5ab0cb 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 6aa970e..e802955 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 12db6de..3ca558e 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 91391e7..057cc76 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]