pcffont 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pcffont-0.0.1/.github/workflows/publish.yml +29 -0
- pcffont-0.0.1/.github/workflows/test.yml +24 -0
- pcffont-0.0.1/.gitignore +141 -0
- pcffont-0.0.1/LICENSE +21 -0
- pcffont-0.0.1/PKG-INFO +76 -0
- pcffont-0.0.1/README.md +58 -0
- pcffont-0.0.1/assets/artwiz/anorexia.pcf +0 -0
- pcffont-0.0.1/assets/artwiz/kates.pcf +0 -0
- pcffont-0.0.1/assets/dweep/dweep.pcf +0 -0
- pcffont-0.0.1/assets/profont-x11/ProFont_r400-29.pcf +0 -0
- pcffont-0.0.1/assets/raize/raize-normal-19.pcf +0 -0
- pcffont-0.0.1/assets/sgi/rock36.pcf +0 -0
- pcffont-0.0.1/assets/trisk/trisk.pcf +0 -0
- pcffont-0.0.1/assets/unifont/OFL.txt +90 -0
- pcffont-0.0.1/assets/unifont/unifont-15.1.05.pcf +0 -0
- pcffont-0.0.1/examples/__init__.py +5 -0
- pcffont-0.0.1/examples/demo.py +28 -0
- pcffont-0.0.1/pyproject.toml +34 -0
- pcffont-0.0.1/requirements.txt +1 -0
- pcffont-0.0.1/src/pcffont/__init__.py +10 -0
- pcffont-0.0.1/src/pcffont/error.py +25 -0
- pcffont-0.0.1/src/pcffont/font.py +143 -0
- pcffont-0.0.1/src/pcffont/header.py +70 -0
- pcffont-0.0.1/src/pcffont/internal/__init__.py +0 -0
- pcffont-0.0.1/src/pcffont/internal/buffer.py +122 -0
- pcffont-0.0.1/src/pcffont/internal/util.py +49 -0
- pcffont-0.0.1/src/pcffont/metric.py +59 -0
- pcffont-0.0.1/src/pcffont/t_accelerators.py +143 -0
- pcffont-0.0.1/src/pcffont/t_bitmaps.py +135 -0
- pcffont-0.0.1/src/pcffont/t_encodings.py +104 -0
- pcffont-0.0.1/src/pcffont/t_glyph_names.py +58 -0
- pcffont-0.0.1/src/pcffont/t_metrics.py +49 -0
- pcffont-0.0.1/src/pcffont/t_properties.py +388 -0
- pcffont-0.0.1/src/pcffont/t_scalable_widths.py +40 -0
- pcffont-0.0.1/src/pcffont/table.py +29 -0
- pcffont-0.0.1/src/pcffont/xlfd.py +50 -0
- pcffont-0.0.1/tests/test_dump.py +74 -0
- pcffont-0.0.1/tests/test_load_save.py +76 -0
- pcffont-0.0.1/tests/test_reload.py +120 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment:
|
|
11
|
+
name: pypi
|
|
12
|
+
url: https://pypi.org/project/pcffont/
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
- name: Setup Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: '3.x'
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install pip --upgrade
|
|
25
|
+
python -m pip install build
|
|
26
|
+
- name: Build
|
|
27
|
+
run: python -m build
|
|
28
|
+
- name: Publish
|
|
29
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
fail-fast: false
|
|
10
|
+
matrix:
|
|
11
|
+
python-version: ["3.11", "3.12"]
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
- name: Setup Python
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install pip --upgrade
|
|
22
|
+
python -m pip install -r requirements.txt
|
|
23
|
+
- name: Test
|
|
24
|
+
run: python -m pytest
|
pcffont-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
98
|
+
__pypackages__/
|
|
99
|
+
|
|
100
|
+
# Celery stuff
|
|
101
|
+
celerybeat-schedule
|
|
102
|
+
celerybeat.pid
|
|
103
|
+
|
|
104
|
+
# SageMath parsed files
|
|
105
|
+
*.sage.py
|
|
106
|
+
|
|
107
|
+
# Environments
|
|
108
|
+
.env
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
|
139
|
+
|
|
140
|
+
# PyCharm
|
|
141
|
+
.idea/
|
pcffont-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 TakWolf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pcffont-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pcffont
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A library for manipulating Portable Compiled Format (PCF) Fonts.
|
|
5
|
+
Project-URL: homepage, https://github.com/TakWolf/pcffont
|
|
6
|
+
Project-URL: source, https://github.com/TakWolf/pcffont
|
|
7
|
+
Project-URL: issues, https://github.com/TakWolf/pcffont/issues
|
|
8
|
+
Author: TakWolf
|
|
9
|
+
Maintainer: TakWolf
|
|
10
|
+
License: MIT License
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: font,pcf
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# PcfFont
|
|
20
|
+
|
|
21
|
+
[](https://www.python.org)
|
|
22
|
+
[](https://pypi.org/project/pcffont/)
|
|
23
|
+
|
|
24
|
+
PcfFont is a library for manipulating [Portable Compiled Format (PCF) Fonts](https://en.wikipedia.org/wiki/Portable_Compiled_Format).
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
pip install pcffont
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import os
|
|
36
|
+
import shutil
|
|
37
|
+
|
|
38
|
+
from examples import assets_dir, build_dir
|
|
39
|
+
from pcffont import PcfFont
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def main():
|
|
43
|
+
outputs_dir = os.path.join(build_dir, 'demo')
|
|
44
|
+
if os.path.exists(outputs_dir):
|
|
45
|
+
shutil.rmtree(outputs_dir)
|
|
46
|
+
os.makedirs(outputs_dir)
|
|
47
|
+
|
|
48
|
+
font = PcfFont.load(os.path.join(assets_dir, 'unifont', 'unifont-15.1.05.pcf'))
|
|
49
|
+
print(f'name: {font.properties.font}')
|
|
50
|
+
print(f'size: {font.properties.pixel_size}')
|
|
51
|
+
print(f'ascent: {font.accelerators.font_ascent}')
|
|
52
|
+
print(f'descent: {font.accelerators.font_descent}')
|
|
53
|
+
for code_point, glyph_index in sorted(font.bdf_encodings.items()):
|
|
54
|
+
print(f'{code_point:04X} {chr(code_point)} - {font.glyph_names[glyph_index]}')
|
|
55
|
+
for bitmap_row in font.bitmaps[glyph_index]:
|
|
56
|
+
print(''.join(map(str, bitmap_row)).replace('0', '__').replace('1', '**'))
|
|
57
|
+
print()
|
|
58
|
+
font.save(os.path.join(outputs_dir, 'unifont-15.1.05.pcf'))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == '__main__':
|
|
62
|
+
main()
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Test Fonts
|
|
66
|
+
|
|
67
|
+
- [GNU Unifont Glyphs](https://unifoundry.com/unifont/index.html)
|
|
68
|
+
- [bitmap-fonts](https://github.com/masaeedu/bitmap-fonts)
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
- [FontForge - The X11 PCF bitmap font file format](https://fontforge.org/docs/techref/pcf-format.html)
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
Under the [MIT license](LICENSE).
|
pcffont-0.0.1/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# PcfFont
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org)
|
|
4
|
+
[](https://pypi.org/project/pcffont/)
|
|
5
|
+
|
|
6
|
+
PcfFont is a library for manipulating [Portable Compiled Format (PCF) Fonts](https://en.wikipedia.org/wiki/Portable_Compiled_Format).
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
pip install pcffont
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import os
|
|
18
|
+
import shutil
|
|
19
|
+
|
|
20
|
+
from examples import assets_dir, build_dir
|
|
21
|
+
from pcffont import PcfFont
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main():
|
|
25
|
+
outputs_dir = os.path.join(build_dir, 'demo')
|
|
26
|
+
if os.path.exists(outputs_dir):
|
|
27
|
+
shutil.rmtree(outputs_dir)
|
|
28
|
+
os.makedirs(outputs_dir)
|
|
29
|
+
|
|
30
|
+
font = PcfFont.load(os.path.join(assets_dir, 'unifont', 'unifont-15.1.05.pcf'))
|
|
31
|
+
print(f'name: {font.properties.font}')
|
|
32
|
+
print(f'size: {font.properties.pixel_size}')
|
|
33
|
+
print(f'ascent: {font.accelerators.font_ascent}')
|
|
34
|
+
print(f'descent: {font.accelerators.font_descent}')
|
|
35
|
+
for code_point, glyph_index in sorted(font.bdf_encodings.items()):
|
|
36
|
+
print(f'{code_point:04X} {chr(code_point)} - {font.glyph_names[glyph_index]}')
|
|
37
|
+
for bitmap_row in font.bitmaps[glyph_index]:
|
|
38
|
+
print(''.join(map(str, bitmap_row)).replace('0', '__').replace('1', '**'))
|
|
39
|
+
print()
|
|
40
|
+
font.save(os.path.join(outputs_dir, 'unifont-15.1.05.pcf'))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == '__main__':
|
|
44
|
+
main()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Test Fonts
|
|
48
|
+
|
|
49
|
+
- [GNU Unifont Glyphs](https://unifoundry.com/unifont/index.html)
|
|
50
|
+
- [bitmap-fonts](https://github.com/masaeedu/bitmap-fonts)
|
|
51
|
+
|
|
52
|
+
## References
|
|
53
|
+
|
|
54
|
+
- [FontForge - The X11 PCF bitmap font file format](https://fontforge.org/docs/techref/pcf-format.html)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
Under the [MIT license](LICENSE).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
The SIL Open Font License version 1.1 is copied below, and is also
|
|
2
|
+
available with a FAQ at http://scripts.sil.org/OFL.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
-----------------------------------------------------------
|
|
6
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
PREAMBLE
|
|
10
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
11
|
+
development of collaborative font projects, to support the font creation
|
|
12
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
13
|
+
open framework in which fonts may be shared and improved in partnership
|
|
14
|
+
with others.
|
|
15
|
+
|
|
16
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
17
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
18
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
19
|
+
redistributed and/or sold with any software provided that any reserved
|
|
20
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
21
|
+
however, cannot be released under any other type of license. The
|
|
22
|
+
requirement for fonts to remain under this license does not apply
|
|
23
|
+
to any document created using the fonts or their derivatives.
|
|
24
|
+
|
|
25
|
+
DEFINITIONS
|
|
26
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
27
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
28
|
+
include source files, build scripts and documentation.
|
|
29
|
+
|
|
30
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
31
|
+
copyright statement(s).
|
|
32
|
+
|
|
33
|
+
"Original Version" refers to the collection of Font Software components as
|
|
34
|
+
distributed by the Copyright Holder(s).
|
|
35
|
+
|
|
36
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
37
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
38
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
39
|
+
new environment.
|
|
40
|
+
|
|
41
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
42
|
+
writer or other person who contributed to the Font Software.
|
|
43
|
+
|
|
44
|
+
PERMISSION & CONDITIONS
|
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
46
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
47
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
48
|
+
Software, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
1) Neither the Font Software nor any of its individual components,
|
|
51
|
+
in Original or Modified Versions, may be sold by itself.
|
|
52
|
+
|
|
53
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
54
|
+
redistributed and/or sold with any software, provided that each copy
|
|
55
|
+
contains the above copyright notice and this license. These can be
|
|
56
|
+
included either as stand-alone text files, human-readable headers or
|
|
57
|
+
in the appropriate machine-readable metadata fields within text or
|
|
58
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
59
|
+
|
|
60
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
61
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
62
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
63
|
+
presented to the users.
|
|
64
|
+
|
|
65
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
66
|
+
Software shall not be used to promote, endorse or advertise any
|
|
67
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
68
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
69
|
+
permission.
|
|
70
|
+
|
|
71
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
72
|
+
must be distributed entirely under this license, and must not be
|
|
73
|
+
distributed under any other license. The requirement for fonts to
|
|
74
|
+
remain under this license does not apply to any document created
|
|
75
|
+
using the Font Software.
|
|
76
|
+
|
|
77
|
+
TERMINATION
|
|
78
|
+
This license becomes null and void if any of the above conditions are
|
|
79
|
+
not met.
|
|
80
|
+
|
|
81
|
+
DISCLAIMER
|
|
82
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
83
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
84
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
85
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
86
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
87
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
88
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
89
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
90
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
from examples import assets_dir, build_dir
|
|
5
|
+
from pcffont import PcfFont
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
outputs_dir = os.path.join(build_dir, 'demo')
|
|
10
|
+
if os.path.exists(outputs_dir):
|
|
11
|
+
shutil.rmtree(outputs_dir)
|
|
12
|
+
os.makedirs(outputs_dir)
|
|
13
|
+
|
|
14
|
+
font = PcfFont.load(os.path.join(assets_dir, 'unifont', 'unifont-15.1.05.pcf'))
|
|
15
|
+
print(f'name: {font.properties.font}')
|
|
16
|
+
print(f'size: {font.properties.pixel_size}')
|
|
17
|
+
print(f'ascent: {font.accelerators.font_ascent}')
|
|
18
|
+
print(f'descent: {font.accelerators.font_descent}')
|
|
19
|
+
for code_point, glyph_index in sorted(font.bdf_encodings.items()):
|
|
20
|
+
print(f'{code_point:04X} {chr(code_point)} - {font.glyph_names[glyph_index]}')
|
|
21
|
+
for bitmap_row in font.bitmaps[glyph_index]:
|
|
22
|
+
print(''.join(map(str, bitmap_row)).replace('0', '__').replace('1', '**'))
|
|
23
|
+
print()
|
|
24
|
+
font.save(os.path.join(outputs_dir, 'unifont-15.1.05.pcf'))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
main()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pcffont"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "A library for manipulating Portable Compiled Format (PCF) Fonts."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT License" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "TakWolf" },
|
|
14
|
+
]
|
|
15
|
+
maintainers = [
|
|
16
|
+
{ name = "TakWolf" },
|
|
17
|
+
]
|
|
18
|
+
keywords = ["pcf", "font"]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
homepage = "https://github.com/TakWolf/pcffont"
|
|
27
|
+
source = "https://github.com/TakWolf/pcffont"
|
|
28
|
+
issues = "https://github.com/TakWolf/pcffont/issues"
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
pythonpath = "src"
|
|
32
|
+
addopts = [
|
|
33
|
+
"--import-mode=importlib",
|
|
34
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pytest==8.1.1
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from pcffont.font import PcfFont
|
|
2
|
+
from pcffont.header import PcfTableType
|
|
3
|
+
from pcffont.metric import PcfMetric
|
|
4
|
+
from pcffont.t_properties import PcfProperties
|
|
5
|
+
from pcffont.t_accelerators import PcfAccelerators
|
|
6
|
+
from pcffont.t_metrics import PcfMetrics
|
|
7
|
+
from pcffont.t_bitmaps import PcfBitmaps
|
|
8
|
+
from pcffont.t_encodings import PcfBdfEncodings
|
|
9
|
+
from pcffont.t_scalable_widths import PcfScalableWidths
|
|
10
|
+
from pcffont.t_glyph_names import PcfGlyphNames
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
class PcfError(Exception):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PcfPropKeyError(PcfError):
|
|
7
|
+
def __init__(self, key: str, reason: str):
|
|
8
|
+
self.key = key
|
|
9
|
+
self.reason = reason
|
|
10
|
+
super().__init__(f"'{key}': {reason}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PcfPropValueError(PcfError):
|
|
14
|
+
def __init__(self, key: str, value: object, reason: str):
|
|
15
|
+
self.key = key
|
|
16
|
+
self.value = value
|
|
17
|
+
self.reason = reason
|
|
18
|
+
super().__init__(f"'{key}': '{value}': {reason}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class PcfXlfdError(PcfError):
|
|
22
|
+
def __init__(self, font_name: str, reason: str):
|
|
23
|
+
self.font_name = font_name
|
|
24
|
+
self.reason = reason
|
|
25
|
+
super().__init__(f"'{font_name}': {reason}")
|