diff options
| author | Adrian Robert | 2009-09-23 02:36:57 +0000 |
|---|---|---|
| committer | Adrian Robert | 2009-09-23 02:36:57 +0000 |
| commit | 87f66bd3162d0e068bab6b4da062ec78369943e8 (patch) | |
| tree | 51df4d68df2bdf741091926358654e1cc4800670 /src | |
| parent | f456006161eb12d8ae6e080ef6f1535ef20c9c03 (diff) | |
| download | emacs-87f66bd3162d0e068bab6b4da062ec78369943e8.tar.gz emacs-87f66bd3162d0e068bab6b4da062ec78369943e8.zip | |
* nsfont.m (Vns_reg_to_script): New lisp variable.
(syms_of_nsfont): Declare it.
(ns_registry_to_script): New function.
(ns_get_req_script): Call it.
(ns_findfonts): Don't give up on non-unicode registry.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfont.m | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/src/nsfont.m b/src/nsfont.m index 1359a3e248d..16d6671f7bf 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -46,6 +46,7 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 46 | 46 | ||
| 47 | extern Lisp_Object Qns; | 47 | extern Lisp_Object Qns; |
| 48 | extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; | 48 | extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; |
| 49 | static Lisp_Object Vns_reg_to_script; | ||
| 49 | static Lisp_Object Qapple, Qroman, Qmedium; | 50 | static Lisp_Object Qapple, Qroman, Qmedium; |
| 50 | extern Lisp_Object Qappend; | 51 | extern Lisp_Object Qappend; |
| 51 | extern int ns_antialias_text; | 52 | extern int ns_antialias_text; |
| @@ -301,17 +302,35 @@ static NSString | |||
| 301 | } | 302 | } |
| 302 | 303 | ||
| 303 | 304 | ||
| 304 | /* Searches the :script, :lang, and :otf extra-bundle properties of the spec | 305 | /* Convert a font registry, such as */ |
| 305 | for something that can be mapped to a unicode script. Empty string returned | 306 | static NSString |
| 306 | if no script spec found. | 307 | *ns_registry_to_script (char *reg) |
| 307 | TODO: Eventually registry / encoding should be checked and mapped, but for | 308 | { |
| 308 | now the font backend will try script/lang/otf if registry fails, so it is | 309 | Lisp_Object script, r, rts = Vns_reg_to_script; |
| 309 | not needed. */ | 310 | while CONSP (rts) |
| 311 | { | ||
| 312 | r = XCAR (XCAR (rts)); | ||
| 313 | if (!strncmp(SDATA(r), reg, strlen(SDATA(r)))) | ||
| 314 | { | ||
| 315 | script = XCDR (XCAR (rts)); | ||
| 316 | return [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (script))]; | ||
| 317 | } | ||
| 318 | rts = XCDR (rts); | ||
| 319 | } | ||
| 320 | return @""; | ||
| 321 | } | ||
| 322 | |||
| 323 | |||
| 324 | /* Searches the :script, :lang, and :otf extra-bundle properties of the spec, | ||
| 325 | plus registry regular property, for something that can be mapped to a | ||
| 326 | unicode script. Empty string returned if no script spec found. */ | ||
| 310 | static NSString | 327 | static NSString |
| 311 | *ns_get_req_script (Lisp_Object font_spec) | 328 | *ns_get_req_script (Lisp_Object font_spec) |
| 312 | { | 329 | { |
| 330 | Lisp_Object reg = AREF (font_spec, FONT_REGISTRY_INDEX); | ||
| 313 | Lisp_Object extra = AREF (font_spec, FONT_EXTRA_INDEX); | 331 | Lisp_Object extra = AREF (font_spec, FONT_EXTRA_INDEX); |
| 314 | 332 | ||
| 333 | /* The extra-bundle properties have priority. */ | ||
| 315 | for ( ; CONSP (extra); extra = XCDR (extra)) | 334 | for ( ; CONSP (extra); extra = XCDR (extra)) |
| 316 | { | 335 | { |
| 317 | Lisp_Object tmp = XCAR (extra); | 336 | Lisp_Object tmp = XCAR (extra); |
| @@ -327,6 +346,20 @@ static NSString | |||
| 327 | return ns_otf_to_script (val); | 346 | return ns_otf_to_script (val); |
| 328 | } | 347 | } |
| 329 | } | 348 | } |
| 349 | |||
| 350 | /* If we get here, check the charset portion of the registry. */ | ||
| 351 | if (! NILP (reg)) | ||
| 352 | { | ||
| 353 | /* XXX: iso10646 is passed in for non-ascii latin-1 characters | ||
| 354 | (which causes box rendering if we don't treat it like iso8858-1) | ||
| 355 | but also for ascii (which causes unnecessary font substitution). */ | ||
| 356 | #if 0 | ||
| 357 | if (EQ (reg, Qiso10646_1)) | ||
| 358 | reg = Qiso8859_1; | ||
| 359 | #endif | ||
| 360 | return ns_registry_to_script (SDATA (SYMBOL_NAME (reg))); | ||
| 361 | } | ||
| 362 | |||
| 330 | return @""; | 363 | return @""; |
| 331 | } | 364 | } |
| 332 | 365 | ||
| @@ -466,11 +499,6 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch) | |||
| 466 | debug_print (font_spec); | 499 | debug_print (font_spec); |
| 467 | } | 500 | } |
| 468 | 501 | ||
| 469 | /* If has non-unicode registry, give up. */ | ||
| 470 | tem = AREF (font_spec, FONT_REGISTRY_INDEX); | ||
| 471 | if (! NILP (tem) && !EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp)) | ||
| 472 | return isMatch ? ns_fallback_entity () : Qnil; | ||
| 473 | |||
| 474 | cFamilies = ns_get_covering_families (ns_get_req_script (font_spec), 0.90); | 502 | cFamilies = ns_get_covering_families (ns_get_req_script (font_spec), 0.90); |
| 475 | 503 | ||
| 476 | fdesc = ns_spec_to_descriptor (font_spec); | 504 | fdesc = ns_spec_to_descriptor (font_spec); |
| @@ -1490,6 +1518,8 @@ syms_of_nsfont () | |||
| 1490 | DEFSYM (Qapple, "apple"); | 1518 | DEFSYM (Qapple, "apple"); |
| 1491 | DEFSYM (Qroman, "roman"); | 1519 | DEFSYM (Qroman, "roman"); |
| 1492 | DEFSYM (Qmedium, "medium"); | 1520 | DEFSYM (Qmedium, "medium"); |
| 1521 | DEFVAR_LISP ("ns-reg-to-script", &Vns_reg_to_script, | ||
| 1522 | doc: /* Internal use: maps font registry to unicode script. */); | ||
| 1493 | } | 1523 | } |
| 1494 | 1524 | ||
| 1495 | // arch-tag: d6c3c6f0-62de-4978-8b1e-b7966fe02cae | 1525 | // arch-tag: d6c3c6f0-62de-4978-8b1e-b7966fe02cae |