"""Small original single-stroke alphabet; coordinates use a 4 by 6 grid.""" import unicodedata from shapely.geometry import LineString GLYPHS = { "A": ["06 20 46", "14 34"], "B": ["06 00 30 41 32 02", "32 44 35 06"], "C": ["40 10 01 05 16 46"], "D": ["06 00 20 41 45 26 06"], "E": ["40 00 06 46", "03 33"], "F": ["06 00 40", "03 33"], "G": ["40 10 01 05 16 46 43 23"], "H": ["00 06", "40 46", "03 43"], "I": ["00 40", "20 26", "06 46"], "J": ["00 40 45 36 16 05"], "K": ["00 06", "40 03 46"], "L": ["00 06 46"], "M": ["06 00 23 40 46"], "N": ["06 00 46 40"], "O": ["10 30 41 45 36 16 05 01 10"], "P": ["06 00 30 41 32 02"], "Q": ["10 30 41 45 36 16 05 01 10", "24 46"], "R": ["06 00 30 41 32 02", "22 46"], "S": ["40 10 01 12 33 44 35 06"], "T": ["00 40", "20 26"], "U": ["00 05 16 36 45 40"], "V": ["00 26 40"], "W": ["00 16 23 36 40"], "X": ["00 46", "40 06"], "Y": ["00 23 40", "23 26"], "Z": ["00 40 06 46"], "0": ["10 30 41 45 36 16 05 01 10", "05 41"], "1": ["02 20 26", "06 46"], "2": ["01 10 30 41 32 06 46"], "3": ["00 30 41 22 43 45 36 06"], "4": ["00 03 43", "40 46"], "5": ["40 00 03 33 44 35 06"], "6": ["40 10 01 05 16 36 45 34 03"], "7": ["00 40 16"], "8": ["12 01 10 30 41 32 12 03 05 16 36 45 43 32"], "9": ["43 12 01 10 30 41 45 36 06"], "-": ["03 43"], ".": ["25 26"], ",": ["25 16"], ":": ["21 22", "24 25"], "/": ["06 40"], "(": ["30 11 15 36"], ")": ["10 31 35 16"], "?": ["01 10 30 41 32 23 24", "25 26"], "+": ["03 43", "20 26"], "=": ["02 42", "04 44"], "'": ["20 21"], " ": [], } def lettering(text: str, x: float, y: float, height: float) -> list[LineString]: text = unicodedata.normalize("NFKD", text).upper() result = [] for index, character in enumerate(text): if character not in GLYPHS: raise ValueError(f"Unsupported stroke lettering character: {character!r}") for stroke in GLYPHS[character]: points = [ (x + index * height + int(p[0]) * height / 6, y + int(p[1]) * height / 6) for p in stroke.split() ] result.append(LineString(points)) return result