Dependency on XFont

Posted by 每特17劃 on 2006-02-02

Dependency on XFont

(1. Find the bottleneck )

Fbiterm use the XFont to implement pcf & bdf font rendering. The dependency has two aspect: one is dependency of compiling, the other is dependency of linking.

The dependency of linking can be displayed via ldd fbiterm, and it contains:

...
libXfont.so => /usr/lib/libXfont.so.1
...

,I trace the undefined function object in fbiterm via nm fbiterm and related file PREFIX/src/font.c.

Found! Fbiterm invoke serverl subroutine from the font.c:

get_encoding_name
get_glyph_codpoing
get_glyph
load_font
InitFont

,and I find their implementations depend on XFont. To cut off the dependency, we should implement the subroutines ourself to shrink the use of XFont, and link them locally into fbiterm.

(2. start to patch)

We need to tweak the header to solve the compiling dependency. The compiling errors occur most on the X11 related headers, which locate in PREFIX/include/. Remove all "" including, then compile-error & copy-patch all the neccessary declarations. The process is really tedious and slow, all I can do is to trace and trace the code again.

Hardest part is to reimplement “load_font” in PREFIX/src/font.c . FontFileOPen, FontFileClose can be substituded by FreeType’s face loading, and bdfReadFont can also take out of the consideration. But pcfReadFont is complicated. I plan to use Freetype libraries to setup the FontInfo. But it not as easy as imagine. The terminologies are strange to me. And I should to compare them with the terminologies of Freetype.

A specification of PCF file format is really useful. There is a great site which collects many format’s specifications:

https://www.wotsit.org/default.asp

這裡有一個網頁介紹了用 XFont, FreeType, Xft, Fontconfig, Pango 五種不同的方法操作字型:

https://www.ms.mff.cuni.cz/~beran/vyuka/X/ref_trmac/fonts.html.iso-8859-1

最主要的過程是需要字型的程式把每一個字的編碼丟給字型引擎,然後字型引擎找到相對應的圖檔傳回給主程式. 因此移轉時所要注意的地方主要有:

  1. char_code( 字的編碼 )
  2. bitmap
  3. font_width, font_height
  4. font_engine handler