Commit 0f06d775 authored by Kristian Rietveld's avatar Kristian Rietveld
Browse files

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.
parent c39acaa7
......@@ -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
......
......@@ -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;
}
......@@ -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 */
......
......@@ -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)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment