aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2008-03-07 00:45:44 +0000
committerJason Rumney2008-03-07 00:45:44 +0000
commitc960bff86fd051456c6d1c2bb5ec8aebe57247fa (patch)
treeed324427a3e079ec86a0227e91ed947294924b3f /src
parent239bf18bf24e8e8afee41154d1f73345eab0cc3c (diff)
downloademacs-c960bff86fd051456c6d1c2bb5ec8aebe57247fa.tar.gz
emacs-c960bff86fd051456c6d1c2bb5ec8aebe57247fa.zip
(w32_registry): Take font_type argument. Use ANSI
when charset not specified. Only translate ANSI to unicode when font_type is truetype. (w32font_coverage_ok): New function. (add_font_entity_to_list): Use it to filter unsuitable fonts.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/w32font.c42
2 files changed, 46 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 00e1bc33699..adc68e760f0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12008-03-06 Jason Rumney <jasonr@gnu.org>
2
3 * w32font.c (w32_registry): Take font_type argument. Use ANSI
4 when charset not specified. Only translate ANSI to unicode when
5 font_type is truetype.
6 (w32font_coverage_ok): New function.
7 (add_font_entity_to_list): Use it to filter unsuitable fonts.
8
12008-03-04 Jason Rumney <jasonr@gnu.org> 92008-03-04 Jason Rumney <jasonr@gnu.org>
2 10
3 * makefile.w32-in: Always include w32font.c in the build. 11 * makefile.w32-in: Always include w32font.c in the build.
diff --git a/src/w32font.c b/src/w32font.c
index 63190c1b578..10c2ab99ba9 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -85,7 +85,7 @@ static int w32font_full_name P_ ((LOGFONT * font, Lisp_Object font_obj,
85 int pixel_size, char *name, int nbytes)); 85 int pixel_size, char *name, int nbytes));
86static void recompute_cached_metrics P_ ((HDC dc, struct w32font_info * font)); 86static void recompute_cached_metrics P_ ((HDC dc, struct w32font_info * font));
87 87
88static Lisp_Object w32_registry P_ ((LONG w32_charset)); 88static Lisp_Object w32_registry P_ ((LONG w32_charset, DWORD font_type));
89 89
90/* EnumFontFamiliesEx callbacks. */ 90/* EnumFontFamiliesEx callbacks. */
91static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *, 91static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *,
@@ -942,7 +942,7 @@ w32_enumfont_pattern_entity (frame, logical_font, physical_font,
942 942
943 ASET (entity, FONT_TYPE_INDEX, backend); 943 ASET (entity, FONT_TYPE_INDEX, backend);
944 ASET (entity, FONT_FRAME_INDEX, frame); 944 ASET (entity, FONT_FRAME_INDEX, frame);
945 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet)); 945 ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet, font_type));
946 ASET (entity, FONT_OBJLIST_INDEX, Qnil); 946 ASET (entity, FONT_OBJLIST_INDEX, Qnil);
947 947
948 /* Foundry is difficult to get in readable form on Windows. 948 /* Foundry is difficult to get in readable form on Windows.
@@ -1218,6 +1218,33 @@ font_matches_spec (type, font, spec)
1218 return 1; 1218 return 1;
1219} 1219}
1220 1220
1221static int
1222w32font_coverage_ok (coverage, charset)
1223 FONTSIGNATURE * coverage;
1224 BYTE charset;
1225{
1226 DWORD subrange1 = coverage->fsUsb[1];
1227
1228#define SUBRANGE1_HAN_MASK 0x08000000
1229#define SUBRANGE1_HANGEUL_MASK 0x01000000
1230#define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
1231
1232 if (charset == GB2312_CHARSET || charset == CHINESEBIG5_CHARSET)
1233 {
1234 return (subrange1 & SUBRANGE1_HAN_MASK) == SUBRANGE1_HAN_MASK;
1235 }
1236 else if (charset == SHIFTJIS_CHARSET)
1237 {
1238 return (subrange1 & SUBRANGE1_JAPANESE_MASK) == SUBRANGE1_JAPANESE_MASK;
1239 }
1240 else if (charset == HANGEUL_CHARSET)
1241 {
1242 return (subrange1 & SUBRANGE1_HANGEUL_MASK) == SUBRANGE1_HANGEUL_MASK;
1243 }
1244
1245 return 1;
1246}
1247
1221/* Callback function for EnumFontFamiliesEx. 1248/* Callback function for EnumFontFamiliesEx.
1222 * Checks if a font matches everything we are trying to check agaist, 1249 * Checks if a font matches everything we are trying to check agaist,
1223 * and if so, adds it to a list. Both the data we are checking against 1250 * and if so, adds it to a list. Both the data we are checking against
@@ -1238,6 +1265,8 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam)
1238 && logfonts_match (&logical_font->elfLogFont, &match_data->pattern) 1265 && logfonts_match (&logical_font->elfLogFont, &match_data->pattern)
1239 && font_matches_spec (font_type, physical_font, 1266 && font_matches_spec (font_type, physical_font,
1240 match_data->orig_font_spec) 1267 match_data->orig_font_spec)
1268 && w32font_coverage_ok (&physical_font->ntmFontSig,
1269 match_data->pattern.lfCharSet)
1241 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif) 1270 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
1242 We limit this to raster fonts, because the test can catch some 1271 We limit this to raster fonts, because the test can catch some
1243 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually 1272 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
@@ -1297,10 +1326,15 @@ registry_to_w32_charset (charset)
1297} 1326}
1298 1327
1299static Lisp_Object 1328static Lisp_Object
1300w32_registry (w32_charset) 1329w32_registry (w32_charset, font_type)
1301 LONG w32_charset; 1330 LONG w32_charset;
1331 DWORD font_type;
1302{ 1332{
1303 if (w32_charset == ANSI_CHARSET) 1333 /* If charset is defaulted, use ANSI (unicode for truetype fonts). */
1334 if (w32_charset == DEFAULT_CHARSET)
1335 w32_charset = ANSI_CHARSET;
1336
1337 if (font_type == TRUETYPE_FONTTYPE && w32_charset == ANSI_CHARSET)
1304 return Qiso10646_1; 1338 return Qiso10646_1;
1305 else 1339 else
1306 { 1340 {