[cairo] scale with text

Damon Chaplin damon at karuna.eclipse.co.uk
Fri Feb 23 12:53:48 PST 2007


On Fri, 2007-02-23 at 19:14 +0100, Tobias Ceglarek wrote:
> > > 1. Turn off the hinting
> > > 
> > >    You can do this with cairo_font_options_set_hint_style and
> > >    cairo_font_options_set_hint_metrics. See the example I attached
> > >    below for details. (And note that I also explicitly set
> > >    ANTIALIAS_GRAY since you really don't want ANTIALIAS_SUBPIXEL
> > >    without hinting).
> > > 
> > >    This is the right answer if you want to be able to scale without
> > >    any change in shape, (for example, if you're animating a zoom with
> > >    text, the changes in shape and position can be very
> > >    undesirable). But, without hinting, text can also be much less
> > >    legible, so it's not necessarily always the right thing.
> > 
> > For me this is the best/quickest solution. Thank you very very much for
> > your help!!!
> 
> :-(
> 
> I have detect a difficulty. Yet I have testet my scenario with pygtk: a
> drawingarea in a window.
> 
> Now I have inserted the drawingarea in a viewport, the viewport in a
> scrolledwindow, the scrolledwindow in a vbox an the vbox in the window.
> 
> suddenly the settings
> 
> ...
> set_hint_style (cairo.HINT_STYLE_NONE)
> set_hint_metrics (cairo.HINT_METRICS_OFF)
> fopt.set_antialias (cairo.ANTIALIAS_GRAY)
> ...
> 
> seem to be overwritten. My problem is present again.

Are you using Pango? If you are, you need to set the font options on the
pango context rather than the cairo context (this one took me ages to
figure out):

  font_options = cairo_font_options_create ();
  cairo_font_options_set_hint_metrics (font_options,
                                       CAIRO_HINT_METRICS_OFF);
  cairo_font_options_set_hint_style (font_options,
                                     CAIRO_HINT_STYLE_NONE);
  context = pango_layout_get_context (layout);
  pango_cairo_context_set_font_options (context, font_options);
  cairo_font_options_destroy (font_options);

Damon




More information about the cairo mailing list