diff options
| author | Steven Tamm | 2004-12-18 16:36:31 +0000 |
|---|---|---|
| committer | Steven Tamm | 2004-12-18 16:36:31 +0000 |
| commit | fbe6152fad0cd271a9bb766f16a70a8fa988d992 (patch) | |
| tree | c45ab5f252570fd6d32b2bba0b2a710af2cb82bb /src/macterm.c | |
| parent | c138633412ded34ddb448cca51f52cdf7a3edbab (diff) | |
| download | emacs-fbe6152fad0cd271a9bb766f16a70a8fa988d992.tar.gz emacs-fbe6152fad0cd271a9bb766f16a70a8fa988d992.zip | |
* term/mac-win.el (encoding-vector, mac-font-encoder-list)
(ccl-encode-mac-centraleurroman-font): Use centraleurroman
instead of centraleuropean as the name
* macterm.c (endif, x_font_name_to_mac_font_name): Use
maccentraleurroman instead of maccentraleuropean
(mac_c_string_match, mac_do_list_fonts): Speed up font search by
quickly finding a specific font without needing regexps.
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 104 |
1 files changed, 81 insertions, 23 deletions
diff --git a/src/macterm.c b/src/macterm.c index 4e3b0ae1b65..ca15d3c4965 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -5976,7 +5976,7 @@ mac_to_x_fontname (name, size, style, scriptcode, encoding_base) | |||
| 5976 | strcpy(cs, "mac-cyrillic"); | 5976 | strcpy(cs, "mac-cyrillic"); |
| 5977 | break; | 5977 | break; |
| 5978 | case kTextEncodingMacCentralEurRoman: | 5978 | case kTextEncodingMacCentralEurRoman: |
| 5979 | strcpy(cs, "mac-centraleuropean"); | 5979 | strcpy(cs, "mac-centraleurroman"); |
| 5980 | break; | 5980 | break; |
| 5981 | case kTextEncodingMacSymbol: | 5981 | case kTextEncodingMacSymbol: |
| 5982 | case kTextEncodingMacDingbats: | 5982 | case kTextEncodingMacDingbats: |
| @@ -6034,7 +6034,7 @@ x_font_name_to_mac_font_name (char *xf, char *mf) | |||
| 6034 | coding_system = Qeuc_kr; | 6034 | coding_system = Qeuc_kr; |
| 6035 | else if (strcmp (cs, "mac-roman") == 0 | 6035 | else if (strcmp (cs, "mac-roman") == 0 |
| 6036 | || strcmp (cs, "mac-cyrillic") == 0 | 6036 | || strcmp (cs, "mac-cyrillic") == 0 |
| 6037 | || strcmp (cs, "mac-centraleuropean") == 0 | 6037 | || strcmp (cs, "mac-centraleurroman") == 0 |
| 6038 | || strcmp (cs, "adobe-fontspecific") == 0) | 6038 | || strcmp (cs, "adobe-fontspecific") == 0) |
| 6039 | strcpy (mf, family); | 6039 | strcpy (mf, family); |
| 6040 | else | 6040 | else |
| @@ -6276,6 +6276,28 @@ static int xlfd_scalable_fields[] = | |||
| 6276 | }; | 6276 | }; |
| 6277 | 6277 | ||
| 6278 | static Lisp_Object | 6278 | static Lisp_Object |
| 6279 | mac_c_string_match (regexp, string, nonspecial, exact) | ||
| 6280 | Lisp_Object regexp; | ||
| 6281 | const char *string, *nonspecial; | ||
| 6282 | int exact; | ||
| 6283 | { | ||
| 6284 | if (exact) | ||
| 6285 | { | ||
| 6286 | if (strcmp (string, nonspecial) == 0) | ||
| 6287 | return build_string (string); | ||
| 6288 | } | ||
| 6289 | else if (strstr (string, nonspecial)) | ||
| 6290 | { | ||
| 6291 | Lisp_Object str = build_string (string); | ||
| 6292 | |||
| 6293 | if (fast_string_match (regexp, str) >= 0) | ||
| 6294 | return str; | ||
| 6295 | } | ||
| 6296 | |||
| 6297 | return Qnil; | ||
| 6298 | } | ||
| 6299 | |||
| 6300 | static Lisp_Object | ||
| 6279 | mac_do_list_fonts (pattern, maxnames) | 6301 | mac_do_list_fonts (pattern, maxnames) |
| 6280 | char *pattern; | 6302 | char *pattern; |
| 6281 | int maxnames; | 6303 | int maxnames; |
| @@ -6286,6 +6308,8 @@ mac_do_list_fonts (pattern, maxnames) | |||
| 6286 | char scaled[256]; | 6308 | char scaled[256]; |
| 6287 | char *ptr; | 6309 | char *ptr; |
| 6288 | int scl_val[XLFD_SCL_LAST], *field, *val; | 6310 | int scl_val[XLFD_SCL_LAST], *field, *val; |
| 6311 | char *longest_start, *cur_start, *nonspecial; | ||
| 6312 | int longest_len, cur_len, exact; | ||
| 6289 | 6313 | ||
| 6290 | for (i = 0; i < XLFD_SCL_LAST; i++) | 6314 | for (i = 0; i < XLFD_SCL_LAST; i++) |
| 6291 | scl_val[i] = -1; | 6315 | scl_val[i] = -1; |
| @@ -6343,34 +6367,66 @@ mac_do_list_fonts (pattern, maxnames) | |||
| 6343 | ptr = regex; | 6367 | ptr = regex; |
| 6344 | *ptr++ = '^'; | 6368 | *ptr++ = '^'; |
| 6345 | 6369 | ||
| 6346 | /* Turn pattern into a regexp and do a regexp match. */ | 6370 | longest_start = cur_start = ptr; |
| 6371 | longest_len = cur_len = 0; | ||
| 6372 | exact = 1; | ||
| 6373 | |||
| 6374 | /* Turn pattern into a regexp and do a regexp match. Also find the | ||
| 6375 | longest substring containing no special characters. */ | ||
| 6347 | for (; *pattern; pattern++) | 6376 | for (; *pattern; pattern++) |
| 6348 | { | 6377 | { |
| 6349 | if (*pattern == '?') | 6378 | if (*pattern == '?' || *pattern == '*') |
| 6350 | *ptr++ = '.'; | 6379 | { |
| 6351 | else if (*pattern == '*') | 6380 | if (cur_len > longest_len) |
| 6352 | { | 6381 | { |
| 6353 | *ptr++ = '.'; | 6382 | longest_start = cur_start; |
| 6354 | *ptr++ = '*'; | 6383 | longest_len = cur_len; |
| 6355 | } | 6384 | } |
| 6385 | cur_len = 0; | ||
| 6386 | exact = 0; | ||
| 6387 | |||
| 6388 | if (*pattern == '?') | ||
| 6389 | *ptr++ = '.'; | ||
| 6390 | else /* if (*pattern == '*') */ | ||
| 6391 | { | ||
| 6392 | *ptr++ = '.'; | ||
| 6393 | *ptr++ = '*'; | ||
| 6394 | } | ||
| 6395 | } | ||
| 6356 | else | 6396 | else |
| 6357 | *ptr++ = tolower (*pattern); | 6397 | { |
| 6398 | if (cur_len == 0) | ||
| 6399 | cur_start = ptr; | ||
| 6400 | cur_len++; | ||
| 6401 | |||
| 6402 | *ptr++ = tolower (*pattern); | ||
| 6403 | } | ||
| 6358 | } | 6404 | } |
| 6405 | |||
| 6406 | if (cur_len > longest_len) | ||
| 6407 | { | ||
| 6408 | longest_start = cur_start; | ||
| 6409 | longest_len = cur_len; | ||
| 6410 | } | ||
| 6411 | |||
| 6359 | *ptr = '$'; | 6412 | *ptr = '$'; |
| 6360 | *(ptr + 1) = '\0'; | 6413 | *(ptr + 1) = '\0'; |
| 6361 | 6414 | ||
| 6415 | nonspecial = xmalloc (longest_len + 1); | ||
| 6416 | strncpy (nonspecial, longest_start, longest_len); | ||
| 6417 | nonspecial[longest_len] = '\0'; | ||
| 6418 | |||
| 6362 | pattern_regex = build_string (regex); | 6419 | pattern_regex = build_string (regex); |
| 6363 | 6420 | ||
| 6364 | for (i = 0; i < font_name_count; i++) | 6421 | for (i = 0; i < font_name_count; i++) |
| 6365 | { | 6422 | { |
| 6366 | fontname = build_string (font_name_table[i]); | 6423 | fontname = mac_c_string_match (pattern_regex, font_name_table[i], |
| 6367 | if (fast_string_match (pattern_regex, fontname) >= 0) | 6424 | nonspecial, exact); |
| 6425 | if (!NILP (fontname)) | ||
| 6368 | { | 6426 | { |
| 6369 | font_list = Fcons (fontname, font_list); | 6427 | font_list = Fcons (fontname, font_list); |
| 6370 | 6428 | if (exact || maxnames > 0 && ++n_fonts >= maxnames) | |
| 6371 | n_fonts++; | 6429 | return font_list; |
| 6372 | if (maxnames > 0 && n_fonts >= maxnames) | ||
| 6373 | break; | ||
| 6374 | } | 6430 | } |
| 6375 | else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 | 6431 | else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 |
| 6376 | && (ptr = strstr (font_name_table[i], "-0-0-75-75-m-0-"))) | 6432 | && (ptr = strstr (font_name_table[i], "-0-0-75-75-m-0-"))) |
| @@ -6384,17 +6440,19 @@ mac_do_list_fonts (pattern, maxnames) | |||
| 6384 | scl_val[XLFD_SCL_POINT_SIZE], | 6440 | scl_val[XLFD_SCL_POINT_SIZE], |
| 6385 | scl_val[XLFD_SCL_AVGWIDTH], | 6441 | scl_val[XLFD_SCL_AVGWIDTH], |
| 6386 | ptr + sizeof ("-0-0-75-75-m-0-") - 1); | 6442 | ptr + sizeof ("-0-0-75-75-m-0-") - 1); |
| 6387 | fontname = build_string (scaled); | 6443 | fontname = mac_c_string_match (pattern_regex, scaled, |
| 6388 | if (fast_string_match (pattern_regex, fontname) >= 0) | 6444 | nonspecial, exact); |
| 6445 | if (!NILP (fontname)) | ||
| 6389 | { | 6446 | { |
| 6390 | font_list = Fcons (fontname, font_list); | 6447 | font_list = Fcons (fontname, font_list); |
| 6391 | 6448 | if (exact || maxnames > 0 && ++n_fonts >= maxnames) | |
| 6392 | n_fonts++; | 6449 | return font_list; |
| 6393 | if (maxnames > 0 && n_fonts >= maxnames) | ||
| 6394 | break; | ||
| 6395 | } | 6450 | } |
| 6396 | } | 6451 | } |
| 6397 | } | 6452 | } |
| 6453 | |||
| 6454 | xfree (nonspecial); | ||
| 6455 | |||
| 6398 | return font_list; | 6456 | return font_list; |
| 6399 | } | 6457 | } |
| 6400 | 6458 | ||