Mercurial > emacs
comparison src/w32font.c @ 99854:528e53849f51
(check_face_name): New function.
(add_font_entity_to_list): Use it to filter out common substituted fonts.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sun, 23 Nov 2008 15:07:25 +0000 |
parents | 3c62347bccdb |
children | a63d3e2ae30c |
comparison
equal
deleted
inserted
replaced
99853:6a28cc2ace8a | 99854:528e53849f51 |
---|---|
809 else | 809 else |
810 metrics = NULL; | 810 metrics = NULL; |
811 } | 811 } |
812 | 812 |
813 if (!metrics) | 813 if (!metrics) |
814 { | 814 GetTextMetricsW (dc, &w32_font->metrics); |
815 GetTextMetricsW (dc, &w32_font->metrics); | 815 |
816 } | |
817 | |
818 w32_font->cached_metrics = NULL; | 816 w32_font->cached_metrics = NULL; |
819 w32_font->n_cache_blocks = 0; | 817 w32_font->n_cache_blocks = 0; |
820 | 818 |
821 SelectObject (dc, old_font); | 819 SelectObject (dc, old_font); |
822 release_frame_dc (f, dc); | 820 release_frame_dc (f, dc); |
1298 } | 1296 } |
1299 | 1297 |
1300 return 1; | 1298 return 1; |
1301 } | 1299 } |
1302 | 1300 |
1301 | |
1302 static int | |
1303 check_face_name (font, full_name) | |
1304 LOGFONT *font; | |
1305 char *full_name; | |
1306 { | |
1307 char full_iname[LF_FULLFACESIZE+1]; | |
1308 | |
1309 /* Just check for names known to cause problems, since the full name | |
1310 can contain expanded abbreviations, prefixed foundry, postfixed | |
1311 style, the latter of which sometimes differs from the style indicated | |
1312 in the shorter name (eg Lt becomes Light or even Extra Light) */ | |
1313 | |
1314 /* Helvetica is mapped to Arial in Windows, but if a Type-1 Helvetica is | |
1315 installed, we run into problems with the Uniscribe backend which tries | |
1316 to avoid non-truetype fonts, and ends up mixing the Type-1 Helvetica | |
1317 with Arial's characteristics, since that attempt to use Truetype works | |
1318 some places, but not others. */ | |
1319 if (!stricmp (font->lfFaceName, "helvetica")) | |
1320 { | |
1321 strncpy (full_iname, full_name, LF_FULLFACESIZE); | |
1322 full_iname[LF_FULLFACESIZE] = 0; | |
1323 _strlwr (full_iname); | |
1324 return strstr ("helvetica", full_iname); | |
1325 } | |
1326 else if (!stricmp (font->lfFaceName, "times")) | |
1327 /* Since Times is mapped to Times New Roman, a substring | |
1328 match is not sufficient to filter out the bogus match. */ | |
1329 return stricmp (full_name, "times"); | |
1330 | |
1331 return 1; | |
1332 } | |
1333 | |
1334 | |
1303 /* Callback function for EnumFontFamiliesEx. | 1335 /* Callback function for EnumFontFamiliesEx. |
1304 * Checks if a font matches everything we are trying to check agaist, | 1336 * Checks if a font matches everything we are trying to check agaist, |
1305 * and if so, adds it to a list. Both the data we are checking against | 1337 * and if so, adds it to a list. Both the data we are checking against |
1306 * and the list to which the fonts are added are passed in via the | 1338 * and the list to which the fonts are added are passed in via the |
1307 * lparam argument, in the form of a font_callback_data struct. */ | 1339 * lparam argument, in the form of a font_callback_data struct. */ |
1338 therefore get through this test. Since full names can be prefixed | 1370 therefore get through this test. Since full names can be prefixed |
1339 by a foundry, we accept raster fonts if the font name is found | 1371 by a foundry, we accept raster fonts if the font name is found |
1340 anywhere within the full name. */ | 1372 anywhere within the full name. */ |
1341 && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS | 1373 && (logical_font->elfLogFont.lfOutPrecision != OUT_STRING_PRECIS |
1342 || strstr (logical_font->elfFullName, | 1374 || strstr (logical_font->elfFullName, |
1343 logical_font->elfLogFont.lfFaceName))) | 1375 logical_font->elfLogFont.lfFaceName)) |
1376 /* Check for well known substitutions that mess things up in the | |
1377 presence of Type-1 fonts of the same name. */ | |
1378 && (match_data->pattern.lfFaceName[0] | |
1379 && check_face_name (logical_font, logical_font->elfFullName))) | |
1344 { | 1380 { |
1345 Lisp_Object entity | 1381 Lisp_Object entity |
1346 = w32_enumfont_pattern_entity (match_data->frame, logical_font, | 1382 = w32_enumfont_pattern_entity (match_data->frame, logical_font, |
1347 physical_font, font_type, | 1383 physical_font, font_type, |
1348 &match_data->pattern, | 1384 &match_data->pattern, |