summaryrefslogtreecommitdiff
path: root/pango/pangocairo-atsuifont.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2010-03-21 21:23:56 +0100
committerKristian Rietveld <kris@gtk.org>2010-03-21 21:27:34 +0100
commitf4201009d192300442e76d25a83c0dab8022d0d6 (patch)
tree297d953ca41d3e9d01a53f8e5e77ab15042bc62c /pango/pangocairo-atsuifont.c
parent7e2abeb19c4b0760d60ec8b388c9f98075700004 (diff)
downloadpango-f4201009d192300442e76d25a83c0dab8022d0d6.tar.gz
Bug 611033 - Layout using ATSUI fontmap treats absolute font sizes a...
pango_atsui_font_map_load_font() has been corrected to take into account whether the size retrieved from the given font description is absolute when setting this size again on best_description. _pango_cairo_atsui_font_new() has been cleaned up with regard to size conversion and usage. The code now properly takes the absolute property into account and is more clear.
Diffstat (limited to 'pango/pangocairo-atsuifont.c')
-rw-r--r--pango/pangocairo-atsuifont.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c
index 057cc76c..3abaffff 100644
--- a/pango/pangocairo-atsuifont.c
+++ b/pango/pangocairo-atsuifont.c
@@ -36,8 +36,7 @@ struct _PangoCairoATSUIFont
PangoATSUIFont font;
PangoCairoFontPrivate cf_priv;
- double size;
- int absolute_size;
+ double size; /* Absolute size */
};
struct _PangoCairoATSUIFontClass
@@ -166,7 +165,8 @@ pango_cairo_atsui_font_describe_absolute (PangoFont *font)
PangoCairoATSUIFont *cafont = (PangoCairoATSUIFont *) font;
desc = pango_font_describe (font);
- pango_font_description_set_absolute_size (desc, cafont->absolute_size);
+ pango_font_description_set_absolute_size (desc,
+ cafont->size * PANGO_SCALE);
return desc;
}
@@ -212,7 +212,7 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
CFStringRef cfstr;
ATSFontRef font_ref;
CGFontRef font_id;
- double size;
+ double size, abs_size;
double dpi;
double m;
cairo_matrix_t font_matrix;
@@ -224,6 +224,23 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
font_ref = ATSFontFindFromPostScriptName (cfstr, kATSOptionFlagsDefault);
CFRelease (cfstr);
+ abs_size = size = pango_units_to_double (pango_font_description_get_size (desc));
+
+ if (context)
+ {
+ dpi = pango_cairo_context_get_resolution (context);
+
+ if (dpi <= 0)
+ dpi = cafontmap->dpi;
+ }
+ else
+ dpi = cafontmap->dpi;
+
+ if (pango_font_description_get_size_is_absolute (desc))
+ size *= 72. / dpi;
+ else
+ abs_size *= dpi / 72.;
+
/* We synthesize italic in two cases. The first is when
* NSFontManager has handed out a face that it claims has italic but
* it doesn't. The other is when an italic face is requested that
@@ -236,8 +253,6 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
NSString *nsname;
NSFont *nsfont, *converted_font;
- size = (double) pango_font_description_get_size (desc) / PANGO_SCALE;
-
nsname = [NSString stringWithUTF8String:postscript_name];
nsfont = [NSFont fontWithName:nsname size:size];
@@ -266,26 +281,10 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
_pango_atsui_font_set_font_description (afont, desc);
_pango_atsui_font_set_face (afont, face);
- 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)
- {
- dpi = pango_cairo_context_get_resolution (context);
-
- if (dpi <= 0)
- dpi = cafontmap->dpi;
- }
- else
- dpi = cafontmap->dpi;
-
- cafont->absolute_size = pango_font_description_get_size (desc);
-
- if (!pango_font_description_get_size_is_absolute (desc))
- size *= dpi / 72.;
-
- cafont->size = size;
+ cafont->size = abs_size;
/* When synthesizing italics, apply a shear matrix matching what Cocoa
* does. Cairo quartz had transformed text wrong before 1.5.13, stay
@@ -304,7 +303,7 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
else
cairo_matrix_init_identity (&font_matrix);
- cairo_matrix_scale (&font_matrix, size, size);
+ cairo_matrix_scale (&font_matrix, abs_size, abs_size);
_pango_cairo_font_private_initialize (&cafont->cf_priv,
(PangoCairoFont *) cafont,