try to match devfont without style

This commit is contained in:
Vincent Wei
2019-01-13 17:42:27 +08:00
parent 83c8984c74
commit 9ea0e15dba
+26 -7
View File
@@ -191,17 +191,34 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
dev_font = dev_font->next;
}
if (matched_font) {
#ifndef HAVE_ALLOCA
FreeFixStr ((char*)match_bits);
#endif
if (matched_font)
goto matched;
matched_font->font_ops->get_font_size (log_font, matched_font,
log_font->size);
/* try to match without style */
min_error = FONT_MAX_SIZE;
matched_font = NULL;
dev_font = list_head;
for (i = 0; i < list_len; i++) {
int error;
if ((match_bits [i] & MATCHED_TYPE)
&& (match_bits [i] & MATCHED_FAMILY)
&& (match_bits [i] & MATCHED_CHARSET)) {
error = log_font->size -
(*dev_font->font_ops->get_font_size) (log_font, dev_font,
log_font->size);
error = ABS (error);
if (min_error >= error) { /* use >=, make the later has a higher priority */
min_error = error;
matched_font = dev_font;
}
}
return matched_font;
dev_font = dev_font->next;
}
if (matched_font)
goto matched;
min_error = FONT_MAX_SIZE;
dev_font = list_head;
for (i = 0; i < list_len; i++) {
@@ -218,6 +235,8 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
dev_font = dev_font->next;
}
matched:
#ifndef HAVE_ALLOCA
FreeFixStr ((char*)match_bits);
#endif