From cd18008c97efad014de60d1f9347a8fb07429cab Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 22 Jan 2024 12:19:19 +0000 Subject: [PATCH] Don't crash on non-existant subsets --- Lib/gfsubsets/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/gfsubsets/__init__.py b/Lib/gfsubsets/__init__.py index 572e9a6..0279332 100644 --- a/Lib/gfsubsets/__init__.py +++ b/Lib/gfsubsets/__init__.py @@ -6,6 +6,7 @@ import contextlib import re import sys +import warnings from importlib import resources from fontTools import ttLib @@ -25,6 +26,9 @@ def __getitem__(self, subset): def read_namfile(self, subset): cps = set() ref = nam_files.joinpath(subset + "_unique-glyphs.nam") + if not ref.is_file(): + warnings.warn(f"No such subset '{subset}'") + return cps with ref.open("r", encoding="utf-8") as f: for line in f: if line.startswith("#"):