- Lisp_Object entity
- = w32_enumfont_pattern_entity (match_data->frame, logical_font,
- physical_font, font_type,
- &match_data->pattern,
- backend);
- if (!NILP (entity))
- {
- Lisp_Object spec_charset = AREF (match_data->orig_font_spec,
- FONT_REGISTRY_INDEX);
-
- /* If registry was specified as iso10646-1, only report
- ANSI and DEFAULT charsets, as most unicode fonts will
- contain one of those plus others. */
- if ((EQ (spec_charset, Qiso10646_1)
- || EQ (spec_charset, Qunicode_bmp)
- || EQ (spec_charset, Qunicode_sip))
- && logical_font->elfLogFont.lfCharSet != DEFAULT_CHARSET
- && logical_font->elfLogFont.lfCharSet != ANSI_CHARSET)
- return 1;
- /* If registry was specified, but did not map to a windows
- charset, only report fonts that have unknown charsets.
- This will still report fonts that don't match, but at
- least it eliminates known definite mismatches. */
- else if (!NILP (spec_charset)
- && !EQ (spec_charset, Qiso10646_1)
- && !EQ (spec_charset, Qunicode_bmp)
- && !EQ (spec_charset, Qunicode_sip)
- && match_data->pattern.lfCharSet == DEFAULT_CHARSET
- && logical_font->elfLogFont.lfCharSet != DEFAULT_CHARSET)
- return 1;
-
- /* If registry was specified, ensure it is reported as the same. */
- if (!NILP (spec_charset))
- ASET (entity, FONT_REGISTRY_INDEX, spec_charset);
-
- match_data->list = Fcons (entity, match_data->list);
-
- /* If no registry specified, duplicate iso8859-1 truetype fonts
- as iso10646-1. */
- if (NILP (spec_charset)
- && font_type == TRUETYPE_FONTTYPE
- && logical_font->elfLogFont.lfCharSet == ANSI_CHARSET)
- {
- Lisp_Object tem = Fcopy_font_spec (entity);
- ASET (tem, FONT_REGISTRY_INDEX, Qiso10646_1);
- match_data->list = Fcons (tem, match_data->list);
- }
- }
+ Lisp_Object spec_charset = AREF (match_data->orig_font_spec,
+ FONT_REGISTRY_INDEX);
+
+ /* iso10646-1 fonts must contain unicode mapping tables. */
+ if (EQ (spec_charset, Qiso10646_1))
+ {
+ if (!is_unicode)
+ return 1;
+ }
+ /* unicode-bmp fonts must contain characters from the BMP. */
+ else if (EQ (spec_charset, Qunicode_bmp))
+ {
+ if (!physical_font->ntmFontSig.fsUsb[3]
+ && !(physical_font->ntmFontSig.fsUsb[2] & 0xFFFFFF9E)
+ && !(physical_font->ntmFontSig.fsUsb[1] & 0xE81FFFFF)
+ && !(physical_font->ntmFontSig.fsUsb[0] & 0x007F001F))
+ return 1;
+ }
+ /* unicode-sip fonts must contain characters in unicode plane 2.
+ so look for bit 57 (surrogates) in the Unicode subranges, plus
+ the bits for CJK ranges that include those characters. */
+ else if (EQ (spec_charset, Qunicode_sip))
+ {
+ if (!physical_font->ntmFontSig.fsUsb[1] & 0x02000000
+ || !physical_font->ntmFontSig.fsUsb[1] & 0x28000000)
+ return 1;
+ }
+
+ /* This font matches. */
+
+ /* If registry was specified, ensure it is reported as the same. */
+ if (!NILP (spec_charset))
+ ASET (entity, FONT_REGISTRY_INDEX, spec_charset);
+
+ /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
+ fonts as unicode and skip other charsets. */
+ else if (match_data->opentype_only)
+ {
+ if (logical_font->elfLogFont.lfCharSet == ANSI_CHARSET
+ || logical_font->elfLogFont.lfCharSet == DEFAULT_CHARSET)
+ ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1);
+ else
+ return 1;
+ }
+
+ /* Add this font to the list. */
+ match_data->list = Fcons (entity, match_data->list);