From e1639ff8ba51f5407876f8e726f05ca5a98bb504 Mon Sep 17 00:00:00 2001 From: Scott Alfter Date: Wed, 11 Jun 2025 17:12:03 -0700 Subject: [PATCH] bugfix: wasn't working at all --- .gitignore | 1 + partdb_labeler/partdb_labeler.py | 67 ++++++++++++++++++-------------- pyproject.toml | 2 +- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 09e414f..add7c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ partdb-labeler.bat partdb_labeler.egg-info build +*/__pycache__/* \ No newline at end of file diff --git a/partdb_labeler/partdb_labeler.py b/partdb_labeler/partdb_labeler.py index 0281a51..d3d9a84 100644 --- a/partdb_labeler/partdb_labeler.py +++ b/partdb_labeler/partdb_labeler.py @@ -52,25 +52,25 @@ def esc(s): # render a line of text at coordinates # return coordinates of next line -def textline(s, loc, fontnum): +def textline(z, res, s, loc, fontnum): z.output(f"A{loc[0]},{loc[1]},0,{fontnum},1,1,N,\"{esc(filter(subst(s), "cp437"))}\"\n") - return (loc[0], loc[1]+font_metrics[fontnum][1]) + return (loc[0], loc[1]+font_metrics(res)[fontnum][1]) # wrap text in a bounding box at coordinates # return coordinates of next line and any unused text -def textbox(s, loc, bbox, fontnum): - wrapped=textwrap.wrap(filter(subst(s), "cp437"), width=floor(bbox[0]/font_metrics[fontnum][0])) +def textbox(z, res, s, loc, bbox, fontnum): + wrapped=textwrap.wrap(filter(subst(s), "cp437"), width=floor(bbox[0]/font_metrics(res)[fontnum][0])) line=0 - while line*font_metrics[fontnum][1]