mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
IBM Plex Mono workaround is needed only under fontconfig
This commit is contained in:
parent
2652342544
commit
7fd9bca845
@ -81,15 +81,10 @@ def get_variable_data_for_face(d: Face) -> VariableData:
|
||||
def find_best_match_in_candidates(
|
||||
candidates: List[DescriptorVar], scorer: Scorer, is_medium_face: bool, ignore_face: Optional[DescriptorVar] = None
|
||||
) -> Optional[DescriptorVar]:
|
||||
if not candidates:
|
||||
return None
|
||||
if len(candidates) == 1 and not is_medium_face and candidates[0].get('family') == candidates[0].get('full_name'):
|
||||
# IBM Plex Mono does this, where the full name of the regular font
|
||||
# face is the same as its family name
|
||||
return None
|
||||
for x in scorer.sorted_candidates(candidates):
|
||||
if ignore_face is None or x != ignore_face:
|
||||
return x
|
||||
if candidates:
|
||||
for x in scorer.sorted_candidates(candidates):
|
||||
if ignore_face is None or x != ignore_face:
|
||||
return x
|
||||
return None
|
||||
|
||||
def pprint(*a: Any) -> None:
|
||||
|
@ -182,10 +182,10 @@ def find_best_match(
|
||||
m = font_map[which]
|
||||
cq = m.get(q, [])
|
||||
if cq:
|
||||
if which == 'full_map' and cq[0]['family'] == cq[0]['full_name']:
|
||||
continue # IBM Plex Mono has fullname of regular face == family_name under fontconfig
|
||||
exact_match = find_best_match_in_candidates(cq, scorer, is_medium_face, ignore_face=ignore_face)
|
||||
if exact_match:
|
||||
# dump_sorted_candidates(bold, italic, cq, scorer)
|
||||
assert exact_match['descriptor_type'] == 'fontconfig'
|
||||
return exact_match
|
||||
|
||||
# Use fc-match to see if we can find a monospaced font that matches family
|
||||
|
@ -39,11 +39,14 @@ def both(family: str, *expected: str) -> None:
|
||||
for family in (family, f'family="{family}"'):
|
||||
s(family, *expected)
|
||||
|
||||
def has(family):
|
||||
return family_name_to_key(family) in names
|
||||
def has(family, allow_missing_in_ci=False):
|
||||
ans = family_name_to_key(family) in names
|
||||
if self.is_ci and not allow_missing_in_ci and not ans:
|
||||
raise AssertionError(f'The family: {family} is not available')
|
||||
return ans
|
||||
|
||||
def t(family, psprefix, bold='Bold', italic='Italic', bi='', reg='Regular'):
|
||||
if has(family):
|
||||
def t(family, psprefix, bold='Bold', italic='Italic', bi='', reg='Regular', allow_missing_in_ci=False):
|
||||
if has(family, allow_missing_in_ci=allow_missing_in_ci):
|
||||
bi = bi or bold + italic
|
||||
if reg:
|
||||
reg = '-' + reg
|
||||
@ -53,9 +56,14 @@ def t(family, psprefix, bold='Bold', italic='Italic', bi='', reg='Regular'):
|
||||
t('sourcecodeVf', 'SourceCodeVF', 'Semibold')
|
||||
t('fira code', 'FiraCodeRoman', 'SemiBold', 'Regular', 'SemiBold')
|
||||
t('hack', 'Hack')
|
||||
t('ubuntu mono', 'UbuntuMono')
|
||||
t('liberation mono', 'LiberationMono', reg='')
|
||||
t('ibm plex mono', 'IBMPlexMono', 'SmBld', reg='')
|
||||
t('iosevka fixed', 'Iosevka-Fixed', 'Semibold', reg='', bi='Semibold-Italic', allow_missing_in_ci=True)
|
||||
t('iosevka term', 'Iosevka-Term', 'Semibold', reg='', bi='Semibold-Italic', allow_missing_in_ci=True)
|
||||
t('fantasque sans mono', 'FantasqueSansMono')
|
||||
t('jetbrains mono', 'JetBrainsMono', 'SemiBold')
|
||||
t('consolas', 'Consolas', reg='')
|
||||
t('consolas', 'Consolas', reg='', allow_missing_in_ci=True)
|
||||
if has('cascadia code'):
|
||||
if is_macos:
|
||||
both('cascadia code', 'CascadiaCode-Regular', 'CascadiaCode-Regular_SemiBold', 'CascadiaCode-Italic', 'CascadiaCode-Italic_SemiBold-Italic')
|
||||
@ -66,7 +74,7 @@ def t(family, psprefix, bold='Bold', italic='Italic', bi='', reg='Regular'):
|
||||
both('cascadia mono', 'CascadiaMono-Regular', 'CascadiaMono-Regular_SemiBold', 'CascadiaMono-Italic', 'CascadiaMono-Italic_SemiBold-Italic')
|
||||
else:
|
||||
both('cascadia mono', 'CascadiaMonoRoman-Regular', 'CascadiaMonoRoman-SemiBold', 'CascadiaMono-Italic', 'CascadiaMono-SemiBoldItalic')
|
||||
if has('operator mono'):
|
||||
if has('operator mono', allow_missing_in_ci=True):
|
||||
both('operator mono', 'OperatorMono-Medium', 'OperatorMono-Bold', 'OperatorMono-MediumItalic', 'OperatorMono-BoldItalic')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user