IBM Plex Mono workaround is needed only under fontconfig

This commit is contained in:
Kovid Goyal
2024-05-16 09:56:58 +05:30
parent 2652342544
commit 7fd9bca845
3 changed files with 20 additions and 17 deletions

View File

@@ -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:

View File

@@ -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