<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xcrefsetman'>
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XCreFSet.man,v 1.3 2003/04/28 22:17:54 herrb Exp $ -->

<!-- .na -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<refmeta>
<refentrytitle>XCreateFontSet</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XCreateFontSet</refname>
<refname>XFreeFontSet</refname>
<refpurpose>create and free an international text drawing font set</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>XFontSet XCreateFontSet&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, char
*<emphasis remap='I'>base_font_name_list</emphasis>&hairsp;, char ***<emphasis remap='I'>missing_charset_list_return</emphasis>&hairsp;, int
*<emphasis remap='I'>missing_charset_count_return</emphasis>&hairsp;, char **<emphasis remap='I'>def_string_return</emphasis>&hairsp;);</para>

<para>void XFreeFontSet&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, XFontSet <emphasis remap='I'>font_set</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>display</emphasis></term>
  <listitem>
<para>Specifies the connection to the X server.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>base_font_name_list</emphasis></term>
  <listitem>
<para>Specifies the base font names.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>def_string_return</emphasis></term>
  <listitem>
<para>Returns the string drawn for missing charsets.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>font_set</emphasis></term>
  <listitem>
<para>Specifies the font set.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>missing_charset_count_return</emphasis></term>
  <listitem>
<para>Returns the number of missing charsets.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>missing_charset_list_return</emphasis></term>
  <listitem>
<para>Returns the missing charsets.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>The 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
function creates a font set for the specified display.
The font set is bound to the current locale when 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
is called.
The font set may be used in subsequent calls to obtain font
and character information and to image text in the locale of the font set.</para>

<para>The base_font_name_list argument is a list of base font names
that Xlib uses to load the fonts needed for the locale.
The base font names are a comma-separated list.
The string is null-terminated
and is assumed to be in the Host Portable Character Encoding; 
otherwise, the result is implementation-dependent.
White space immediately on either side of a separating comma is ignored.</para>

<para>Use of XLFD font names permits Xlib to obtain the fonts needed for a
variety of locales from a single locale-independent base font name.
The single base font name should name a family of fonts whose members
are encoded in the various charsets needed by the locales of interest.</para>

<para>An XLFD base font name can explicitly name a charset needed for the locale.
This allows the user to specify an exact font for use with a charset required
by a locale, fully controlling the font selection.</para>

<para>If a base font name is not an XLFD name,
Xlib will attempt to obtain an XLFD name from the font properties
for the font.
If this action is successful in obtaining an XLFD name, the
<emphasis remap='I'>&hairsp;XBaseFontNameListOfFontSet&hairsp;</emphasis>
function will return this XLFD name instead of the client-supplied name.</para>

<para>Xlib uses the following algorithm to select the fonts
that will be used to display text with the 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>.</para>

<para>For each font charset required by the locale,
the base font name list is searched for the first appearance of one 
of the following cases that names a set of fonts that exist at the server:</para>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>The first XLFD-conforming base font name that specifies the required
charset or a superset of the required charset in its 
<emphasis remap='I'>&hairsp;CharSetRegistry&hairsp;</emphasis>
and 
<emphasis remap='I'>&hairsp;CharSetEncoding&hairsp;</emphasis>
fields.
The implementation may use a base font name whose specified charset
is a superset of the required charset, for example,
an ISO8859-1 font for an ASCII charset.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>The first set of one or more XLFD-conforming base font names
that specify one or more charsets that can be remapped to support the
required charset.
The Xlib implementation may recognize various mappings 
from a required charset to one or more other charsets
and use the fonts for those charsets.
For example, JIS Roman is ASCII with tilde and backslash replaced 
by yen and overbar;
Xlib may load an ISO8859-1 font to support this character set
if a JIS Roman font is not available.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>The first XLFD-conforming font name or the first non-XLFD font name
for which an XLFD font name can be obtained, combined with the
required charset (replacing the 
<emphasis remap='I'>&hairsp;CharSetRegistry&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;CharSetEncoding&hairsp;</emphasis>
fields in the XLFD font name).
As in case 1,
the implementation may use a charset that is a superset
of the required charset.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>The first font name that can be mapped in some implementation-dependent
manner to one or more fonts that support imaging text in the charset.</para>
  </listitem>
</itemizedlist>

<para>For example, assume that a locale required the charsets:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
ISO8859-1
JISX0208.1983
JISX0201.1976
GB2312-1980.0
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>The user could supply a base_font_name_list that explicitly specifies the
charsets, ensuring that specific fonts are used if they exist.
For example:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
"-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240-JISX0208.1983-0,\
-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120-JISX0201.1976-0,\
-GB-Fixed-Medium-R-Normal--26-180-100-100-C-240-GB2312-1980.0,\
-Adobe-Courier-Bold-R-Normal--25-180-75-75-M-150-ISO8859-1"
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>Alternatively, the user could supply a base_font_name_list
that omits the charsets,
letting Xlib select font charsets required for the locale.
For example:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
"-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240,\
-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120,\
-GB-Fixed-Medium-R-Normal--26-180-100-100-C-240,\
-Adobe-Courier-Bold-R-Normal--25-180-100-100-M-150"
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>Alternatively, the user could simply supply a single base font name
that allows Xlib to select from all available fonts
that meet certain minimum XLFD property requirements.
For example:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
"-*-*-*-R-Normal--*-180-100-100-*-*"
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>If 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
is unable to create the font set, 
either because there is insufficient memory or because the current locale
is not supported,
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
returns NULL, missing_charset_list_return is set to NULL,
and missing_charset_count_return
is set to zero.
If fonts exist for all of the charsets required by the current locale,
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
returns a valid
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>,
missing_charset_list_return is set to NULL,
and missing_charset_count_return is set to zero.</para>

<para>If no font exists for one or more of the required charsets,
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
sets missing_charset_list_return to a
list of one or more null-terminated charset names for which no font exists
and sets missing_charset_count_return to the number of missing fonts.
The charsets are from the list of the required charsets for
the encoding of the locale and do not include any charsets to which Xlib
may be able to remap a required charset.</para>

<para>If no font exists for any of the required charsets
or if the locale definition in Xlib requires that a font exist
for a particular charset and a font is not found for that charset, 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
returns NULL.
Otherwise, 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
returns a valid 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>
to font_set.</para>

<para>When an Xmb/wc drawing or measuring function is called with an
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>
that has missing charsets, some characters in the locale will not be
drawable.
If def_string_return is non-NULL,
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>
returns a pointer to a string that represents the glyphs
that are drawn with this 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>
when the charsets of the available fonts do not include all font glyphs
required to draw a codepoint.
The string does not necessarily consist of valid characters 
in the current locale and is not necessarily drawn with
the fonts loaded for the font set,
but the client can draw and measure the default glyphs
by including this string in a string being drawn or measured with the 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>.</para>

<para>If the string returned to def_string_return is the empty string ("&hairsp;"),
no glyphs are drawn, and the escapement is zero.
The returned string is null-terminated.
It is owned by Xlib and should not be modified or freed by the client.
It will be freed by a call to 
<emphasis remap='I'>&hairsp;XFreeFontSet&hairsp;</emphasis>
with the associated 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>.
Until freed, its contents will not be modified by Xlib.</para>

<para>The client is responsible for constructing an error message from the
missing charset and default string information and may choose to continue
operation in the case that some fonts did not exist.</para>

<para>The returned 
<emphasis remap='I'>&hairsp;XFontSet&hairsp;</emphasis>
and missing charset list should be freed with 
<emphasis remap='I'>&hairsp;XFreeFontSet&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;XFreeStringList&hairsp;</emphasis>,
respectively.
The client-supplied base_font_name_list may be freed 
by the client after calling 
<emphasis remap='I'>&hairsp;XCreateFontSet&hairsp;</emphasis>.</para>

<para>The
<emphasis remap='I'>&hairsp;XFreeFontSet&hairsp;</emphasis>
function frees the specified font set.
The associated base font name list, font name list, 
<emphasis remap='I'>&hairsp;XFontStruct&hairsp;</emphasis>
list, and 
<emphasis remap='I'>&hairsp;XFontSetExtents&hairsp;</emphasis>,
if any, are freed.</para>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XExtentsofFontSet(3X11),
XFontsOfFontSet(3X11),
XFontSetExtents(3X11)
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

