summaryrefslogtreecommitdiff
path: root/pango/pangocairo-fcfont.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-07-21 13:55:19 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-07-21 13:55:19 +0000
commit6f1def024e5c0c0f75c992c26dded3c192aa455c (patch)
tree2ef6a8974d23d58dff51473c9691ab5785bdc4c6 /pango/pangocairo-fcfont.c
parent07085142899378e7b5c0ad8e3fdd35ea2a941b1a (diff)
downloadpango-6f1def024e5c0c0f75c992c26dded3c192aa455c.tar.gz
Rework handling of context-specific options: drop get_render_key() and add
2005-07-19 Owen Taylor <otaylor@redhat.com> * pango/pango-fcfontmap.[ch]: Rework handling of context-specific options: drop get_render_key() and add a opaque "context key" (get_context_key() and friends). Also add a function to get the resolution. * pango/pango-fcfontmap.c pango/pangofc-font.h: - Move the 'lang' into the fontset key lookup and get rid of the funky list-of-hash-tables - Make lookups of fontsets and fonts dependent on the context key for the context. - Simplify the pattern/fontset caching to have one finite-size cache rather than an infinite first-level and a finite-size second level. * pango/pangocairo.h pango/pangocairo-private.h pango/pangocairo-fontmap.c: Add pango_cairo_context_get/set_resolution(), pango_cairo_context_set/get_font_options to allow controlling the resolution and font rendering options for a specific PangoContext. * pango/pangocairo-fcfont.c pango/pangocairo-fcfontmap pango/pangocairo-win32font.c: Implement resolution and font options handling adapt to related Cairo changes. * docs/pango-sections.txt docs/Makefile.am pango/pangowin32.c: Doc updates and build fixes. * pango/pangofc-fontmap.c (pango_fc_make_pattern): Create patterns with FC_SIZE as well as FC_PIXEL_SIZE to work around a libgnomeprint bug. (#309477)
Diffstat (limited to 'pango/pangocairo-fcfont.c')
-rw-r--r--pango/pangocairo-fcfont.c110
1 files changed, 20 insertions, 90 deletions
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 5b06be81..cc7b3136 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -51,6 +51,7 @@ struct _PangoCairoFcFont
cairo_scaled_font_t *scaled_font;
cairo_matrix_t font_matrix;
cairo_matrix_t ctm;
+ cairo_font_options_t *options;
GHashTable *glyph_info;
};
@@ -104,9 +105,11 @@ pango_cairo_fc_font_get_scaled_font (PangoCairoFont *font)
cairo_font_face_t *font_face;
font_face = pango_cairo_fc_font_get_font_face (font);
+
cffont->scaled_font = cairo_scaled_font_create (font_face,
&cffont->font_matrix,
- &cffont->ctm);
+ &cffont->ctm,
+ cffont->options);
/* Failure of the above should only occur for out of memory,
* we can't proceed at that point
@@ -151,6 +154,8 @@ pango_cairo_fc_font_finalize (GObject *object)
cairo_font_face_destroy (cffont->font_face);
if (cffont->scaled_font)
cairo_scaled_font_destroy (cffont->scaled_font);
+ if (cffont->options)
+ cairo_font_options_destroy (cffont->options);
g_hash_table_destroy (cffont->glyph_info);
@@ -308,96 +313,22 @@ pango_cairo_fc_font_init (PangoCairoFcFont *cffont)
********************/
static double
-transformed_length (const PangoMatrix *matrix,
- double dx,
- double dy)
+get_font_size (PangoCairoFcFontMap *cffontmap,
+ PangoContext *context,
+ const PangoFontDescription *desc)
{
- double tx = (dx * matrix->xx + dy * matrix->xy);
- double ty = (dx * matrix->yx + dy * matrix->yy);
-
- return sqrt (tx * tx + ty * ty);
-}
-
-/* Adapted from cairo_matrix.c:_cairo_matrix_compute_scale_factors.
- */
-static void
-compute_scale_factors (const PangoMatrix *matrix,
- double *sx,
- double *sy)
-{
- double det;
-
- det = matrix->xx * matrix->yy - matrix->xy * matrix->xx;
-
- if (det == 0)
- *sx = *sy = 0;
- else
- {
- double major, minor;
- major = transformed_length (matrix, 1, 0);
- /*
- * ignore mirroring
- */
- if (det < 0)
- det = -det;
- if (major)
- minor = det / major;
- else
- minor = 0.0;
-
- *sx = major;
- *sy = minor;
- }
-}
-
-gboolean
-_pango_cairo_fc_get_render_key (PangoCairoFcFontMap *cffontmap,
- PangoContext *context,
- const PangoFontDescription *desc,
- int *xsize,
- int *ysize,
- guint *flags)
-{
- const PangoMatrix *matrix;
- double xscale, yscale;
- double size;
-
- matrix = pango_context_get_matrix (context);
- if (matrix)
- {
- compute_scale_factors (matrix, &xscale, &yscale);
- }
- else
- {
- xscale = 1.;
- yscale = 1.;
- }
-
if (pango_font_description_get_size_is_absolute (desc))
- size = pango_font_description_get_size (desc);
+ return pango_font_description_get_size (desc);
else
- size = cffontmap->dpi * pango_font_description_get_size (desc) / 72.;
-
- *xsize = (int) (xscale * size + 0.5);
- *ysize = (int) (xscale * size + 0.5);
-
- *flags = pango_cairo_context_get_hinting (context);
-
- if (matrix)
{
- if (xscale == 0. && yscale == 0.)
- return FALSE;
- else
- {
- return (matrix->yx / xscale < 1. / 65536. &&
- matrix->xy / yscale < 1. / 65536. &&
- matrix->xx > 0 &&
- matrix->yy > 0);
- }
+ double dpi = pango_cairo_context_get_resolution (context);
+
+ if (dpi <= 0)
+ dpi = cffontmap->dpi;
+
+ return dpi * pango_font_description_get_size (desc) / 72.;
}
- else
- return TRUE;
}
PangoFcFont *
@@ -430,11 +361,8 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap,
}
else
cairo_matrix_init_identity (&cffont->font_matrix);
-
- if (pango_font_description_get_size_is_absolute (desc))
- size = pango_font_description_get_size (desc);
- else
- size = cffontmap->dpi * pango_font_description_get_size (desc) / 72.;
+
+ size = get_font_size (cffontmap, context, desc);
cairo_matrix_scale (&cffont->font_matrix,
size / PANGO_SCALE, size / PANGO_SCALE);
@@ -450,5 +378,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);
}