Relax font validation in the config

Fixes #2256
This commit is contained in:
Florian Bruhin 2017-02-05 12:51:10 +01:00
parent 112e4a1dad
commit a62062af27
3 changed files with 8 additions and 5 deletions

View File

@ -44,6 +44,8 @@ Fixed
- `:download --mhtml` now uses the new file dialog
- Insert mode now gets entered correctly with a non-100% zoom
- Word hints are now upper-cased correctly when hints -> uppercase is true
- Font validation is now more permissive in the config, allowing e.g. "Terminus
(TTF)" as font name.
v0.9.1
------

View File

@ -741,9 +741,9 @@ class Font(BaseType):
) |
# size (<float>pt | <int>px)
(?P<size>[0-9]+((\.[0-9]+)?[pP][tT]|[pP][xX]))
)\ # size/weight/style are space-separated
)* # 0-inf size/weight/style tags
(?P<family>[A-Za-z0-9, "-]*)$ # mandatory font family""", re.VERBOSE)
)\ # size/weight/style are space-separated
)* # 0-inf size/weight/style tags
(?P<family>.+)$ # mandatory font family""", re.VERBOSE)
def validate(self, value):
self._basic_validation(value)

View File

@ -978,6 +978,8 @@ class TestFont:
'inconsolatazi4':
FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1,
'inconsolatazi4'),
'Terminus (TTF)':
FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1, 'Terminus (TTF)'),
'10pt "Foobar Neue"':
FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'),
'10PT "Foobar Neue"':
@ -1042,7 +1044,7 @@ class TestFont:
font_xfail('green'),
font_xfail('10pt'),
font_xfail('10pt ""'),
'%',
'',
])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
@ -1102,7 +1104,6 @@ class TestFontFamily:
'normal bold 10pt "Foobar Neue"',
'bold italic 10pt "Foobar Neue"',
'', # with none_ok=False
'%',
]
@pytest.fixture