summaryrefslogtreecommitdiff
path: root/devdocs/elisp/fontsets.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/fontsets.html')
-rw-r--r--devdocs/elisp/fontsets.html31
1 files changed, 31 insertions, 0 deletions
diff --git a/devdocs/elisp/fontsets.html b/devdocs/elisp/fontsets.html
new file mode 100644
index 00000000..5623ec9e
--- /dev/null
+++ b/devdocs/elisp/fontsets.html
@@ -0,0 +1,31 @@
+ <h4 class="subsection">Fontsets</h4> <p>A <em>fontset</em> is a list of fonts, each assigned to a range of character codes. An individual font cannot display the whole range of characters that Emacs supports, but a fontset can. Fontsets have names, just as fonts do, and you can use a fontset name in place of a font name when you specify the font for a frame or a face. Here is information about defining a fontset under Lisp program control. </p> <dl> <dt id="create-fontset-from-fontset-spec">Function: <strong>create-fontset-from-fontset-spec</strong> <em>fontset-spec &amp;optional style-variant-p noerror</em>
+</dt> <dd>
+<p>This function defines a new fontset according to the specification string <var>fontset-spec</var>. The string should have this format: </p> <div class="example"> <pre class="example"><var>fontpattern</var>, <span class="roman">[</span><var>charset</var>:<var>font</var><span class="roman">]…</span>
+</pre>
+</div> <p>Whitespace characters before and after the commas are ignored. </p> <p>The first part of the string, <var>fontpattern</var>, should have the form of a standard X font name, except that the last two fields should be ‘<samp>fontset-<var>alias</var></samp>’. </p> <p>The new fontset has two names, one long and one short. The long name is <var>fontpattern</var> in its entirety. The short name is ‘<samp>fontset-<var>alias</var></samp>’. You can refer to the fontset by either name. If a fontset with the same name already exists, an error is signaled, unless <var>noerror</var> is non-<code>nil</code>, in which case this function does nothing. </p> <p>If optional argument <var>style-variant-p</var> is non-<code>nil</code>, that says to create bold, italic and bold-italic variants of the fontset as well. These variant fontsets do not have a short name, only a long one, which is made by altering <var>fontpattern</var> to indicate the bold and/or italic status. </p> <p>The specification string also says which fonts to use in the fontset. See below for the details. </p>
+</dd>
+</dl> <p>The construct ‘<samp><var>charset</var>:<var>font</var></samp>’ specifies which font to use (in this fontset) for one particular character set. Here, <var>charset</var> is the name of a character set, and <var>font</var> is the font to use for that character set. You can use this construct any number of times in the specification string. </p> <p>For the remaining character sets, those that you don’t specify explicitly, Emacs chooses a font based on <var>fontpattern</var>: it replaces ‘<samp>fontset-<var>alias</var></samp>’ with a value that names one character set. For the <acronym>ASCII</acronym> character set, ‘<samp>fontset-<var>alias</var></samp>’ is replaced with ‘<samp>ISO8859-1</samp>’. </p> <p>In addition, when several consecutive fields are wildcards, Emacs collapses them into a single wildcard. This is to prevent use of auto-scaled fonts. Fonts made by scaling larger fonts are not usable for editing, and scaling a smaller font is not useful because it is better to use the smaller font in its own size, which Emacs does. </p> <p>Thus if <var>fontpattern</var> is this, </p> <div class="example"> <pre class="example">-*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24
+</pre>
+</div> <p>the font specification for <acronym>ASCII</acronym> characters would be this: </p> <div class="example"> <pre class="example">-*-fixed-medium-r-normal-*-24-*-ISO8859-1
+</pre>
+</div> <p>and the font specification for Chinese GB2312 characters would be this: </p> <div class="example"> <pre class="example">-*-fixed-medium-r-normal-*-24-*-gb2312*-*
+</pre>
+</div> <p>You may not have any Chinese font matching the above font specification. Most X distributions include only Chinese fonts that have ‘<samp>song ti</samp>’ or ‘<samp>fangsong ti</samp>’ in the <var>family</var> field. In such a case, ‘<samp>Fontset-<var>n</var></samp>’ can be specified as below: </p> <div class="example"> <pre class="example">Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\
+ chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-*
+</pre>
+</div> <p>Then, the font specifications for all but Chinese GB2312 characters have ‘<samp>fixed</samp>’ in the <var>family</var> field, and the font specification for Chinese GB2312 characters has a wild card ‘<samp>*</samp>’ in the <var>family</var> field. </p> <dl> <dt id="set-fontset-font">Function: <strong>set-fontset-font</strong> <em>fontset characters font-spec &amp;optional frame add</em>
+</dt> <dd>
+<p>This function modifies the existing <var>fontset</var> to use the font specified by <var>font-spec</var> for displaying the specified <var>characters</var>. </p> <p>If <var>fontset</var> is <code>nil</code>, this function modifies the fontset of the selected frame or that of <var>frame</var> if <var>frame</var> is not <code>nil</code>. </p> <p>If <var>fontset</var> is <code>t</code>, this function modifies the default fontset, whose short name as a string is ‘<samp>fontset-default</samp>’. </p> <p>The <var>characters</var> argument can be a single character which should be displayed using <var>font-spec</var>. It can also be a cons cell <code>(<var>from</var> . <var>to</var>)</code>, where <var>from</var> and <var>to</var> are characters. In that case, use <var>font-spec</var> for all the characters in the range <var>from</var> and <var>to</var> (inclusive). </p> <p><var>characters</var> may be a charset symbol (see <a href="character-sets">Character Sets</a>). In that case, use <var>font-spec</var> for all the characters in the charset. </p> <p><var>characters</var> may be a script symbol (see <a href="character-properties">char-script-table</a>). In that case, use <var>font-spec</var> for all the characters belonging to the script. </p> <p><var>characters</var> may be <code>nil</code>, which means to use <var>font-spec</var> for any character in <var>fontset</var> for which no font-spec is specified. </p> <p><var>font-spec</var> may be a font-spec object created by the function <code>font-spec</code> (see <a href="low_002dlevel-font">Low-Level Font</a>). </p> <p><var>font-spec</var> may be a cons cell <code>(<var>family</var> . <var>registry</var>)</code>, where <var>family</var> is a family name of a font (possibly including a foundry name at the head), and <var>registry</var> is a registry name of a font (possibly including an encoding name at the tail). </p> <p><var>font-spec</var> may be a font name, a string. </p> <p><var>font-spec</var> may be <code>nil</code>, which explicitly specifies that there’s no font for the specified <var>characters</var>. This is useful, for example, to avoid expensive system-wide search for fonts for characters that have no glyphs, like those from the Unicode Private Use Area (PUA). </p> <p>The optional argument <var>add</var>, if non-<code>nil</code>, specifies how to add <var>font-spec</var> to the font specifications previously set for <var>characters</var>. If it is <code>prepend</code>, <var>font-spec</var> is prepended to the existing specs. If it is <code>append</code>, <var>font-spec</var> is appended. By default, <var>font-spec</var> overwrites the previously set font specs. </p> <p>For instance, this changes the default fontset to use a font whose family name is ‘<samp>Kochi Gothic</samp>’ for all characters belonging to the charset <code>japanese-jisx0208</code>: </p> <div class="example"> <pre class="example">(set-fontset-font t 'japanese-jisx0208
+ (font-spec :family "Kochi Gothic"))
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="char-displayable-p">Function: <strong>char-displayable-p</strong> <em>char</em>
+</dt> <dd>
+<p>This function returns non-<code>nil</code> if Emacs ought to be able to display <var>char</var>. Or more precisely, if the selected frame’s fontset has a font to display the character set that <var>char</var> belongs to. </p> <p>Fontsets can specify a font on a per-character basis; when the fontset does that, this function’s value may not be accurate. </p> <p>This function may return non-<code>nil</code> even when there is no font available, since it also checks whether the coding system for the text terminal can encode the character (see <a href="terminal-i_002fo-encoding">Terminal I/O Encoding</a>). </p>
+</dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Fontsets.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Fontsets.html</a>
+ </p>
+</div>