diff options
author | Jason Rumney <[email protected]> | 2008-11-23 15:08:52 +0000 |
---|---|---|
committer | Jason Rumney <[email protected]> | 2008-11-23 15:08:52 +0000 |
commit | b0857706e4bc6d09dc04f46766f6bde39a836f80 (patch) | |
tree | 534c3b6c545ec50dee770ad423708598200e4ffd /src | |
parent | a608bcbf777d126198b046c317af58cf4f373002 (diff) |
(check_face_name): New function.
(add_font_entity_to_list): Use it to filter out common substituted fonts.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 9 | ||||
-rw-r--r-- | src/w32font.c | 46 |
2 files changed, 50 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9d1be5d6ab..21f54c61df 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2008-11-23 Jason Rumney <[email protected]> + + * w32uniscribe.c (uniscribe_encode_char): Ensure context is + restored before returning. + + * w32font.c (check_face_name): New function. + (add_font_entity_to_list): Use it to filter out common substituted + fonts. + 2008-11-22 Martin Rudalics <[email protected]> * buffer.c (Fswitch_to_buffer): Reword and mention new option diff --git a/src/w32font.c b/src/w32font.c index 74c74ee075..94dad4367f 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -811,10 +811,8 @@ w32font_open_internal (f, font_entity, pixel_size, font_object) } if (!metrics) - { - GetTextMetricsW (dc, &w32_font->metrics); - } - + GetTextMetricsW (dc, &w32_font->metrics); + w32_font->cached_metrics = NULL; w32_font->n_cache_blocks = 0; @@ -1300,6 +1298,40 @@ w32font_coverage_ok (coverage, charset) return 1; } + +static int +check_face_name (font, full_name) + LOGFONT *font; + char *full_name; +{ + char full_iname[LF_FULLFACESIZE+1]; + + /* Just check for names known to cause problems, since the full name + can contain expanded abbreviations, prefixed foundry, postfixed + style, the latter of which sometimes differs from the style indicated + in the shorter name (eg Lt becomes Light or even Extra Light) */ + + /* Helvetica is mapped to Arial in Windows, but if a Type-1 Helvetica is + installed, we run into problems with the Uniscribe backend which tries + to avoid non-truetype fonts, and ends up mixing the Type-1 Helvetica + with Arial's characteristics, since that attempt to use Truetype works + some places, but not others. */ + if (!stricmp (font->lfFaceName, "helvetica")) + { + strncpy (full_iname, full_name, LF_FULLFACESIZE); + full_iname[LF_FULLFACESIZE] = 0; + _strlwr (full_iname); + return strstr ("helvetica", full_iname); + } + else if (!stricmp (font->lfFaceName, "times")) + /* Since Times is mapped to Times New Roman, a substring + match is not sufficient to filter out the bogus match. */ + return stricmp (full_name, "times"); + + return 1; +} + + /* Callback function for EnumFontFamiliesEx. * Checks if a font matches everything we are trying to check agaist, * and if so, adds it to a list. Both the data we are checking against @@ -1340,7 +1372,11 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam) anywhere within the full name. */ && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS || strstr (logical_font->elfFullName, - logical_font->elfLogFont.lfFaceName))) + logical_font->elfLogFont.lfFaceName)) + /* Check for well known substitutions that mess things up in the + presence of Type-1 fonts of the same name. */ + && (match_data->pattern.lfFaceName[0] + && check_face_name (logical_font, logical_font->elfFullName))) { Lisp_Object entity = w32_enumfont_pattern_entity (match_data->frame, logical_font, |