Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > 2fcb262fce8df923d1c90b2e80f20b02 > files > 1403

pl-5.7.11-5.fc12.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<HTML>
<HEAD>
<TITLE>Programming in XPCE/Prolog: Section 10.9</TITLE><LINK REL=home HREF="index.html">
<LINK REL=contents HREF="Contents.html">
<LINK REL=index HREF="DocIndex.html">
<LINK REL=summary HREF="summary.html">
<LINK REL=previous HREF="errors.html">
<LINK REL=next HREF="images.html">
<STYLE type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/

dd.defbody
{ margin-bottom: 1em;
}

dt.pubdef
{ background-color: #c5e1ff;
}

pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}

div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}

div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}

div.author
{ text-align: center;
font-style: italic;
}

div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}

div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}

div.toc-h1
{ font-size: 200%;
font-weight: bold;
}

div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}

div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}

div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}

span.sec-nr
{ 
}

span.sec-title
{ 
}

span.pred-ext
{ font-weight: bold;
}

/* Footnotes */

sup.fn { color: blue; text-decoration: underline; }
span.fn-text: { display: none; }
sup.fn span {display: none;}
sup:hover span 
{ display: block !important;
position: absolute; top: auto; left: auto; width: 80%;
color: #000; background: white;
border: 2px solid;
padding: 5px; margin: 10px; z-index: 100;
font-size: smaller;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="white">
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
<A class="nav" href="summary.html"><IMG SRC="info.gif" BORDER=0 ALT="Summary"></A>
<A class="nav" href="errors.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
<A class="nav" href="images.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
</DIV>

<H2><A NAME="sec:10.9"><SPAN class="sec-nr">10.9</SPAN> <SPAN class="sec-title">Specifying 
fonts</SPAN></A></H2>

<A NAME="sec:font"></A>

<P><font size=-1>XPCE</font>'s font specification is a two-stage 
process. In the first stage,
<font size=-1>XPCE</font> physical fonts are mapped to fonts of the 
underlying windowing system. In this stage, fonts are identified by 
their <EM>family</EM>,
<EM>style</EM> and <EM>size</EM>. For example

<PRE class="code">
font(screen, roman, 13)
</PRE>

<P>Refers to a fixed-width font designed for use on the screen that has 
normal weight, not slanted and 13-pixels high characters.

<P>In the second stage, logical font-names are mapped to their physical 
implementation. At this level, fonts are identified by a single name 
from an extensible, but preferably small set.

<P>See <A class="sec" href="winfont.html">section B.5</A> for a 
description of Windows specific font issues.

<H3><A NAME="sec:10.9.1"><SPAN class="sec-nr">10.9.1</SPAN> <SPAN class="sec-title">Physical 
fonts</SPAN></A></H3>

<P>The default physical font set is built when the first font object is 
opened (i.e. its window counterpart is located and made available to the 
text-drawing functions). This set is created from class-variables on the 
display object. The first class-variable is display.font_families, which 
defines a chain with names of the font-families. The default value is:<SUP class="fn">11<SPAN class="fn-text">See <A class="sec" href="classvar.html">section 
8</A> for the default syntax.</SPAN></SUP>

<PRE class="code">
display.font_families: \
        [ screen_fonts, \
          courier_fonts, \
          helvetica_fonts, \
          times_fonts, \
          symbol_fonts
        ]
</PRE>

<P>Each of these names refers to the name of another resource of class
<A class="" href="summary.html#class:display">display</A>, enumerating 
the members of this font family. The default value can be examined using 
the online manual. Below is the default value for the <CODE>screen_fonts</CODE> 
font-set for X11:

<PRE class="code">
display.screen_fonts: \
        [ font(screen, roman, 10, "6x10"), \
          font(screen, roman, 12, "6x12"), \
          font(screen, roman, 13, "8x13"), \
          font(screen, roman, 14, "7x14"), \
          font(screen, roman, 15, "9x15"), \
          font(screen, bold, 13, "8x13bold"), \
          font(screen, bold, 14, "7x14bold"), \
          font(screen, bold, 15, "9x15bold") \
        ]
</PRE>

<P>The set of predefined physical fonts can be examined using the 
FontViewer demo application accessible through the online manual tools.

<H4><A NAME="sec:10.9.1.1"><SPAN class="sec-nr">10.9.1.1</SPAN> <SPAN class="sec-title">Defining 
additional fonts</SPAN></A></H4>

<P>If an application needs additional fonts, such fonts can be declared 
using directives. The fourth initialisation argument of class
<A class="" href="summary.html#class:font">font</A> determines the 
window-system font that will be mapped. The syntax for this argument 
depends on the window-system used. For this Unix/X11 version it is a 
string consisting of 15 `-' separated fields. A font can be searched 
using <STRONG>xfontsel</STRONG>(1) or the much better GNOME-project <STRONG>gfontsel</STRONG>(1).

<P>For example, the 14-points `courier new' TrueType font can be 
registered using:

<PRE class="code">
:- initialization
   new(_, font(courier, roman, 14,
               '-winfonts-courier new-medium-r-normal-*-*-140-*-*-m-*-iso8859-1')).
</PRE>

<P>This specification has various drawbacks. For example, another 
library or application loaded on top of the same <font size=-1>XPCE</font> 
process may be using the symbol,roman,14 specification, but bound to 
another window-system font. A user may try to run your application on an 
environment that does not have this font. Part of these problems can be 
eliminated by binding the font to a logical font name. See also <A class="sec" href="font.html">section 
10.9.2</A>.

<PRE class="code">
:- initialization
   send(@display, font_alias,
        adobesymbol,
        font(symbol, roman, 14,
             '-*-symbol-*-*-*-*-14-*-*-*-*-*-adobe-*')).
</PRE>

<P>The application will refer to this font using the font-alias. user 
has other preferences or the font is not available, the user may specify 
the font using the display.user_fonts class-variable described in <A class="sec" href="font.html">section 
10.9.2</A>.

<H3><A NAME="sec:10.9.2"><SPAN class="sec-nr">10.9.2</SPAN> <SPAN class="sec-title">Logical 
fonts</SPAN></A></H3>

<A NAME="sec:fontalias"></A>.

<P>It is not wise let your application code speak about physical fonts 
as the user or interface guidelines may prefer using a different 
font-palette. For this reason the display defines a mapping between 
logical font names and physical fonts. Applications are encouraged to 
use logical font names as much as possible and leave the assignment to 
physical fonts to the users preferences. <font size=-1>XPCE</font> 
predefines the following logical font-names. The value gives the default 
assignment for these fonts.

<P>
<UL>
<DT><CODE>normal</CODE><I>font(helvetica, roman, 12)</I></DT>
<DD class="defbody">
The default font. Normally a proportional roman font. Should be easy to 
read.
</DD>
<DT><CODE>bold</CODE><I>font(helvetica, bold, 12)</I></DT>
<DD class="defbody">
Bold version of the normal font.
</DD>
<DT><CODE>italic</CODE><I>font(helvetica, oblique, 12)</I></DT>
<DD class="defbody">
Slanted version of the normal font. Note that italic fonts should not be 
used for long text as italics is generally not easy to read on most 
displays.
</DD>
<DT><CODE>small</CODE><I>font(helvetica, roman, 10)</I></DT>
<DD class="defbody">
Small version of the normal font. To be used in notes, subscripts, etc. 
May not be so easy to read, so avoid using it for long texts.
</DD>
<DT><CODE>large</CODE><I>font(helvetica, roman, 14)</I></DT>
<DD class="defbody">
Slightly larger version of the normal font.
</DD>
<DT><CODE>boldlarge</CODE><I>font(helvetica, bold, 14)</I></DT>
<DD class="defbody">
Bold version of large.
</DD>
<DT><CODE>huge</CODE><I>font(helvetica, roman, 18)</I></DT>
<DD class="defbody">
Even larger font. To be used for titles, etc.
</DD>
<DT><CODE>boldhuge</CODE><I>font(helvetica, bold, 18)</I></DT>
<DD class="defbody">
Bold version of huge.
</DD>
<DT><CODE>fixed</CODE><I>font(screen, roman, 13)</I></DT>
<DD class="defbody">
Terminal font. To be used for code fragments, code editors, etc. Should 
be easy to read.
</DD>
<DT><CODE>tt</CODE><I>font(screen, roman, 13)</I></DT>
<DD class="defbody">
Same as <CODE>fixed</CODE>.
</DD>
<DT><CODE>boldtt</CODE><I>font(screen, bold, 13)</I></DT>
<DD class="defbody">
Bold terminal font.
</DD>
<DT><CODE>symbol</CODE><I>font(symbol, roman, 12)</I></DT>
<DD class="defbody">
Symbol font using the adobe symbol-font encoding. This font provides 
many <A NAME="idx:mathematicalsymbols:431">mathematical symbols</A>.
</UL>

<P>The end-user of an <font size=-1>XPCE</font> application can define 
the class-variable display.user_fonts to overrule fonts. The example 
below re-binds the most commonly used fonts to be slightly larger and 
choose from the Times font family rather than the Helvetica fonts.

<PRE class="code">
display.user_fonts: \
        [ normal := font(times, roman, 14), \
          bold   := font(times, bold, 14), \
          italic := font(times, italic, 14) \
        ]
</PRE>

<P>The mapping between logical font names and physical fonts is realised 
by the methods <A NAME="idx:displaybothfontalias:432"></A>`<B>display<CODE>&lt;-&gt;</CODE>font_alias</B>' 
additional font aliases may be loaded using <A NAME="idx:displaysendloadfontaliases:433"></A>`<B>display<CODE>-&gt;</CODE>load_font_aliases</B>'.

<P>Class <A class="" href="summary.html#class:font">font</A>'s 
predefined conversion will translate names to font objects. This implies 
that for any method expecting a font object the programmer can specify 
the font-name instead. In those (rare) cases where a font needs to be 
passed, but the type-specification does not require this, the conversion 
must be done explicitly. The preferred way to make the conversion is 
using the font type object:

<PRE class="code">
        ...,
        get(type(font), check, bold, BoldFont),
        ...,
</PRE>

<P></BODY></HTML>