Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
legopitstop committed Feb 3, 2024
1 parent 72abbf1 commit aaff33f
Show file tree
Hide file tree
Showing 1,743 changed files with 132,906 additions and 9,411 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: Legopitstop
open_collective: # Replace with a single Open Collective username
ko_fi: legopitstop
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with a custom donation URL
73 changes: 73 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Bug Report
description: Submit a bug report.
labels:
- "bug :bug:"
assignees:
- legopitstop
body:
- type: markdown
attributes:
value: |
Note: Please search to see if an issue already exists for the bug you encountered.
- type: textarea
id: describe
validations:
required: true
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.

- type: textarea
id: reproduce
validations:
required: true
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior
value: |
1.
2.
3.
...
- type: textarea
id: expected
validations:
required: true
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.

- type: input
id: python_version
validations:
required: true
attributes:
label: Python Version
description: The version of Python that you are using this with.
placeholder: e.g. 3.11

- type: input
id: package_version
validations:
required: true
attributes:
label: Package Version
description: The version of this package that you are using.
placeholder: e.g. 1.0.0

- type: input
id: platform
attributes:
label: Platform
description: The device that you are using this package on.
placeholder: e.g. Windows 11, iOS, Linux

- type: textarea
id: other
attributes:
label: Additional context
description: |
Add any other information about the problem here.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Feature Request
description: Suggest an idea for this package
labels:
- "Suggestion :bulb:"
assignees:
- legopitstop
body:
- type: textarea
id: feature
validations:
required: true
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.

- type: textarea
id: rel_issue
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is.
placeholder: I'm always frustrated when [...]

- type: textarea
id: other
attributes:
label: Additional context
description: |
Add any other information about the problem here.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/test.py
/gen
/build
/mcaddon/todo
Binary file not shown.
133 changes: 133 additions & 0 deletions .venv/Lib/site-packages/PIL/BdfFontFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# The Python Imaging Library
# $Id$
#
# bitmap distribution font (bdf) file parser
#
# history:
# 1996-05-16 fl created (as bdf2pil)
# 1997-08-25 fl converted to FontFile driver
# 2001-05-25 fl removed bogus __init__ call
# 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev)
# 2003-04-22 fl more robustification (from Graham Dumpleton)
#
# Copyright (c) 1997-2003 by Secret Labs AB.
# Copyright (c) 1997-2003 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#

"""
Parse X Bitmap Distribution Format (BDF)
"""
from __future__ import annotations

from typing import BinaryIO

from . import FontFile, Image

bdf_slant = {
"R": "Roman",
"I": "Italic",
"O": "Oblique",
"RI": "Reverse Italic",
"RO": "Reverse Oblique",
"OT": "Other",
}

bdf_spacing = {"P": "Proportional", "M": "Monospaced", "C": "Cell"}


def bdf_char(
f: BinaryIO,
) -> (
tuple[
str,
int,
tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int]],
Image.Image,
]
| None
):
# skip to STARTCHAR
while True:
s = f.readline()
if not s:
return None
if s[:9] == b"STARTCHAR":
break
id = s[9:].strip().decode("ascii")

# load symbol properties
props = {}
while True:
s = f.readline()
if not s or s[:6] == b"BITMAP":
break
i = s.find(b" ")
props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")

# load bitmap
bitmap = bytearray()
while True:
s = f.readline()
if not s or s[:7] == b"ENDCHAR":
break
bitmap += s[:-1]

# The word BBX
# followed by the width in x (BBw), height in y (BBh),
# and x and y displacement (BBxoff0, BByoff0)
# of the lower left corner from the origin of the character.
width, height, x_disp, y_disp = (int(p) for p in props["BBX"].split())

# The word DWIDTH
# followed by the width in x and y of the character in device pixels.
dwx, dwy = (int(p) for p in props["DWIDTH"].split())

bbox = (
(dwx, dwy),
(x_disp, -y_disp - height, width + x_disp, -y_disp),
(0, 0, width, height),
)

try:
im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
except ValueError:
# deal with zero-width characters
im = Image.new("1", (width, height))

return id, int(props["ENCODING"]), bbox, im


class BdfFontFile(FontFile.FontFile):
"""Font file plugin for the X11 BDF format."""

def __init__(self, fp: BinaryIO):
super().__init__()

s = fp.readline()
if s[:13] != b"STARTFONT 2.1":
msg = "not a valid BDF file"
raise SyntaxError(msg)

props = {}
comments = []

while True:
s = fp.readline()
if not s or s[:13] == b"ENDPROPERTIES":
break
i = s.find(b" ")
props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")
if s[:i] in [b"COMMENT", b"COPYRIGHT"]:
if s.find(b"LogicalFontDescription") < 0:
comments.append(s[i + 1 : -1].decode("ascii"))

while True:
c = bdf_char(fp)
if not c:
break
id, ch, (xy, dst, src), im = c
if 0 <= ch < len(self.glyph):
self.glyph[ch] = xy, dst, src, im
Loading

0 comments on commit aaff33f

Please sign in to comment.