On Thu, 2007-12-06 at 19:01 -0800, Karl Reis wrote: > I'm trying to find a way to scale fonts linearly. As far as I can tell, the > way to do it is to use a freetype font and turn hinting off. Using the API, > I tried to pull some code together that would try to do that, but > unfortunately, the font is still scaling non-linearly.
You're on the right track. All font backends are supposed to support that but I'm not sure how non-freetype ones handle it right now. > cairo_font_options_t *options; > > PangoFontMap *fm; > > PangoContext *context; > > > > fm = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); > > pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP(fm), 96); > > context = pango_cairo_font_map_create_context > (PANGO_CAIRO_FONT_MAP(fm)); > > > > options = cairo_font_options_create (); > > cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE); > > pango_cairo_context_set_font_options (context, options); > > During runtime I receive the following error: > > Pango-CRITICAL **: pango_cairo_font_map_create_context: assertion > `PANGO_IS_CAIRO_FONT_MAP (fontmap)' failed What's your platform? This pretty much means that pango_cairo_font_map_new_for_font_type() returned NULL, which according to the docs, means that pango detected at compile time that your cairo isn't compiled with the freetype font backend enabled. Most of the time you just need pango_cairo_font_map_get_default(). > Specifically, how can I use a PangoCairoFontMap in such a scenario? The > documentation states that I should be getting such a structure upon calling > pango_cairo_font_map_new_for_font_type. However, all I get is a > PangoFontMap. I'm not sure what the difference is between these two > structures and/or if one can be type cast onto another. PangoCairoFontMap is a PangoFontMap. Think object-oriented programming. > More generally, how can I scale fonts linearly using the Pango, Cairo API? You are setting hint_style. That affects rendering of the glyphs but not their extents. You should turn metrics hinting off for that. cairo_font_options_set_hint_metrics(). > Tutorials, guides would be very helpful. A tutorial is in the works right now, but far from complete: http://bugzilla.gnome.org/show_bug.cgi?id=502222 > Thanks, > > > > Karl Have fun with pangocairo! -- behdad http://behdad.org/ ...very few phenomena can pull someone out of Deep Hack Mode, with two noted exceptions: being struck by lightning, or worse, your *computer* being struck by lightning. -- Matt Welsh _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list