Use ${_monospace} for default hints font

This commit is contained in:
Florian Bruhin 2016-08-17 12:42:24 +02:00
parent 016349941b
commit 7c17af3889
4 changed files with 22 additions and 2 deletions

View File

@ -2194,7 +2194,7 @@ Default: +pass:[8pt ${_monospace}]+
=== hints
Font used for the hints.
Default: +pass:[bold 13px Monospace]+
Default: +pass:[bold 13px ${_monospace}]+
[[fonts-debug-console]]
=== debug-console

View File

@ -322,6 +322,16 @@ def _transform_hint_color(val):
return val
def _transform_hint_font(val):
"""Transformer for fonts -> hints."""
match = re.fullmatch(r'(.*\d+p[xt]) Monospace', val)
if match:
# Close enough to the old default:
return match.group(1) + ' ${_monospace}'
else:
return val
class ConfigManager(QObject):
"""Configuration manager for qutebrowser.
@ -407,6 +417,7 @@ class ConfigManager(QObject):
('colors', 'hints.bg'): _transform_hint_color,
('colors', 'hints.fg'): _transform_hint_color,
('colors', 'hints.fg.match'): _transform_hint_color,
('fonts', 'hints'): _transform_hint_font,
}
changed = pyqtSignal(str, str)

View File

@ -1305,7 +1305,7 @@ def data(readonly=False):
"Font used for the downloadbar."),
('hints',
SettingValue(typ.Font(), 'bold 13px Monospace'),
SettingValue(typ.Font(), 'bold 13px ${_monospace}'),
"Font used for the hints."),
('debug-console',

View File

@ -256,6 +256,15 @@ class TestTransformers:
def test_hint_color(self, val, expected):
assert config._transform_hint_color(val) == expected
@pytest.mark.parametrize('val, expected', [
('bold 12pt Monospace', 'bold 12pt ${_monospace}'),
('23pt Monospace', '23pt ${_monospace}'),
('bold 12pt ${_monospace}', 'bold 12pt ${_monospace}'),
('bold 12pt Comic Sans MS', 'bold 12pt Comic Sans MS'),
])
def test_hint_font(self, val, expected):
assert config._transform_hint_font(val) == expected
class TestKeyConfigParser: