1#!/usr/local/bin/python3.8
2
3import os
4
5# Parses a single repacking test file. The first line of the file is
6# the name of the font to use and the remaining lines define the set of
7# codepoints in the subset.
8class RepackTest:
9
10	def __init__(self, test_path, definition):
11		self.test_path = test_path
12		self.font_name = None
13		self.codepoints = set ()
14		self._parse(definition)
15
16	def font_path(self):
17		return os.path.join (self._base_path (), "fonts", self.font_name)
18
19	def codepoints_string (self):
20		return ",".join (self.codepoints)
21
22	def _base_path(self):
23	        return os.path.join(
24		    os.path.dirname(self.test_path),
25		    "../")
26
27
28	def _parse(self, definition):
29		lines = definition.splitlines ()
30		self.font_name = lines.pop (0)
31		for line in lines:
32			line = line.strip()
33			if not line:
34				continue
35
36			self.codepoints.add (line)
37