mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 00:14:09 -04:00
bitwidgets: Import X11 misc fonts since they're PD
We really heavily depend on these fonts, so in the name of portability, it's okayish to import them here. The license for these files is apparently the public domain, so this should be okay. Adjusts the fonts package to load in the fonts using importlib and some BytesIO wizardry.
This commit is contained in:
parent
206c096829
commit
38384f512c
BIN
g13gui/bitwidgets/assets/10x20.pcf.gz
Normal file
BIN
g13gui/bitwidgets/assets/10x20.pcf.gz
Normal file
Binary file not shown.
BIN
g13gui/bitwidgets/assets/4x6.pcf.gz
Normal file
BIN
g13gui/bitwidgets/assets/4x6.pcf.gz
Normal file
Binary file not shown.
BIN
g13gui/bitwidgets/assets/5x7.pcf.gz
Normal file
BIN
g13gui/bitwidgets/assets/5x7.pcf.gz
Normal file
Binary file not shown.
BIN
g13gui/bitwidgets/assets/8x13.pcf.gz
Normal file
BIN
g13gui/bitwidgets/assets/8x13.pcf.gz
Normal file
Binary file not shown.
BIN
g13gui/bitwidgets/assets/9x18.pcf.gz
Normal file
BIN
g13gui/bitwidgets/assets/9x18.pcf.gz
Normal file
Binary file not shown.
1
g13gui/bitwidgets/assets/LICENSE.font-misc-misc
Normal file
1
g13gui/bitwidgets/assets/LICENSE.font-misc-misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
"Public domain font. Share and enjoy."
|
@ -16,20 +16,20 @@ import gzip
|
|||||||
import pathlib
|
import pathlib
|
||||||
import enum
|
import enum
|
||||||
import PIL
|
import PIL
|
||||||
|
import importlib.resources as pkg_resources
|
||||||
from PIL.ImageFont import ImageFont
|
from PIL.ImageFont import ImageFont
|
||||||
from PIL.PcfFontFile import PcfFontFile
|
from PIL.PcfFontFile import PcfFontFile
|
||||||
from PIL.FontFile import puti16
|
from PIL.FontFile import puti16
|
||||||
|
|
||||||
|
from . import assets
|
||||||
X11_FONT_PATH = pathlib.Path('/usr/share/fonts/X11/misc')
|
|
||||||
|
|
||||||
|
|
||||||
class Fonts(enum.Enum):
|
class Fonts(enum.Enum):
|
||||||
TINY = X11_FONT_PATH / '4x6.pcf.gz'
|
TINY = '4x6.pcf.gz'
|
||||||
SMALL = X11_FONT_PATH / '5x7.pcf.gz'
|
SMALL = '5x7.pcf.gz'
|
||||||
MEDIUM = X11_FONT_PATH / '8x13.pcf.gz'
|
MEDIUM = '8x13.pcf.gz'
|
||||||
LARGE = X11_FONT_PATH / '9x18.pcf.gz'
|
LARGE = '9x18.pcf.gz'
|
||||||
HUGE = X11_FONT_PATH / '10x20.pcf.gz'
|
HUGE = '10x20.pcf.gz'
|
||||||
|
|
||||||
|
|
||||||
class PcfFontConverter(PcfFontFile):
|
class PcfFontConverter(PcfFontFile):
|
||||||
@ -108,7 +108,9 @@ class FontManager(object):
|
|||||||
return FontManager._fonts[font]
|
return FontManager._fonts[font]
|
||||||
|
|
||||||
def _loadPcfFont(filename):
|
def _loadPcfFont(filename):
|
||||||
with gzip.open(filename, 'rb') as fp:
|
compressed_data = pkg_resources.read_binary(assets, filename)
|
||||||
|
data = gzip.decompress(compressed_data)
|
||||||
|
with io.BytesIO(data) as fp:
|
||||||
pff = PcfFontConverter(fp)
|
pff = PcfFontConverter(fp)
|
||||||
imageFont = pff.getImageFont()
|
imageFont = pff.getImageFont()
|
||||||
return imageFont
|
return imageFont
|
||||||
|
Loading…
Reference in New Issue
Block a user