-
Notifications
You must be signed in to change notification settings - Fork 24
pcf: Support vewwy big letters #34
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
Conversation
When glyphs lie entirely within 127 pixels of the glyph origin, they get "compressed metrics". Otherwise, they get "uncompressed metrics". Some of the calculations for "uncompressed metrics" were wrong. This only affects extremely unusual or large point-size fonts, which is why it wasn't found initially. Testing performed: rendered the letter 'a' at 200 points from pcf.
At least for some CJK character sets, FontForge writes a font which includes a METRICSSET section in the preamble, and later in some glyphs skips the SWIDTH/DWIDTH lines in preference to the default values specified in the METRICSSET. According to the Adobe document describing the 2.2 format, this is ia size optimization for storing bdf fonts because many glyphs have the same metrics, particular for vertical text layouts. X's bdftopcf never accepted these extensions not present in BDF 2.1, but fontforge writes them anyway. (I'm not sure who is using fontforge's BDF output, given this fact) This adds minimal support for these elements of the font. Testing performed: * converted yasa-200.bdf to pcf, then rendered with Adafruit_CircuitPython_BitmapFont's simpletest on a host computer with adafruit/Adafruit_CircuitPython_Bitmap_Font#34 applied. (this was broken before this PR) * converted a bdf file produced by otf2bdf and displayed it similarly (this was working before)
This font file should allow testing of this PR: yasahsi-ascii-200.zip |
My test code, using a pyportal titano: import board
from adafruit_bitmap_font.bitmap_font import load_font
from adafruit_display_text.label import Label
from displayio import Group
display = board.DISPLAY
font = load_font("/yasahsi-ascii-200.pcf")
group = Group()
label = Label(font=font, text="a")
label.x = 80
label.y = 120
group.append(label)
display.show(group)
while True:
pass
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this successfully on PyPortal with Adafruit CircuitPython 6.1.0-beta.1
The changes do allow the large font linked here to work properly. Looks good to me. Thank you!
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.4 from 3.5.3: > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#122 from anecdata/disconnect Updating https://github.com/adafruit/Adafruit_CircuitPython_FXAS21002C to 2.1.4 from 2.1.3: > Merge pull request adafruit/Adafruit_CircuitPython_FXAS21002C#19 from tmf97/master Updating https://github.com/adafruit/Adafruit_CircuitPython_LPS35HW to 1.2.4 from 1.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_LPS35HW#8 from adafruit/temp_sign_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 4.0.0 from 3.6.2: > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#97 from flavio-fernandes/get_local_time.exception.merge Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.3 from 3.10.2: > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#88 from agarthetiger/st7789-docs Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.3.2 from 2.3.1: > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#23 from codingbandit/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.3.2 from 1.3.1: > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#34 from jepler/big-metrics Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 5.0.2 from 5.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#63 from BiffoBear/add-0x-to-error-msg Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 1.5.3 from 1.5.2: > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#48 from benetherington/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal to 2.0.0 from 1.9.6: > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#55 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_miniesptool to 0.2.6 from 0.2.5: > Merge pull request adafruit/Adafruit_CircuitPython_miniesptool#25 from Vinx911/master
When glyphs lie entirely within 127 pixels of the glyph origin, they get "compressed metrics". Otherwise, they get "uncompressed
metrics". Some of the calculations for "uncompressed metrics" were wrong. This only affects extremely unusual or large point-size fonts, which is why it wasn't found initially.
Testing performed: rendered the letter 'a' at 200 points from pcf using the simpletest.