diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-07-21 13:55:19 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-07-21 13:55:19 +0000 |
commit | 6f1def024e5c0c0f75c992c26dded3c192aa455c (patch) | |
tree | 2ef6a8974d23d58dff51473c9691ab5785bdc4c6 /pango/pangocairo-fcfontmap.c | |
parent | 07085142899378e7b5c0ad8e3fdd35ea2a941b1a (diff) | |
download | pango-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-fcfontmap.c')
-rw-r--r-- | pango/pangocairo-fcfontmap.c | 88 |
1 files changed, 68 insertions, 20 deletions
diff --git a/pango/pangocairo-fcfontmap.c b/pango/pangocairo-fcfontmap.c index e032c9d5..15752e2a 100644 --- a/pango/pangocairo-fcfontmap.c +++ b/pango/pangocairo-fcfontmap.c @@ -18,6 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include <cairo-ft.h> #include "pangofc-fontmap.h" #include "pangocairo.h" @@ -43,7 +44,7 @@ pango_cairo_fc_font_map_set_resolution (PangoCairoFontMap *cfontmap, } static double -pango_cairo_fc_font_map_get_resolution (PangoCairoFontMap *cfontmap) +pango_cairo_fc_font_map_get_resolution_cairo (PangoCairoFontMap *cfontmap) { PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (cfontmap); @@ -65,7 +66,7 @@ static void cairo_font_map_iface_init (PangoCairoFontMapIface *iface) { iface->set_resolution = pango_cairo_fc_font_map_set_resolution; - iface->get_resolution = pango_cairo_fc_font_map_get_resolution; + iface->get_resolution = pango_cairo_fc_font_map_get_resolution_cairo; iface->get_renderer = pango_cairo_fc_font_map_get_renderer; } @@ -90,32 +91,71 @@ pango_cairo_fc_font_map_context_substitute (PangoFcFontMap *fcfontmap, PangoContext *context, FcPattern *pattern) { - PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (fcfontmap); - FcValue v; - FcConfigSubstitute (NULL, pattern, FcMatchPattern); - if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch) - FcPatternAddDouble (pattern, FC_DPI, cffontmap->dpi); - - if (!pango_cairo_context_get_hinting (context)) - FcPatternAddBool (pattern, FC_HINTING, FcFalse); + cairo_ft_font_options_substitute (_pango_cairo_context_get_merged_font_options (context), + pattern); FcDefaultSubstitute (pattern); } -static gboolean -pango_cairo_fc_font_map_get_render_key (PangoFcFontMap *fcfontmap, - PangoContext *context, - const PangoFontDescription *desc, - int *xsize, - int *ysize, - guint *flags) +static double +pango_cairo_fc_font_map_get_resolution_fc (PangoFcFontMap *fcfontmap, + PangoContext *context) +{ + PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (fcfontmap); + double dpi; + + if (context) + { + dpi = pango_cairo_context_get_resolution (context); + + if (dpi <= 0) + dpi = cffontmap->dpi; + } + else + dpi = cffontmap->dpi; + + return dpi; +} + +static gconstpointer +pango_cairo_fc_font_map_context_key_get (PangoFcFontMap *fcfontmap, + PangoContext *context) +{ + return _pango_cairo_context_get_merged_font_options (context); +} + +static gpointer +pango_cairo_fc_font_map_context_key_copy (PangoFcFontMap *fcfontmap, + gconstpointer key) +{ + return cairo_font_options_copy (key); +} + +static void +pango_cairo_fc_font_map_context_key_free (PangoFcFontMap *fcfontmap, + gpointer key) +{ + cairo_font_options_destroy (key); +} + + +static guint32 +pango_cairo_fc_font_map_context_key_hash (PangoFcFontMap *fcfontmap, + gconstpointer key) { - return _pango_cairo_fc_get_render_key (PANGO_CAIRO_FC_FONT_MAP (fcfontmap), - context, desc, xsize, ysize, flags); + return (guint32)cairo_font_options_hash (key); } +static gboolean +pango_cairo_fc_font_map_context_key_equal (PangoFcFontMap *fcfontmap, + gconstpointer key_a, + gconstpointer key_b) +{ + return cairo_font_options_equal (key_a, key_b); +} + static PangoFcFont * pango_cairo_fc_font_map_create_font (PangoFcFontMap *fcfontmap, PangoContext *context, @@ -133,8 +173,16 @@ pango_cairo_fc_font_map_class_init (PangoCairoFcFontMapClass *class) PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class); gobject_class->finalize = pango_cairo_fc_font_map_finalize; + fcfontmap_class->context_substitute = pango_cairo_fc_font_map_context_substitute; - fcfontmap_class->get_render_key = pango_cairo_fc_font_map_get_render_key; + fcfontmap_class->get_resolution = pango_cairo_fc_font_map_get_resolution_fc; + + fcfontmap_class->context_key_get = pango_cairo_fc_font_map_context_key_get; + fcfontmap_class->context_key_copy = pango_cairo_fc_font_map_context_key_copy; + fcfontmap_class->context_key_free = pango_cairo_fc_font_map_context_key_free; + fcfontmap_class->context_key_hash = pango_cairo_fc_font_map_context_key_hash; + fcfontmap_class->context_key_equal = pango_cairo_fc_font_map_context_key_equal; + fcfontmap_class->create_font = pango_cairo_fc_font_map_create_font; } |