[pango/coretext: 7/9] Get _pango_cairo_core_text_font_new right
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/coretext: 7/9] Get _pango_cairo_core_text_font_new right
- Date: Sun, 27 Mar 2011 19:52:25 +0000 (UTC)
commit a7b0cde0b8575bb9b9d2a86f6477e11d0412d254
Author: Kristian Rietveld <kris gtk org>
Date: Wed Mar 17 23:01:48 2010 +0100
Get _pango_cairo_core_text_font_new right
pango/pangocairo-coretextfont.c | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/pango/pangocairo-coretextfont.c b/pango/pangocairo-coretextfont.c
index 0f0c404..5948752 100644
--- a/pango/pangocairo-coretextfont.c
+++ b/pango/pangocairo-coretextfont.c
@@ -37,8 +37,7 @@ struct _PangoCairoCoreTextFont
PangoCoreTextFont font;
PangoCairoFontPrivate cf_priv;
- double size;
- int absolute_size;
+ int abs_size;
};
struct _PangoCairoCoreTextFontClass
@@ -172,7 +171,7 @@ pango_cairo_core_text_font_describe_absolute (PangoFont *font)
PangoCairoCoreTextFont *cafont = (PangoCairoCoreTextFont *) font;
desc = pango_font_describe (font);
- pango_font_description_set_absolute_size (desc, cafont->absolute_size);
+ pango_font_description_set_absolute_size (desc, cafont->abs_size);
return desc;
}
@@ -218,14 +217,13 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap,
CFStringRef cfstr;
CTFontRef font_ref;
CGFontRef font_id;
- double size;
+ double size, abs_size;
double dpi;
cairo_matrix_t font_matrix;
postscript_name = _pango_core_text_face_get_postscript_name (face);
- /* Calculate size in points */
- size = (double) pango_font_description_get_size (desc) / PANGO_SCALE;
+ abs_size = size = pango_units_to_double (pango_font_description_get_size (desc));
if (context)
{
@@ -238,8 +236,9 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap,
dpi = cafontmap->dpi;
if (pango_font_description_get_size_is_absolute (desc))
- size *= dpi / 72.;
-
+ size *= 72. / dpi;
+ else
+ abs_size *= dpi / 72.;
cfstr = CFStringCreateWithCString (NULL, postscript_name,
kCFStringEncodingUTF8);
@@ -259,14 +258,9 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap,
_pango_core_text_font_set_font_description (cfont, desc);
_pango_core_text_font_set_face (cfont, face);
- _pango_core_text_font_set_ctfont (cfont, font_ref);
-
- if (pango_font_description_get_size_is_absolute (desc))
- cafont->absolute_size = pango_font_description_get_size (desc);
- else
- cafont->absolute_size = pango_font_description_get_size (desc) * (dpi / 72.);
+ cafont->abs_size = abs_size * PANGO_SCALE;
- cafont->size = size;
+ _pango_core_text_font_set_ctfont (cfont, font_ref);
if (synthesize_italic)
cairo_matrix_init (&font_matrix,
@@ -275,8 +269,9 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap,
0, 0);
else
cairo_matrix_init_identity (&font_matrix);
-
- cairo_matrix_scale (&font_matrix, size, size);
+
+ /* Scale using absolute size */
+ cairo_matrix_scale (&font_matrix, abs_size, abs_size);
_pango_cairo_font_private_initialize (&cafont->cf_priv,
(PangoCairoFont *) cafont,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]