diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2005-12-12 23:25:47 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2005-12-12 23:25:47 +0000 |
commit | 28d0dfac2179120c4b7b2fb3e185b16926097563 (patch) | |
tree | 3bfe60e15a3a3d14325e33dcc81a4dcd632f00bd | |
parent | da3a78d96e54a69b64fca8a0ccd182c2e06ca623 (diff) | |
download | pango-28d0dfac2179120c4b7b2fb3e185b16926097563.tar.gz |
Fix bug #323540.
2005-12-12 Behdad Esfahbod <behdad@gnome.org>
Fix bug #323540.
* pangofc-fontmap.c (get_scaled_size): The logic in there is moved
and renamed into pango-utils.
* pango/pango-types.h,
* pango/pango-utils.c (pango_matrix_get_font_scale_factor):
New function.
* pango/pangocairo-fcfont.c (get_font_size): Divide pixel-size by
matrix font-scale-factor, since pixel-size is scaled.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | pango/pango-types.h | 1 | ||||
-rw-r--r-- | pango/pango-utils.c | 52 | ||||
-rw-r--r-- | pango/pangocairo-fcfont.c | 11 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 42 |
5 files changed, 77 insertions, 43 deletions
@@ -1,3 +1,17 @@ +2005-12-12 Behdad Esfahbod <behdad@gnome.org> + + Fix bug #323540. + + * pangofc-fontmap.c (get_scaled_size): The logic in there is moved + and renamed into pango-utils. + + * pango/pango-types.h, + * pango/pango-utils.c (pango_matrix_get_font_scale_factor): + New function. + + * pango/pangocairo-fcfont.c (get_font_size): Divide pixel-size by + matrix font-scale-factor, since pixel-size is scaled. + 2005-12-11 Behdad Esfahbod <behdad@gnome.org> * configure.in: Undo last change. 2.9.1 has the revised diff --git a/pango/pango-types.h b/pango/pango-types.h index 1e3a0305..e01b8911 100644 --- a/pango/pango-types.h +++ b/pango/pango-types.h @@ -123,6 +123,7 @@ void pango_matrix_rotate (PangoMatrix *matrix, double degrees); void pango_matrix_concat (PangoMatrix *matrix, const PangoMatrix *new_matrix); +double pango_matrix_get_font_scale_factor (PangoMatrix *matrix); #define PANGO_SCALE 1024 #define PANGO_PIXELS(d) (((int)(d) + 512) >> 10) diff --git a/pango/pango-utils.c b/pango/pango-utils.c index c252a63a..c4af168e 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -1154,6 +1154,58 @@ pango_matrix_concat (PangoMatrix *matrix, matrix->y0 = tmp.yx * new_matrix->y0 + tmp.yy * new_matrix->y0 + tmp.y0; } +/** + * pango_matrix_get_font_scale_factor: + * @matrix: a #PangoMatrix, may be %NULL + * + * Return value: the scale factor of @matrix on the height of the font. + * That is, the scale factor in the direction perpendicular to the + * vector that the X coordinate is mapped to, or 1.0 if @matrix is %NULL. + * + * Since: 1.12 + **/ +double +pango_matrix_get_font_scale_factor (PangoMatrix *matrix) +{ +/* + * Based on cairo-matrix.c:_cairo_matrix_compute_scale_factors() + * + * Copyright 2005, Keith Packard + */ + double det; + + if (!matrix) + return 1.0; + + det = matrix->xx * matrix->yy - matrix->yx * matrix->xy; + + if (det == 0) + { + return 0.0; + } + else + { + double x = matrix->xx; + double y = matrix->yx; + double major, minor; + + major = sqrt (x*x + y*y); + + /* + * ignore mirroring + */ + if (det < 0) + det = - det; + + if (major) + minor = det / major; + else + minor = 0.0; + + return minor; + } +} + static const char canon_map[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c index ec7a932f..c6aeabe5 100644 --- a/pango/pangocairo-fcfont.c +++ b/pango/pangocairo-fcfont.c @@ -536,7 +536,8 @@ static double get_font_size (PangoCairoFcFontMap *cffontmap, PangoContext *context, const PangoFontDescription *desc, - FcPattern *pattern) + FcPattern *pattern, + PangoMatrix *matrix) { double size; @@ -554,7 +555,7 @@ get_font_size (PangoCairoFcFontMap *cffontmap, */ if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch) - return size * PANGO_SCALE; + return size * PANGO_SCALE / pango_matrix_get_font_scale_factor (matrix); /* Just in case FC_PIXEL_SIZE got unset between pango_fc_make_pattern() * and here. @@ -603,12 +604,13 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap, else cairo_matrix_init_identity (&cffont->font_matrix); - size = get_font_size (cffontmap, context, desc, pattern); + pango_ctm = pango_context_get_matrix (context); + + size = get_font_size (cffontmap, context, desc, pattern, pango_ctm); cairo_matrix_scale (&cffont->font_matrix, size / PANGO_SCALE, size / PANGO_SCALE); - pango_ctm = pango_context_get_matrix (context); if (pango_ctm) cairo_matrix_init (&cffont->ctm, pango_ctm->xx, @@ -619,6 +621,7 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap, else cairo_matrix_init_identity (&cffont->ctm); + cffont->options = cairo_font_options_copy (_pango_cairo_context_get_merged_font_options (context)); return PANGO_FC_FONT (cffont); diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 0e13224e..858939d7 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -1011,44 +1011,6 @@ get_unscaled_size (PangoFcFontMap *fcfontmap, } } -/* - * Based on cairo-matrix.c:_cairo_matrix_compute_scale_factors() - * - * Copyright 2005, Keith Packard - */ -static double -get_scaled_size (FontsetHashKey *key) -{ - PangoMatrix *matrix = &key->matrix; - double det = matrix->xx * matrix->yy - matrix->yx * matrix->xy; - - if (det == 0) - { - return 0.0; - } - else - { - double x = matrix->xx; - double y = matrix->yx; - double major, minor; - - major = sqrt (x*x + y*y); - - /* - * ignore mirroring - */ - if (det < 0) - det = - det; - - if (major) - minor = det / major; - else - minor = 0.0; - - return minor * key->size / 1024.; - } -} - static PangoFcPatternSet * pango_fc_font_map_get_patterns (PangoFontMap *fontmap, PangoContext *context, @@ -1083,8 +1045,10 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap, if (patterns == NULL) { + double scale_factor = pango_matrix_get_font_scale_factor (&key.matrix); + double scaled_size = key.size * scale_factor / PANGO_SCALE; pattern = pango_fc_make_pattern (desc, language, - get_scaled_size (&key), + scaled_size, pango_fc_font_map_get_resolution (fcfontmap, context)); pango_fc_default_substitute (fcfontmap, context, pattern); |