Pango Backend Abstraction



Hi Owen et al.,

Sorry to bring up just another api issue this late, but
I fail to see another solution:

Recent Cvs Gimp Text Tool directly uses the FT2 backend to render
into a bitmap. Because there are other backends, IMO we need
a Pango Backend Abstraction to avoid special caseing on the
application level.

I hacked up a solution which should work on any platform with
GModule support, but is currently only fully implemented and
tested for the win32 backend. (Porting to FT2 should be very
easy, because the special new 'render to bitmap' function
is modeled after the FT2 implementation)

Currently only two new functions are necessary:

/**
 * pango_backend_get_context:
 * @backend: the name of the prefered backend, i.e. 'x', 'ft2', 'win32' or
 *           %NULL if none is prefered
 *
 * Retrieves a #PangoContext appropriate for rendering with Pango fonts.
 * If the prefered backend isn't available the function tries to return 
 * a #PangoContext from another backend.
 * 
 * Return value: the new #PangoContext or #NULL ...
 **/
PangoContext *
pango_backend_get_context (const char* backend)

[Function required for 'initialization' of Pango]

and:

/**
 * pango_backend_render_layout:
 * @bitmap:    a #PangoBitmap to render the line onto
 * @layout:    a #PangoLayout
 * @x:         the X position of the left of the layout (in pixels)
 * @y:         the Y position of the top of the layout (in pixels)
 *
 * Render a #PangoLayoutLine onto a FreeType2 bitmap
 */
void 
pango_backend_render_layout (PangoBitmap *bitmap,
                             PangoLayout *layout,
                             int          x, 
                             int          y)

[which simply delegates to the appropriate backend function.
 There is an implementation for the Win32 backend, the FT2 backend
 would need a simple wrapper because it appears to always render
 into a bitmap, the X version will probably require some more
 work]

The backend guessing should probably not only rely on GModule
and the library name, but use a not yet implemented registration
of already loaded and initialized backends. On the other hand
it should not rely on it, because AFAIK the *_get_context ()
function currently is only called by gdk_pango_context (), which
would enforce a gtk+ dependency, which probably isn't necessary,
at least not for FT2 and Win32. (There is the issue with
pango_xft_get_context requireing the DISPLAY and the DefaultScreen)

The full patch is attached. Any comments ?

Thanks,
	Hans

Attachment: pango-backend-2001-08-26-hb.zip
Description: Zip archive

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert


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