About RFont



Hello printers!

I just hacked GnomeRFont from gnom-font draft into existing gnome-print.

GnomeRFont = Gnome Rasterized Font

It will (eventually) take the burden of properly rasterizing, caching and
drawing glyphs (maybe even strings) from user. At moment there are only 2
targets (RGB and RBBA buffers), single drawing mode (antialiased) and very
simple cacheing. But hopefully I can implement more things in near future.

API

GnomeRFont * gnome_font_get_rfont (GnomeFont * font, gdouble * transform)

Creates RFont instance. Transform is 2x2 matrix, describing affine
transformation from typographic unit coordinate system (i.e. the one where
12 pt font em square is 12.000 x 12.000 units) to pixel buffer. Usual
libart matrix would do, as translation part will simply be ignored.

Various attribute reading methods, that are not very interesting

ArtPoint * gnome_rfont_get_glyph_stdadvance (const GnomeRFont * rfont,
	gint glyph, ArtPoint * advance)

Returns given glyph pen advancement vector in raster coordinates. It is
correct, whatever is the transformation of text, and (in future) will take
into account proper hinting.

ArtDRect * gnome_rfont_get_glyph_stdbbox (const GnomeRFont * rfont,
	gint glyph, ArtDRect * bbox);

Glyph binding box (relative to pen position) in raster coordinates.

gnome_rfont_render_glyph_rgb8 (const GnomeRFont * rfont, gint glyph,
	guint32 rgba
	gdouble x, gdouble y,
	guchar * buf,
	gint width, gint height, gint rowstride,
	guint flags);

Renders glyph shape to given 24bit RGB buffer at position x,y
There are at moment only one flag GNOME_RFONT_RENDER_DEFAULT=0, but in
future flags will determine whether to do exact (sub-pixel) or aligned
positioning

The same for rgba buffer.

There is (partial) using example in gnome_canvas_hacktext.c (::render()
method), so anybody interested, should take look there. Hopefully there
will be little need for RFonts in normal code, as canvasitems and
printcontexts will take care of creating/destroying appropriate rfonts as
needed.

The next (and unfortunate) thing in my .plan is:

gnome_rfont_render_glyph_gdk_drawable

But this is about (<< 8) tougher.
- separate caches for different displays/visuals
- separate cache entries for every fg/bg color combination

If anybody knows, how to do it The Right Way (other than implementing it
in next version of X), I would like to hear ;)

Best wishes
Lauris






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]