Handle fonts that are marked as bold but have the same weight as the normal variant
This commit is contained in:
parent
761a121452
commit
3c381b6c55
1 changed files with 5 additions and 0 deletions
|
@ -25,6 +25,7 @@ struct FontMatch {
|
|||
NSCharacterSet *codepoints = nil;
|
||||
int weight = 400;
|
||||
int width = 5;
|
||||
bool bold = false;
|
||||
bool italic = false;
|
||||
bool family_match = false;
|
||||
};
|
||||
|
@ -44,6 +45,7 @@ FontMatch process_descriptor(NSFontDescriptor *desc, NSString *name) {
|
|||
// that
|
||||
auto traits = CTFontGetSymbolicTraits((__bridge CTFontRef)font);
|
||||
ret.italic = !!(traits & kCTFontItalicTrait);
|
||||
ret.bold = !!(traits & kCTFontBoldTrait);
|
||||
if (!ret.italic) {
|
||||
auto data = (__bridge_transfer NSData *)CTFontCopyTable((__bridge CTFontRef)font, kCTFontTableHead, 0);
|
||||
if (data.length > 45) {
|
||||
|
@ -143,6 +145,9 @@ CollectionResult CoreTextFontFileLister::GetFontPaths(std::string const& facenam
|
|||
if (m.weight != best.weight) {
|
||||
return weight_penalty(bold, m.weight) < weight_penalty(bold, best.weight);
|
||||
}
|
||||
else if (m.bold != best.bold) {
|
||||
return m.bold == bold > 550;
|
||||
}
|
||||
if (m.italic != best.italic) {
|
||||
return (m.italic != italic) < (best.italic != italic);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue