Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions papertty/papertty.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def ttydev(vcsa):

def vcsudev(self, vcsa):
"""Return character width and associated vcs(u) for vcsa device,
ie. for /dev/vcsa1, retunr (4, "/dev/vcsu1") if vcsu is available, or
ie. for /dev/vcsa1, return (4, "/dev/vcsu1") if vcsu is available, or
(1, "/dev/vcs1") if not"""
dev = vcsa.replace("vcsa", "vcsu")
if os.path.exists(dev):
Expand Down Expand Up @@ -228,7 +228,10 @@ def recalculate_font(self, font):
"""Load the PIL or TrueType font"""
# get physical dimensions of font. Take the average width of
# 1000 M's because oblique fonts a complicated.
self.font_width = font.getsize('M' * 1000)[0] // 1000
ll, tt, rr, bb = font.getbbox('M')
#ww = (((rr * 1000) - (ll * 1000)) // 1000)
hh = bb - tt
self.font_height = hh
if 'getmetrics' in dir(font):
metrics_ascent, metrics_descent = font.getmetrics()
self.spacing = int(self.spacing) if self.spacing != 'auto' else (metrics_descent - 2)
Expand All @@ -242,7 +245,10 @@ def recalculate_font(self, font):
self.spacing = int(self.spacing) if self.spacing != 'auto' else 0
# pil fonts don't seem to have metrics, but all
# characters seem to have the same height
self.font_height = font.getsize('a')[1] + self.spacing
ll, tt, rr, bb = font.getbbox('A')
#ww = (((rr * 1000) - (ll * 1000)) // 1000)
hh = bb - tt
self.font_height = hh + self.spacing

def init_display(self):
"""Initialize the display - call the driver's init method"""
Expand Down Expand Up @@ -1202,7 +1208,11 @@ def stdin(settings, font, fontsize, width, portrait, nofold, spacing, ttyrows, t
if width:
text = ptty.fold(text, width)
else:
font_width = ptty.font.getsize('M')[0]
ll, tt, rr, bb = ptty.font.getbbox('M')
ww = (((rr * 1000) - (ll * 1000)) // 1000)
hh = bb - tt
font_height = hh
font_width = ww
max_width = int((ptty.driver.width - 8) / font_width) if portrait else int(ptty.driver.height / font_width)
text = ptty.fold(text, width=max_width)
if ttyrows:
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ homepage = "https://github.com/joukos/PaperTTY"

[tool.poetry.dependencies]
click = "^7.1.2"
Pillow = "7.1.2"
python = "^3.5"
"RPi.GPIO" = "^0.7.0"
spidev = "^3.4"
vncdotool = "^1.0.0"
Pillow = "10.4.0"
python = "^3.9"
gpiozero = "^2.0.0"
lgpio = "^0.2.0.0"
"RPi.GPIO" = "^0.7.1"
spidev = "^3.6"
vncdotool = "^1.2.0"

[tool.poetry.scripts]
papertty = "papertty.papertty:cli"
Expand Down