diff --git a/adafruit_bitmap_font/pcf.py b/adafruit_bitmap_font/pcf.py index 7e9df42..94bf9c6 100644 --- a/adafruit_bitmap_font/pcf.py +++ b/adafruit_bitmap_font/pcf.py @@ -25,29 +25,29 @@ from collections import namedtuple import gc import struct +from micropython import const from fontio import Glyph from .glyph_cache import GlyphCache -_PCF_PROPERTIES = 1 << 0 -_PCF_ACCELERATORS = 1 << 1 -_PCF_METRICS = 1 << 2 -_PCF_BITMAPS = 1 << 3 -_PCF_INK_METRICS = 1 << 4 -_PCF_BDF_ENCODINGS = 1 << 5 -_PCF_SWIDTHS = 1 << 6 -_PCF_GLYPH_NAMES = 1 << 7 -_PCF_BDF_ACCELERATORS = 1 << 8 - -_PCF_DEFAULT_FORMAT = 0x00000000 -_PCF_INKBOUNDS = 0x00000200 -_PCF_ACCEL_W_INKBOUNDS = 0x00000100 -_PCF_COMPRESSED_METRICS = 0x00000100 - -_PCF_GLYPH_PAD_MASK = 3 << 0 # See the bitmap table for explanation */ -_PCF_BYTE_MASK = 1 << 2 # If set then Most Sig Byte First */ -_PCF_BIT_MASK = 1 << 3 # If set then Most Sig Bit First */ -_PCF_SCAN_UNIT_MASK = 3 << 4 +_PCF_PROPERTIES = const(1 << 0) +_PCF_ACCELERATORS = const(1 << 1) +_PCF_METRICS = const(1 << 2) +_PCF_BITMAPS = const(1 << 3) +_PCF_INK_METRICS = const(1 << 4) +_PCF_BDF_ENCODINGS = const(1 << 5) +_PCF_SWIDTHS = const(1 << 6) +_PCF_GLYPH_NAMES = const(1 << 7) +_PCF_BDF_ACCELERATORS = const(1 << 8) + +_PCF_DEFAULT_FORMAT = const(0x00000000) +_PCF_ACCEL_W_INKBOUNDS = const(0x00000100) +_PCF_COMPRESSED_METRICS = const(0x00000100) + +_PCF_GLYPH_PAD_MASK = const(3 << 0) # See the bitmap table for explanation */ +_PCF_BYTE_MASK = const(1 << 2) # If set then Most Sig Byte First */ +_PCF_BIT_MASK = const(1 << 3) # If set then Most Sig Bit First */ +_PCF_SCAN_UNIT_MASK = const(3 << 4) # https://fontforge.org/docs/techref/pcf-format.html @@ -214,9 +214,7 @@ def _read_accelerator_tables(self): raise RuntimeError("Accelerator table missing") format_ = self._seek_table(accelerators) - has_inkbounds = format_ & _PCF_ACCEL_W_INKBOUNDS - compressed_metrics = format_ & _PCF_COMPRESSED_METRICS ( no_overlap, @@ -231,11 +229,11 @@ def _read_accelerator_tables(self): font_descent, max_overlap, ) = self._read(">BBBBBBBBIII") - minbounds = self._read_metrics(compressed_metrics) - maxbounds = self._read_metrics(compressed_metrics) + minbounds = self._read_metrics(False) + maxbounds = self._read_metrics(False) if has_inkbounds: - ink_minbounds = self._read_metrics(compressed_metrics) - ink_maxbounds = self._read_metrics(compressed_metrics) + ink_minbounds = self._read_metrics(False) + ink_maxbounds = self._read_metrics(False) else: ink_minbounds = minbounds ink_maxbounds = maxbounds diff --git a/test/displayio.py b/test/displayio.py index d506343..7b16498 100644 --- a/test/displayio.py +++ b/test/displayio.py @@ -2,7 +2,9 @@ # # SPDX-License-Identifier: MIT +"""Implementation of minimal displayio subset for testing""" +# pylint: disable=all class Bitmap: def __init__(self, width, height, color_count): self.width = width diff --git a/test/fontio.py b/test/fontio.py index 8222362..19e1062 100644 --- a/test/fontio.py +++ b/test/fontio.py @@ -2,6 +2,8 @@ # # SPDX-License-Identifier: MIT +"""Implementation of minimal fontio subset for testing""" + import collections Glyph = collections.namedtuple(