2123 |
} |
} |
2124 |
|
|
2125 |
|
|
|
/* Return an ASCII font name generated from fontset name NAME and |
|
|
ASCII font specification ASCII_SPEC. NAME is a string conforming |
|
|
to XLFD. ASCII_SPEC is a vector: |
|
|
[FAMILY WEIGHT SLANT SWIDTH ADSTYLE REGISTRY]. */ |
|
|
|
|
2126 |
Lisp_Object |
Lisp_Object |
2127 |
generate_ascii_font_name (name, ascii_spec) |
split_font_name_into_vector (fontname) |
2128 |
Lisp_Object name, ascii_spec; |
Lisp_Object fontname; |
2129 |
{ |
{ |
2130 |
struct font_name font; |
struct font_name font; |
2131 |
char *p; |
Lisp_Object vec; |
2132 |
|
int i; |
2133 |
|
|
2134 |
font.name = LSTRDUPA (name); |
font.name = LSTRDUPA (fontname); |
2135 |
if (! split_font_name (NULL, &font, 0)) |
if (! split_font_name (NULL, &font, 0)) |
2136 |
return Qnil; |
return Qnil; |
2137 |
|
vec = Fmake_vector (make_number (XLFD_LAST), Qnil); |
2138 |
|
for (i = 0; i < XLFD_LAST; i++) |
2139 |
|
if (font.fields[i][0] != '*') |
2140 |
|
ASET (vec, i, build_string (font.fields[i])); |
2141 |
|
return vec; |
2142 |
|
} |
2143 |
|
|
2144 |
|
Lisp_Object |
2145 |
|
build_font_name_from_vector (vec) |
2146 |
|
Lisp_Object vec; |
2147 |
|
{ |
2148 |
|
struct font_name font; |
2149 |
|
Lisp_Object fontname; |
2150 |
|
char *p; |
2151 |
|
int i; |
2152 |
|
|
2153 |
if (STRINGP (AREF (ascii_spec, FONT_SPEC_FAMILY_INDEX))) |
for (i = 0; i < XLFD_LAST; i++) |
2154 |
{ |
{ |
2155 |
p = LSTRDUPA (AREF (ascii_spec, FONT_SPEC_FAMILY_INDEX)); |
font.fields[i] = (NILP (AREF (vec, i)) |
2156 |
font.fields[XLFD_FOUNDRY] = p; |
? "*" : (char *) XSTRING (AREF (vec, i))->data); |
2157 |
while (*p != '-') p++; |
if ((i == XLFD_FAMILY || i == XLFD_REGISTRY) |
2158 |
if (*p) |
&& (p = strchr (font.fields[i], '-'))) |
2159 |
{ |
{ |
2160 |
*p++ = 0; |
char *p1 = STRDUPA (font.fields[i]); |
2161 |
font.fields[XLFD_FAMILY] = p; |
|
2162 |
} |
p1[p - font.fields[i]] = '\0'; |
2163 |
else |
if (i == XLFD_FAMILY) |
2164 |
{ |
{ |
2165 |
font.fields[XLFD_FAMILY] = font.fields[XLFD_FOUNDRY]; |
font.fields[XLFD_FOUNDRY] = p1; |
2166 |
font.fields[XLFD_FOUNDRY] = "*"; |
font.fields[XLFD_FAMILY] = p + 1; |
2167 |
|
} |
2168 |
|
else |
2169 |
|
{ |
2170 |
|
font.fields[XLFD_REGISTRY] = p1; |
2171 |
|
font.fields[XLFD_ENCODING] = p + 1; |
2172 |
|
break; |
2173 |
|
} |
2174 |
} |
} |
2175 |
} |
} |
|
if (STRINGP (AREF (ascii_spec, FONT_SPEC_WEIGHT_INDEX))) |
|
|
font.fields[XLFD_WEIGHT] |
|
|
= XSTRING (AREF (ascii_spec, FONT_SPEC_WEIGHT_INDEX))->data; |
|
|
if (STRINGP (AREF (ascii_spec, FONT_SPEC_SLANT_INDEX))) |
|
|
font.fields[XLFD_SLANT] |
|
|
= XSTRING (AREF (ascii_spec, FONT_SPEC_SLANT_INDEX))->data; |
|
|
if (STRINGP (AREF (ascii_spec, FONT_SPEC_SWIDTH_INDEX))) |
|
|
font.fields[XLFD_SWIDTH] |
|
|
= XSTRING (AREF (ascii_spec, FONT_SPEC_SWIDTH_INDEX))->data; |
|
|
if (STRINGP (AREF (ascii_spec, FONT_SPEC_ADSTYLE_INDEX))) |
|
|
font.fields[XLFD_ADSTYLE] |
|
|
= XSTRING (AREF (ascii_spec, FONT_SPEC_ADSTYLE_INDEX))->data; |
|
|
p = LSTRDUPA (AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX)); |
|
|
font.fields[XLFD_REGISTRY] = p; |
|
|
while (*p != '-') p++; |
|
|
if (*p) |
|
|
*p++ = 0; |
|
|
else |
|
|
p = "*"; |
|
|
font.fields[XLFD_ENCODING] = p; |
|
2176 |
|
|
2177 |
p = build_font_name (&font); |
p = build_font_name (&font); |
2178 |
name = build_string (p); |
fontname = build_string (p); |
2179 |
xfree (p); |
xfree (p); |
2180 |
return name; |
return fontname; |
|
} |
|
|
|
|
|
|
|
|
Lisp_Object |
|
|
font_name_registry (fontname) |
|
|
Lisp_Object fontname; |
|
|
{ |
|
|
struct font_name font; |
|
|
|
|
|
font.name = LSTRDUPA (fontname); |
|
|
if (! split_font_name (NULL, &font, 0)) |
|
|
return Qnil; |
|
|
font.fields[XLFD_ENCODING][-1] = '-'; |
|
|
return build_string (font.fields[XLFD_REGISTRY]); |
|
2181 |
} |
} |
2182 |
|
|
2183 |
#ifdef HAVE_WINDOW_SYSTEM |
#ifdef HAVE_WINDOW_SYSTEM |
2716 |
|
|
2717 |
If PATTERN is non-nil, list fonts matching that pattern. |
If PATTERN is non-nil, list fonts matching that pattern. |
2718 |
|
|
2719 |
If REGISTRY is non-nil, return fonts with that registry and the |
If REGISTRY is non-nil, it is a list of registry (and encoding) |
2720 |
alternative registries from Vface_alternative_font_registry_alist. |
names. Return fonts with those registries and the alternative |
2721 |
|
registries from Vface_alternative_font_registry_alist. |
2722 |
|
|
2723 |
If REGISTRY is nil return fonts of any registry. |
If REGISTRY is nil return fonts of any registry. |
2724 |
|
|
2732 |
Lisp_Object pattern, family, registry; |
Lisp_Object pattern, family, registry; |
2733 |
struct font_name **fonts; |
struct font_name **fonts; |
2734 |
{ |
{ |
2735 |
int nfonts = font_list_1 (f, pattern, family, registry, fonts); |
int nfonts; |
2736 |
|
int reg_prio; |
2737 |
if (!NILP (registry) |
int i; |
|
&& CONSP (Vface_alternative_font_registry_alist)) |
|
|
{ |
|
|
Lisp_Object alter; |
|
|
|
|
|
alter = Fassoc (registry, Vface_alternative_font_registry_alist); |
|
|
if (CONSP (alter)) |
|
|
{ |
|
|
int reg_prio, i; |
|
2738 |
|
|
2739 |
for (alter = XCDR (alter), reg_prio = 1; |
if (NILP (registry)) |
2740 |
CONSP (alter); |
return font_list_1 (f, pattern, family, registry, fonts); |
|
alter = XCDR (alter), reg_prio++) |
|
|
if (STRINGP (XCAR (alter))) |
|
|
{ |
|
|
int nfonts2; |
|
|
struct font_name *fonts2; |
|
2741 |
|
|
2742 |
nfonts2 = font_list_1 (f, pattern, family, XCAR (alter), |
for (reg_prio = 0, nfonts = 0; CONSP (registry); registry = XCDR (registry)) |
2743 |
&fonts2); |
{ |
2744 |
|
Lisp_Object elt, alter; |
2745 |
|
int nfonts2; |
2746 |
|
struct font_name *fonts2; |
2747 |
|
|
2748 |
|
elt = XCAR (registry); |
2749 |
|
alter = Fassoc (elt, Vface_alternative_font_registry_alist); |
2750 |
|
if (NILP (alter)) |
2751 |
|
alter = Fcons (elt, Qnil); |
2752 |
|
for (; CONSP (alter); alter = XCDR (alter), reg_prio++) |
2753 |
|
{ |
2754 |
|
nfonts2 = font_list_1 (f, pattern, family, XCAR (alter), &fonts2); |
2755 |
|
if (nfonts2 > 0) |
2756 |
|
{ |
2757 |
|
if (reg_prio > 0) |
2758 |
for (i = 0; i < nfonts2; i++) |
for (i = 0; i < nfonts2; i++) |
2759 |
fonts2[i].registry_priority = reg_prio; |
fonts2[i].registry_priority = reg_prio; |
2760 |
*fonts = (nfonts > 0 |
if (nfonts > 0) |
2761 |
? concat_font_list (*fonts, nfonts, fonts2, nfonts2) |
*fonts = concat_font_list (*fonts, nfonts, fonts2, nfonts2); |
2762 |
: fonts2); |
else |
2763 |
nfonts += nfonts2; |
*fonts = fonts2; |
2764 |
} |
nfonts += nfonts2; |
2765 |
|
} |
2766 |
} |
} |
2767 |
} |
} |
2768 |
|
|
6273 |
|
|
6274 |
/* If we are choosing an ASCII font and a font name is explicitly |
/* If we are choosing an ASCII font and a font name is explicitly |
6275 |
specified in ATTRS, return it. */ |
specified in ATTRS, return it. */ |
|
#if 0 |
|
6276 |
if (NILP (font_spec) && STRINGP (attrs[LFACE_FONT_INDEX])) |
if (NILP (font_spec) && STRINGP (attrs[LFACE_FONT_INDEX])) |
6277 |
return xstrdup (XSTRING (attrs[LFACE_FONT_INDEX])->data); |
return xstrdup (XSTRING (attrs[LFACE_FONT_INDEX])->data); |
|
#endif |
|
6278 |
|
|
6279 |
if (NILP (attrs[LFACE_FAMILY_INDEX])) |
if (NILP (attrs[LFACE_FAMILY_INDEX])) |
6280 |
family = Qnil; |
family = Qnil; |
6281 |
else |
else |
6282 |
family = Fcons (attrs[LFACE_FAMILY_INDEX], Qnil); |
family = Fcons (attrs[LFACE_FAMILY_INDEX], Qnil); |
6283 |
|
|
6284 |
|
/* Decide FAMILY, ADSTYLE, and REGISTRY from FONT_SPEC. But, |
6285 |
|
ADSTYLE is not used in the font selector for the moment. */ |
6286 |
if (VECTORP (font_spec)) |
if (VECTORP (font_spec)) |
6287 |
{ |
{ |
6288 |
pattern = Qnil; |
pattern = Qnil; |
6289 |
if (STRINGP (AREF (font_spec, FONT_SPEC_FAMILY_INDEX))) |
if (STRINGP (AREF (font_spec, FONT_SPEC_FAMILY_INDEX))) |
6290 |
family = Fcons (AREF (font_spec, FONT_SPEC_FAMILY_INDEX), family); |
family = Fcons (AREF (font_spec, FONT_SPEC_FAMILY_INDEX), family); |
6291 |
adstyle = AREF (font_spec, FONT_SPEC_ADSTYLE_INDEX); |
adstyle = AREF (font_spec, FONT_SPEC_ADSTYLE_INDEX); |
6292 |
registry = AREF (font_spec, FONT_SPEC_REGISTRY_INDEX); |
registry = Fcons (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX), Qnil); |
6293 |
} |
} |
6294 |
else if (STRINGP (font_spec)) |
else if (STRINGP (font_spec)) |
6295 |
{ |
{ |
6300 |
} |
} |
6301 |
else |
else |
6302 |
{ |
{ |
6303 |
|
/* We are choosing an ASCII font. By default, use the registry |
6304 |
|
name "iso8859-1". But, if the registry name of the ASCII |
6305 |
|
font specified in the fontset of ATTRS is not "iso8859-1" |
6306 |
|
(e.g "iso10646-1"), use also that name with higher |
6307 |
|
priority. */ |
6308 |
|
int fontset = face_fontset (attrs); |
6309 |
|
Lisp_Object ascii; |
6310 |
|
int len; |
6311 |
|
struct font_name font; |
6312 |
|
|
6313 |
pattern = Qnil; |
pattern = Qnil; |
6314 |
adstyle = Qnil; |
adstyle = Qnil; |
6315 |
registry = build_string ("iso8859-1"); |
registry = Fcons (build_string ("iso8859-1"), Qnil); |
6316 |
|
|
6317 |
|
ascii = fontset_ascii (fontset); |
6318 |
|
len = STRING_BYTES (XSTRING (ascii)); |
6319 |
|
if (len < 9 |
6320 |
|
|| strcmp (XSTRING (ascii)->data + len - 9, "iso8859-1")) |
6321 |
|
{ |
6322 |
|
font.name = LSTRDUPA (ascii); |
6323 |
|
/* Check if the name is in XLFD. */ |
6324 |
|
if (split_font_name (f, &font, 0)) |
6325 |
|
{ |
6326 |
|
font.fields[XLFD_ENCODING][-1] = '-'; |
6327 |
|
registry = Fcons (build_string (font.fields[XLFD_REGISTRY]), |
6328 |
|
registry); |
6329 |
|
} |
6330 |
|
} |
6331 |
} |
} |
6332 |
|
|
6333 |
/* Get a list of fonts matching that pattern and choose the |
/* Get a list of fonts matching that pattern and choose the |