* 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.
This commit is contained in:
parent
f456006161
commit
87f66bd316
1 changed files with 41 additions and 11 deletions
52
src/nsfont.m
52
src/nsfont.m
|
@ -46,6 +46,7 @@
|
|||
|
||||
extern Lisp_Object Qns;
|
||||
extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded;
|
||||
static Lisp_Object Vns_reg_to_script;
|
||||
static Lisp_Object Qapple, Qroman, Qmedium;
|
||||
extern Lisp_Object Qappend;
|
||||
extern int ns_antialias_text;
|
||||
|
@ -301,17 +302,35 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
}
|
||||
|
||||
|
||||
/* Searches the :script, :lang, and :otf extra-bundle properties of the spec
|
||||
for something that can be mapped to a unicode script. Empty string returned
|
||||
if no script spec found.
|
||||
TODO: Eventually registry / encoding should be checked and mapped, but for
|
||||
now the font backend will try script/lang/otf if registry fails, so it is
|
||||
not needed. */
|
||||
/* Convert a font registry, such as */
|
||||
static NSString
|
||||
*ns_registry_to_script (char *reg)
|
||||
{
|
||||
Lisp_Object script, r, rts = Vns_reg_to_script;
|
||||
while CONSP (rts)
|
||||
{
|
||||
r = XCAR (XCAR (rts));
|
||||
if (!strncmp(SDATA(r), reg, strlen(SDATA(r))))
|
||||
{
|
||||
script = XCDR (XCAR (rts));
|
||||
return [NSString stringWithUTF8String: SDATA (SYMBOL_NAME (script))];
|
||||
}
|
||||
rts = XCDR (rts);
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
|
||||
/* Searches the :script, :lang, and :otf extra-bundle properties of the spec,
|
||||
plus registry regular property, for something that can be mapped to a
|
||||
unicode script. Empty string returned if no script spec found. */
|
||||
static NSString
|
||||
*ns_get_req_script (Lisp_Object font_spec)
|
||||
{
|
||||
Lisp_Object reg = AREF (font_spec, FONT_REGISTRY_INDEX);
|
||||
Lisp_Object extra = AREF (font_spec, FONT_EXTRA_INDEX);
|
||||
|
||||
/* The extra-bundle properties have priority. */
|
||||
for ( ; CONSP (extra); extra = XCDR (extra))
|
||||
{
|
||||
Lisp_Object tmp = XCAR (extra);
|
||||
|
@ -327,6 +346,20 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
return ns_otf_to_script (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get here, check the charset portion of the registry. */
|
||||
if (! NILP (reg))
|
||||
{
|
||||
/* XXX: iso10646 is passed in for non-ascii latin-1 characters
|
||||
(which causes box rendering if we don't treat it like iso8858-1)
|
||||
but also for ascii (which causes unnecessary font substitution). */
|
||||
#if 0
|
||||
if (EQ (reg, Qiso10646_1))
|
||||
reg = Qiso8859_1;
|
||||
#endif
|
||||
return ns_registry_to_script (SDATA (SYMBOL_NAME (reg)));
|
||||
}
|
||||
|
||||
return @"";
|
||||
}
|
||||
|
||||
|
@ -466,11 +499,6 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
debug_print (font_spec);
|
||||
}
|
||||
|
||||
/* If has non-unicode registry, give up. */
|
||||
tem = AREF (font_spec, FONT_REGISTRY_INDEX);
|
||||
if (! NILP (tem) && !EQ (tem, Qiso10646_1) && !EQ (tem, Qunicode_bmp))
|
||||
return isMatch ? ns_fallback_entity () : Qnil;
|
||||
|
||||
cFamilies = ns_get_covering_families (ns_get_req_script (font_spec), 0.90);
|
||||
|
||||
fdesc = ns_spec_to_descriptor (font_spec);
|
||||
|
@ -1490,6 +1518,8 @@ - (void)setIntAttribute: (int)attributeTag value: (int)val
|
|||
DEFSYM (Qapple, "apple");
|
||||
DEFSYM (Qroman, "roman");
|
||||
DEFSYM (Qmedium, "medium");
|
||||
DEFVAR_LISP ("ns-reg-to-script", &Vns_reg_to_script,
|
||||
doc: /* Internal use: maps font registry to unicode script. */);
|
||||
}
|
||||
|
||||
// arch-tag: d6c3c6f0-62de-4978-8b1e-b7966fe02cae
|
||||
|
|
Loading…
Add table
Reference in a new issue