Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with bdf files #1

Open
olikraus opened this issue Jan 14, 2018 · 4 comments
Open

issue with bdf files #1

olikraus opened this issue Jan 14, 2018 · 4 comments

Comments

@olikraus
Copy link

Please excause opening an issue here, but I do not know where else to place my problem.

Background: I was asked to add the wqy directly into u8g2, based on your excellent work: olikraus/u8g2#455

As you already noted, bdfconv will fail with the fonts and you have patched bdfconv accordingly. The problem, however, is not simply solved by removing the assert statements. Instead the assert statements actually warn about an issue in the original bdf file.

Let me take the infinity sign from the 9pt font:

STARTCHAR U_221E
ENCODING 8734
SWIDTH 1000 0
DWIDTH 12 0
BBX 11 6 0 2
BITMAP
38E0
4510
8208
8208
4510
38E0
ENDCHAR

The problem is this: The BBX statement claims, that the glyph has a width of 11 pixel (first argument). However the bitmap later contains pixel in column 13: 8208. This means, the bitmap has an actual width of 13 which differs from the BBX specification.

Your fix in bdfconv has two consequences:

  1. There might be a memory issue, because the x position might be beyond the allocated memory, because memory is allocated based on the BBX information
  2. The glyph is truncated at the right. In fact the infinity sign is truncated and the left two pixel are missing. So actually the glyph is incorrect within u8g2.

To solve the problem, just increase the first argument of the BBX statement. But probably there are multiple glyphs in all bdf files affected.

I do not know how to continue here. I have updated bdfconv to output a warning message together with the glyph encoding number (so that we know which glyph to fix).

So my suggesstion is to go through all bdf files and fix the faulty BBX statement.

@olikraus
Copy link
Author

Current output for the 9pt font:

./bdfconv -v -f 1 -M ../build/gb2312.map ../bdf/wenquanyi_9pt.bdf -o test.c  -n test -d ../bdf/helvB12.bdf 
Glyph size problem: encoding=242/0xf2, width=4, height=10, requested position x=4, y=5
Glyph size problem: encoding=432/0x1b0, width=6, height=12, requested position x=6, y=3
Glyph size problem: encoding=601/0x259, width=5, height=12, requested position x=5, y=2
Glyph size problem: encoding=605/0x25d, width=5, height=12, requested position x=5, y=2
Glyph size problem: encoding=607/0x25f, width=4, height=12, requested position x=4, y=6
Glyph size problem: encoding=8733/0x221d, width=11, height=6, requested position x=11, y=0
Glyph size problem: encoding=8734/0x221e, width=11, height=6, requested position x=11, y=1
Glyph size problem: encoding=8735/0x221f, width=9, height=9, requested position x=9, y=8
Glyph size problem: encoding=8925/0x22dd, width=11, height=17, requested position x=11, y=4
Glyph size problem: encoding=8926/0x22de, width=11, height=17, requested position x=12, y=0
Glyph size problem: encoding=8927/0x22df, width=11, height=17, requested position x=11, y=4
Glyph size problem: encoding=8928/0x22e0, width=11, height=17, requested position x=12, y=0
Glyph size problem: encoding=9548/0x254c, width=11, height=11, requested position x=11, y=5
Glyph size problem: encoding=9549/0x254d, width=11, height=11, requested position x=11, y=5
Glyph size problem: encoding=9618/0x2592, width=11, height=12, requested position x=11, y=1
Glyph size problem: encoding=11960/0x2eb8, width=11, height=11, requested position x=11, y=5
Parse File ../bdf/wenquanyi_9pt.bdf: 30503 glyph(s) found
Map: exclude=0 from=32/$20 to=128/$80 map=32/$20
Map: exclude=0 from=164/$a4 to=164/$a4 map=164/$a4 (further single glyph logs disabled)
Reduce: Start
Reduce: End
CalculateMaxBBX: x=0, y=-2, w=12, h=13
CalculateMaxBBX: Encodings x=32, y=74, w=8230, h=47
bf_CalculateMinMaxDWidth: dx_min=2, dx_max=12
bf_CalculateMinMaxDWidth: x_min=0, x_max=8
bf_CalculateMaxBitFieldSize: bbx.x=5, bbx.y=5, bbx.w=4, bbx.h=4, dwidth=5
RLE Compress: best zero bits 3, one bits 2, total bit size 1665608
RLE Compress: Font code generation, selected glyphs=7539, total glyphs=30503
RLE Compress: 'A' pos = 365, 'a' pos = 743
RLE Compress: Font size 208228
Draw TGA, line height 20
Draw TGA, xmax 336
bf_WriteU8G2CByFilename: Write file 'test.c'

@olikraus
Copy link
Author

I have fixed the fonts. New version of the bdf files are here:
https://github.com/olikraus/u8g2/tree/master/tools/font/bdf

@wayne2000
Copy link

Thanks Olikraus. Using the scripts from u8g2_wqy but bdfconv & bdf from your u8g2 works.

@olikraus
Copy link
Author

olikraus commented Jul 8, 2019

I also included all these font's into u8g2, so hopefully no extra effort is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants