From 1724754e9c8d9b3880aa3c73aa08821f7a0b8e99 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 5 Jan 2021 08:56:40 -0600 Subject: [PATCH 1/2] pcf: Support vewwy big letters 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. --- adafruit_bitmap_font/pcf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_bitmap_font/pcf.py b/adafruit_bitmap_font/pcf.py index bb0ca0d..ae51a5a 100644 --- a/adafruit_bitmap_font/pcf.py +++ b/adafruit_bitmap_font/pcf.py @@ -233,7 +233,7 @@ def _read_accelerator_tables(self): format_ = self._seek_table(accelerators) has_inkbounds = format_ & _PCF_ACCEL_W_INKBOUNDS - compressed_metrics = False # format_ & _PCF_COMPRESSED_METRICS + compressed_metrics = format_ & _PCF_COMPRESSED_METRICS ( no_overlap, @@ -325,7 +325,7 @@ def load_glyphs(self, code_points): ) metrics_compressed = self.tables[_PCF_METRICS].format & _PCF_COMPRESSED_METRICS first_metric_offset = ( - self.tables[_PCF_METRICS].offset + 6 if metrics_compressed else 8 + self.tables[_PCF_METRICS].offset + (6 if metrics_compressed else 8) ) metrics_size = 5 if metrics_compressed else 12 From 7da4b31e1775507f39b8585b6919ffe7c5ffe103 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 5 Jan 2021 08:59:06 -0600 Subject: [PATCH 2/2] run black --- adafruit_bitmap_font/pcf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_bitmap_font/pcf.py b/adafruit_bitmap_font/pcf.py index ae51a5a..a3c787d 100644 --- a/adafruit_bitmap_font/pcf.py +++ b/adafruit_bitmap_font/pcf.py @@ -324,8 +324,8 @@ def load_glyphs(self, code_points): 6 + self._bitmaps.glyph_count ) metrics_compressed = self.tables[_PCF_METRICS].format & _PCF_COMPRESSED_METRICS - first_metric_offset = ( - self.tables[_PCF_METRICS].offset + (6 if metrics_compressed else 8) + first_metric_offset = self.tables[_PCF_METRICS].offset + ( + 6 if metrics_compressed else 8 ) metrics_size = 5 if metrics_compressed else 12