[Bug 205707] Improve parsing of BDFs by vtfontcvt

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Mar 18 20:35:05 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205707

Henry Hu <henry.hu.sh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henry.hu.sh at gmail.com

--- Comment #6 from Henry Hu <henry.hu.sh at gmail.com> ---
Created attachment 180939
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=180939&action=edit
read FONTBOUNDINGBOX and BBX, handle other DWIDTH

I tried to convert fonts in x11-fonts/wqy (an open source Chinese bitmap font)
for use with vt. The original fonts are in pcf, I used
https://github.com/ganaware/pcf2bdf to convert them to bdf.

I found that the original assumptions in the code have several problems:
* Assuming DWIDTH = width or width * 2
Actually there can be varying widths. For wqy, there are DWIDTH between 2-13
for the 10pt font, and 2-12 for the 9pt font.
* Assuming number of lines in the bitmap == height
Actually it usually equals to the height in the BBX line.

This patch fixes the problems by:
* Read the FONTBOUNDINGBOX line.
This gives us the baseline position. If offset_y in this line is -3, we need to
reserve 3 lines at the bottom.
* Read the BBX line.
The offset_x and offset_y information in this line tells us where to position
the glyph. For example, if offset_y == -2, the font should be positioned 2
lines below the baseline.
* Position the glyph at the correct place.
The starting line is calculated by:
    line_y = height + font_y - bb_h - bb_y + i;
The font's baseline (bottom) is height + font_y, the glyph's baseline is height
+ font_y - bb_y.

The font generated by this patch is used successfully with the wqy font on the
vt terminal to display chinese characters. There seems to be problems for
alphabet characters which are double-width (the 'W' in wqy font), so the
working configuration requires a width of at least 10 pixels.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list