summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pangocairo-coretextfont.c17
-rw-r--r--pango/pangocairo-coretextfontmap.c2
-rw-r--r--pango/pangocoretext-fontmap.c15
-rw-r--r--pango/pangocoretext-private.h2
-rw-r--r--pango/pangocoretext.c5
-rw-r--r--tests/test-layout.c11
6 files changed, 33 insertions, 19 deletions
diff --git a/pango/pangocairo-coretextfont.c b/pango/pangocairo-coretextfont.c
index c07f1c77..9dc33447 100644
--- a/pango/pangocairo-coretextfont.c
+++ b/pango/pangocairo-coretextfont.c
@@ -36,6 +36,7 @@ struct _PangoCairoCoreTextFont
{
PangoCoreTextFont font;
PangoCairoFontPrivate cf_priv;
+ int abs_size;
};
struct _PangoCairoCoreTextFontClass
@@ -162,6 +163,17 @@ pango_cairo_core_text_font_create_base_metrics_for_context (PangoCairoFont *font
return metrics;
}
+static PangoFontDescription *
+pango_cairo_core_text_font_describe_absolute (PangoFont *font)
+{
+ PangoCairoCoreTextFont *cafont = (PangoCairoCoreTextFont *)font;
+ PangoFontDescription *desc = pango_font_describe (font);
+
+ pango_font_description_set_absolute_size (desc, cafont->abs_size);
+
+ return desc;
+}
+
static void
pango_cairo_core_text_font_finalize (GObject *object)
{
@@ -179,9 +191,10 @@ pango_cairo_core_text_font_class_init (PangoCairoCoreTextFontClass *class)
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
object_class->finalize = pango_cairo_core_text_font_finalize;
-
+ /* font_class->describe defined by parent class PangoCoreTextFont. */
font_class->get_glyph_extents = pango_cairo_core_text_font_get_glyph_extents;
font_class->get_metrics = _pango_cairo_font_get_metrics;
+ font_class->describe_absolute = pango_cairo_core_text_font_describe_absolute;
}
static void
@@ -219,6 +232,8 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap,
cafont = g_object_new (PANGO_TYPE_CAIRO_CORE_TEXT_FONT, NULL);
cfont = PANGO_CORE_TEXT_FONT (cafont);
+ cafont->abs_size = pango_core_text_font_key_get_size (key);
+
_pango_core_text_font_set_ctfont (cfont, font_ref);
if (synthesize_italic)
diff --git a/pango/pangocairo-coretextfontmap.c b/pango/pangocairo-coretextfontmap.c
index ba5dcec0..5054b7a8 100644
--- a/pango/pangocairo-coretextfontmap.c
+++ b/pango/pangocairo-coretextfontmap.c
@@ -186,5 +186,5 @@ static void
pango_cairo_core_text_font_map_init (PangoCairoCoreTextFontMap *cafontmap)
{
cafontmap->serial = 1;
- cafontmap->dpi = 72.;
+ cafontmap->dpi = 96.;
}
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 4d101847..c5cacab4 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -806,6 +806,7 @@ get_context_matrix (PangoContext *context,
/*
* Helper functions for PangoCoreTextFontsetKey
*/
+static const double ppi = 72.0; /* typographic points per inch */
static double
pango_core_text_font_map_get_resolution (PangoCoreTextFontMap *fontmap,
@@ -817,7 +818,7 @@ pango_core_text_font_map_get_resolution (PangoCoreTextFontMap *fontmap,
/* FIXME: acquire DPI from CoreText using some deafault font */
g_warning ("FIXME: returning default DPI");
- return 72.0;
+ return ppi;
}
static int
@@ -826,8 +827,16 @@ get_scaled_size (PangoCoreTextFontMap *fontmap,
const PangoFontDescription *desc)
{
double size = pango_font_description_get_size (desc);
-
- return .5 + pango_matrix_get_font_scale_factor (pango_context_get_matrix (context)) * size;
+ PangoMatrix *matrix = pango_context_get_matrix (context);
+ double scale_factor = pango_matrix_get_font_scale_factor (matrix);
+
+ if (!pango_font_description_get_size_is_absolute(desc))
+ {
+ double dpi = pango_core_text_font_map_get_resolution (fontmap, context);
+ size *= (dpi/ppi);
+ }
+
+ return .5 + scale_factor * size;
}
diff --git a/pango/pangocoretext-private.h b/pango/pangocoretext-private.h
index c6c642cd..76eb1ebc 100644
--- a/pango/pangocoretext-private.h
+++ b/pango/pangocoretext-private.h
@@ -99,6 +99,8 @@ void _pango_core_text_font_set_ctfont (PangoCoreTextF
PangoFontDescription *_pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef desc);
_PANGO_EXTERN
+int pango_core_text_font_key_get_size (const PangoCoreTextFontKey *key);
+_PANGO_EXTERN
int pango_core_text_font_key_get_size (const PangoCoreTextFontKey *key);
_PANGO_EXTERN
double pango_core_text_font_key_get_resolution (const PangoCoreTextFontKey *key);
diff --git a/pango/pangocoretext.c b/pango/pangocoretext.c
index 8cba1aae..2aa1810a 100644
--- a/pango/pangocoretext.c
+++ b/pango/pangocoretext.c
@@ -225,10 +225,7 @@ pango_core_text_font_class_init (PangoCoreTextFontClass *class)
object_class->finalize = pango_core_text_font_finalize;
font_class->describe = pango_core_text_font_describe;
- /* In CoreText the device unit is points so describe_absoulute and
- * describe are the same.
- */
- font_class->describe_absolute = pango_core_text_font_describe;
+ /* font_class->describe_absolute is left virtual for PangoCairoCoreTextFont. */
font_class->get_coverage = pango_core_text_font_get_coverage;
font_class->find_shaper = pango_core_text_font_find_shaper;
font_class->get_font_map = pango_core_text_font_get_font_map;
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 07ca6909..4bce4439 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -265,18 +265,9 @@ test_file (const gchar *filename, GString *string)
parse_params (contents, &width, &ellipsize_at, &ellipsize, &wrap);
layout = pango_layout_new (context);
-/* The layout tests are predicated on scaling fonts to 90 DPI, but
- * Apple's font APIs (CoreText and CoreGraphics) don't work that way
- * so we have to use a bigger font to get the results to agree with
- * the expected values.
- */
-#if defined (HAVE_CORE_TEXT) && defined (HAVE_CAIRO_QUARTZ)
- desc = pango_font_description_from_string ("Cantarell 14.5");
-#else
desc = pango_font_description_from_string ("Cantarell 11");
-#endif
pango_layout_set_font_description (layout, desc);
- pango_font_description_free (desc);
+ pango_font_description_free (desc);
pango_layout_set_markup (layout, markup, length);
g_free (contents);