Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
Catch missing TrueType font
Browse files Browse the repository at this point in the history
  • Loading branch information
sam210723 committed Feb 11, 2020
1 parent ea729fd commit 92df164
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file.
- ``keymsg-decrypt.py`` output file name

### Fixed
-
- Missing TrueType font exception
</details>


Expand Down
29 changes: 18 additions & 11 deletions tools/enhance-ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,24 @@ def process(img):
p2 = (xoff + dlen + rmar, output.height - (gradh * 1.5) + rmar)
draw.rectangle((p1, p2), outline=(0xFF, 0xFF, 0xFF), width=3)

# Draw LUT text
fnt = ImageFont.truetype("arialbd.ttf", size=38)
col = (0xFF, 0xFF, 0xFF, 0xFF)
text = "{}K".format(round(cal[0]))
draw.text((xoff / 2 - 10, img.height + (gradh / 2) + 3), text, fill=col, font=fnt) # Start
text = "{}K".format(round(cal[7]))
draw.text((w - xoff + 30, img.height + (gradh / 2) + 3), text, fill=col, font=fnt) # End
text = "{}K".format(args.hot)
draw.text((xoff + (hotI * scale) - 40, output.height - gradh - rmar), text, fill=col, font=fnt) # Hot
text = "{}K".format(args.cold)
draw.text((xoff + (coldI * scale) - 40, output.height - gradh - rmar), text, fill=col, font=fnt) # Cold
# Try load Arial Bold font
try:
fnt = ImageFont.truetype("arialbd.ttf", size=38)
except OSError:
print(" UNABLE TO LOAD FONT \"arialbd.ttf\"")
fnt = None

if fnt:
# Draw LUT text
col = (0xFF, 0xFF, 0xFF, 0xFF)
text = "{}K".format(round(cal[0]))
draw.text((xoff / 2 - 10, img.height + (gradh / 2) + 3), text, fill=col, font=fnt) # Start
text = "{}K".format(round(cal[7]))
draw.text((w - xoff + 30, img.height + (gradh / 2) + 3), text, fill=col, font=fnt) # End
text = "{}K".format(args.hot)
draw.text((xoff + (hotI * scale) - 40, output.height - gradh - rmar), text, fill=col, font=fnt) # Hot
text = "{}K".format(args.cold)
draw.text((xoff + (coldI * scale) - 40, output.height - gradh - rmar), text, fill=col, font=fnt) # Cold

# Create empty NumPy arrays for each channel
nplutR = np.zeros(len(lut), dtype=np.uint8)
Expand Down

0 comments on commit 92df164

Please sign in to comment.