From b76dedcde7a961a27f7d8e6b8ce8cd9181c8b2d0 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Mon, 31 Jul 2023 15:32:53 -0600 Subject: [PATCH] Replace font blocklist with font allowlist --- qgreenland/models/config/layer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qgreenland/models/config/layer.py b/qgreenland/models/config/layer.py index 353d698c..a0c05f60 100644 --- a/qgreenland/models/config/layer.py +++ b/qgreenland/models/config/layer.py @@ -60,18 +60,18 @@ class Layer(QgrBaseModel): @validator("style") @classmethod - def style_file_does_not_contain_blocked_fonts(cls, value): - blocked_fonts = ["Cantarell", "Sans Serif"] + def style_file_only_contains_allowed_fonts(cls, value): + allowed_fonts = ["Open Sans"] if value: style_filepath = _style_filepath(value) tree = ElementTree.parse(style_filepath) for elem in tree.getroot().iter(): if font_family := elem.attrib.get("fontFamily", False): - if font_family in blocked_fonts: + if font_family not in allowed_fonts: raise exc.QgrInvalidConfigError( - f"Style {style_filepath} contains blocked font:" + f"Style {style_filepath} contains disallowed font:" f" '{font_family}'." - f" When in doubt, use 'Open Sans'." + f" Only the following fonts are allowed: {allowed_fonts}." ) return value