Thank you for your excellent reply! I modified the code per your suggestions and it worked perfectly. Here is the full snippet of code for anyone else who might find this useful:
cairo_font_options_t *options; cairo_t *cr; PangoFontMap *fm; PangoContext *context; PangoLayout *layout; PangoFontDescription *pfd; cr = gdk_cairo_create (pixmap); fm = pango_cairo_font_map_get_default (); 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); cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); pango_cairo_context_set_font_options (context, options); layout = pango_layout_new (context); pango_layout_set_text (layout,text_string,-1); pfd = pango_font_description_new (); pango_font_description_set_size (pfd,12*PANGO_SCALE*scale_factor); pango_layout_set_font_description (layout,pfd); cairo_move_to (cr, x, y); pango_cairo_show_layout (cr,layout); So, I guess I ended up using some default font which I presume is not a freetype font. But, it worked. To answer your question below, I did check for NULL and indeed the font map created was NULL.... which means as you indicate that the cairo I have is not compiled with the freetype backend enabled. For what it's worth, I also tried it with the "TOY" font and I got the same error. I am running on mingw windows with the binaries derived straight from Tor's page. Thanks again for your help, Karl > -----Original Message----- > From: Behdad Esfahbod [mailto:[EMAIL PROTECTED] On Behalf Of > Behdad Esfahbod > Sent: Thursday, December 06, 2007 2127 PM > To: Karl Reis > Cc: gtk-app-devel-list@gnome.org > Subject: Re: Linear Scaling of fonts with FreeType on Cairo > > 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