Merging code between Xft and FT2 shapers



I finally got tired of having duplicated code in:

 - arabic-ft2 and arabic-xft
 - basic-ft2 and basic-xft
 - hebrew-ft2 and hebrew-xft

with patches for thai-ft2 and indic-ft2 outstanding.
So, what I decided to do was create a PangoFcFont (*) base
class with virtual functions such as:

FT_Face    pango_fc_font_lock_face (PangoFcFont *font);
gboolean   pango_fc_font_has_char  (PangoFcFont *font,
                                    gunichar     wc);

This allows the very same code to be used for both the
Xft and FT2 backend.

What I'd really like to be able to do is actually use the _same_ module
for both backends, but this isn't possible because of the opentype code
that is compiled into libpangoft2.so and libpangoxft.so -- the module
has to link against one of these or the other. It would be possible to
break this out into a separate library, say, libpangofc.so, which would
solve the problem (at the expense of the performance hit of another
library), but for now, what I decided to do was to use a feature
of new automake where you can compile the same module into multiple
libraries with different CFLAGS:

pango_arabic_xft_la_SOURCES = arabic-fc.c [...]
pango_arabic_xft_la_CFLAGS = -DBUILD_XFT
pango_arabic_ft2_la_SOURCES = arabic-fc.c [...]
pango_arabic_ft2_la_CFLAGS = -DBUILD_FT2

#ifdef BUILD_XFT
#include "pangoxft.h"
#define SCRIPT_ENGINE_NAME "ArabicScriptEngineXft"
#define RENDER_TYPE PANGO_RENDER_TYPE_XFT
#else
#include "pangoft2.h"
#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFt2"
#define RENDER_TYPE PANGO_RENDER_TYPE_FT2
#endif

Even with this small hackery going on, I think the 
addition of PangoFcFont cleans things up considerably.
I'm planning to add the indic-ft2 and thai-ft2 backends
to the 1.2.x branch of GTK+ because this change is too major
to be done in the stable branch, but in pango-head, the separate
-xft and -ft2 code is now gone.

Regards,
                                      Owen

(*) This is sort of a misnomer because what is actually
    relevant about what is shared is not the use of fontconfig
    but the use of FreeType. However, the use of FreeType as
    the name for the 

Performance? There seems to be some impact from the extra virtualization
   ... the per-character overhead seems to go up 8-10% from that, but   
   it's rather hard to nail down exactly what's that due to. More
   easily traceable is the overhead from adding kerning to the Xft
   backend as was in the FT2 backend .. that's another 15% on the
   per-character overhead.

   Still, per-character layout overhead isn't a major factor in
   Pango performance, so I'm not too worried.




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