(let
((encoding-vector (make-vector 256 nil))
(i 0)
- (vec ;; mac-centraleuropean (128..255) -> UCS mapping
+ (vec ;; mac-centraleurroman (128..255) -> UCS mapping
[ #x00C4 ;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
#x0100 ;; 129:LATIN CAPITAL LETTER A WITH MACRON
#x0101 ;; 130:LATIN SMALL LETTER A WITH MACRON
(setq i (1+ i)))
(setq translation-table
(make-translation-table-from-vector encoding-vector))
-;; (define-translation-table 'mac-centraleuropean-decoder translation-table)
- (define-translation-table 'mac-centraleuropean-encoder
+;; (define-translation-table 'mac-centraleurroman-decoder translation-table)
+ (define-translation-table 'mac-centraleurroman-encoder
(char-table-extra-slot translation-table 0)))
(let
(defvar mac-font-encoder-list
'(("mac-roman" mac-roman-encoder
ccl-encode-mac-roman-font "%s")
- ("mac-centraleuropean" mac-centraleuropean-encoder
- ccl-encode-mac-centraleuropean-font "%s ce")
+ ("mac-centraleurroman" mac-centraleurroman-encoder
+ ccl-encode-mac-centraleurroman-font "%s ce")
("mac-cyrillic" mac-cyrillic-encoder
ccl-encode-mac-cyrillic-font "%s cy")))
(if mac-encoded
(aset table c mac-encoded))))))))
-(define-ccl-program ccl-encode-mac-centraleuropean-font
+(define-ccl-program ccl-encode-mac-centraleurroman-font
`(0
(if (r0 != ,(charset-id 'ascii))
(if (r0 <= ?\x8f)
- (translate-character mac-centraleuropean-encoder r0 r1)
+ (translate-character mac-centraleurroman-encoder r0 r1)
((r1 <<= 7)
(r1 |= r2)
- (translate-character mac-centraleuropean-encoder r0 r1)))))
- "CCL program for Mac Central European font")
+ (translate-character mac-centraleurroman-encoder r0 r1)))))
+ "CCL program for Mac Central European Roman font")
(define-ccl-program ccl-encode-mac-cyrillic-font
`(0
strcpy(cs, "mac-cyrillic");
break;
case kTextEncodingMacCentralEurRoman:
- strcpy(cs, "mac-centraleuropean");
+ strcpy(cs, "mac-centraleurroman");
break;
case kTextEncodingMacSymbol:
case kTextEncodingMacDingbats:
coding_system = Qeuc_kr;
else if (strcmp (cs, "mac-roman") == 0
|| strcmp (cs, "mac-cyrillic") == 0
- || strcmp (cs, "mac-centraleuropean") == 0
+ || strcmp (cs, "mac-centraleurroman") == 0
|| strcmp (cs, "adobe-fontspecific") == 0)
strcpy (mf, family);
else
-1
};
+static Lisp_Object
+mac_c_string_match (regexp, string, nonspecial, exact)
+ Lisp_Object regexp;
+ const char *string, *nonspecial;
+ int exact;
+{
+ if (exact)
+ {
+ if (strcmp (string, nonspecial) == 0)
+ return build_string (string);
+ }
+ else if (strstr (string, nonspecial))
+ {
+ Lisp_Object str = build_string (string);
+
+ if (fast_string_match (regexp, str) >= 0)
+ return str;
+ }
+
+ return Qnil;
+}
+
static Lisp_Object
mac_do_list_fonts (pattern, maxnames)
char *pattern;
char scaled[256];
char *ptr;
int scl_val[XLFD_SCL_LAST], *field, *val;
+ char *longest_start, *cur_start, *nonspecial;
+ int longest_len, cur_len, exact;
for (i = 0; i < XLFD_SCL_LAST; i++)
scl_val[i] = -1;
ptr = regex;
*ptr++ = '^';
- /* Turn pattern into a regexp and do a regexp match. */
+ longest_start = cur_start = ptr;
+ longest_len = cur_len = 0;
+ exact = 1;
+
+ /* Turn pattern into a regexp and do a regexp match. Also find the
+ longest substring containing no special characters. */
for (; *pattern; pattern++)
{
- if (*pattern == '?')
- *ptr++ = '.';
- else if (*pattern == '*')
- {
- *ptr++ = '.';
- *ptr++ = '*';
- }
+ if (*pattern == '?' || *pattern == '*')
+ {
+ if (cur_len > longest_len)
+ {
+ longest_start = cur_start;
+ longest_len = cur_len;
+ }
+ cur_len = 0;
+ exact = 0;
+
+ if (*pattern == '?')
+ *ptr++ = '.';
+ else /* if (*pattern == '*') */
+ {
+ *ptr++ = '.';
+ *ptr++ = '*';
+ }
+ }
else
- *ptr++ = tolower (*pattern);
+ {
+ if (cur_len == 0)
+ cur_start = ptr;
+ cur_len++;
+
+ *ptr++ = tolower (*pattern);
+ }
}
+
+ if (cur_len > longest_len)
+ {
+ longest_start = cur_start;
+ longest_len = cur_len;
+ }
+
*ptr = '$';
*(ptr + 1) = '\0';
+ nonspecial = xmalloc (longest_len + 1);
+ strncpy (nonspecial, longest_start, longest_len);
+ nonspecial[longest_len] = '\0';
+
pattern_regex = build_string (regex);
for (i = 0; i < font_name_count; i++)
{
- fontname = build_string (font_name_table[i]);
- if (fast_string_match (pattern_regex, fontname) >= 0)
+ fontname = mac_c_string_match (pattern_regex, font_name_table[i],
+ nonspecial, exact);
+ if (!NILP (fontname))
{
font_list = Fcons (fontname, font_list);
-
- n_fonts++;
- if (maxnames > 0 && n_fonts >= maxnames)
- break;
+ if (exact || maxnames > 0 && ++n_fonts >= maxnames)
+ return font_list;
}
else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0
&& (ptr = strstr (font_name_table[i], "-0-0-75-75-m-0-")))
scl_val[XLFD_SCL_POINT_SIZE],
scl_val[XLFD_SCL_AVGWIDTH],
ptr + sizeof ("-0-0-75-75-m-0-") - 1);
- fontname = build_string (scaled);
- if (fast_string_match (pattern_regex, fontname) >= 0)
+ fontname = mac_c_string_match (pattern_regex, scaled,
+ nonspecial, exact);
+ if (!NILP (fontname))
{
font_list = Fcons (fontname, font_list);
-
- n_fonts++;
- if (maxnames > 0 && n_fonts >= maxnames)
- break;
+ if (exact || maxnames > 0 && ++n_fonts >= maxnames)
+ return font_list;
}
}
}
+
+ xfree (nonspecial);
+
return font_list;
}