From 06dbac6efd98be5a015023c88ed3dbd9a35a4594 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 1 Aug 2020 00:01:17 +0200 Subject: =?UTF-8?q?Port=20font=20handling=20to=20fontdock=20and=20ttf-pars?= =?UTF-8?q?er=20=F0=9F=9B=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use fontdock for indexing fonts and querying - Typst binary now automatically indexes and uses system fonts in addition to a fixed font folder! - Removes subsetting support for now (was half-finished anyways, plan is to use harfbuzz for subsetting in the future) - Adds font width configuration support --- tests/src/render.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/src/render.py') diff --git a/tests/src/render.py b/tests/src/render.py index 30289c3b..0ef8ae2b 100644 --- a/tests/src/render.py +++ b/tests/src/render.py @@ -29,10 +29,10 @@ class MultiboxRenderer: def __init__(self, data): self.combined = None - self.fonts = {} - for entry in data["fonts"]: - index = int(entry[0]["id"]), int(entry[0]["variant"]) - self.fonts[index] = os.path.join(BASE, '../../../fonts', entry[1]) + self.faces = {} + for entry in data["faces"]: + face_id = int(entry[0]["index"]), int(entry[0]["variant"]) + self.faces[face_id] = os.path.join(BASE, '../../../fonts', entry[1]) self.layouts = data["layouts"] @@ -45,7 +45,7 @@ class MultiboxRenderer: for layout in self.layouts: size = layout["dimensions"] - renderer = BoxRenderer(self.fonts, size["x"], size["y"]) + renderer = BoxRenderer(self.faces, size["x"], size["y"]) for action in layout["actions"]: renderer.execute(action) @@ -87,8 +87,8 @@ class MultiboxRenderer: class BoxRenderer: - def __init__(self, fonts, width, height, grid=False): - self.fonts = fonts + def __init__(self, faces, width, height, grid=False): + self.faces = faces self.size = (pix(width), pix(height)) img = Image.new('RGBA', self.size, (255, 255, 255, 255)) @@ -126,9 +126,9 @@ class BoxRenderer: self.cursor = [pix(args[0]["x"]), pix(args[0]["y"])] elif cmd == 1: - index = int(args[0]["id"]), int(args[0]["variant"]) + face_id = int(args[0]["index"]), int(args[0]["variant"]) size = pix(args[1]) - self.font = ImageFont.truetype(self.fonts[index], size) + self.font = ImageFont.truetype(self.faces[face_id], size) elif cmd == 2: text = args[0] -- cgit v1.2.3