97 lines
12 KiB
HTML
97 lines
12 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Interface Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInterfaceKit_Overview.html" title="The Interface Kit" /><link rel="prev" href="BDragger_Overview.html" title="BDragger" /><link rel="next" href="BListItem_Overview.html" title="BListItem" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BDragger_Overview.html" title="BDragger"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BListItem_Overview.html" title="BListItem"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Interface Kit</div></div><div id="headerB">Prev: <a href="BDragger_Overview.html">BDragger</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BListItem_Overview.html">BListItem</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFont_Overview"></a>BFont</h2></div></div></div><a id="id548211" class="indexterm"></a><p>
|
||
A <a class="link" href="BFont.html" title="BFont"><code class="classname">BFont</code></a>
|
||
object records a set of font attributes, such as the font's
|
||
family, style, size, and so on. You can set most of these attributes to
|
||
modify the font and then use the object to set the font of a
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>. A
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>'s
|
||
font determines how the characters that it draws (with the
|
||
<a class="link" href="BView.html#BView_DrawString" title="DrawString()"><code class="methodname">DrawString()</code></a> and
|
||
<a class="link" href="BView.html#BView_DrawChar" title="DrawChar()"><code class="methodname">DrawChar()</code></a>
|
||
functions) will be rendered.
|
||
</p><p>
|
||
A <a class="link" href="BFont.html" title="BFont"><code class="classname">BFont</code></a>
|
||
object can perform calculations based on the metrics of the
|
||
particular font it represents. For example, it can tell you how much
|
||
screen real estate it needs to display a given line of text.
|
||
</p><p>
|
||
To find which fonts are currently installed on the system, call
|
||
<a class="link" href="TheInterfaceKit_Functions.html#get_font_family" title="get_font_family(), count_font_families(), get_font_style(), count_font_styles()"><code class="function">get_font_family()</code></a> and
|
||
<a class="link" href="TheInterfaceKit_Functions.html#get_font_style"><code class="function">get_font_style()</code></a>.
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id548304"></a>Using a BFont Object</h3></div></div></div><p>
|
||
A <a class="link" href="BFont.html" title="BFont"><code class="classname">BFont</code></a>
|
||
object by itself doesn't do anything. To be able to draw
|
||
characters in the font, the object must be passed to
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>'s
|
||
<a class="link" href="BView.html#BView_SetFont" title="SetFont(), GetFont()"><code class="methodname">SetFont()</code></a>
|
||
function (or
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>'s
|
||
<a class="link" href="BTextView.html#BTextView_SetFontAndColor" title="SetFontAndColor(), GetFontAndColor()"><code class="methodname">SetFontAndColor()</code></a>).
|
||
</p><p>
|
||
A <a class="link" href="BFont.html" title="BFont"><code class="classname">BFont</code></a>
|
||
object is always a full representation of a font; all attributes
|
||
are always set. However, you can choose which of these attributes will
|
||
modify a
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>'s
|
||
current font by passing a mask to
|
||
<a class="link" href="BView.html#BView_SetFont" title="SetFont(), GetFont()"><code class="methodname">SetFont()</code></a> (or
|
||
<a class="link" href="BTextView.html" title="BTextView"><code class="classname">BTextView</code></a>'s
|
||
<a class="link" href="BTextView.html#BTextView_SetFontAndColor" title="SetFontAndColor(), GetFontAndColor()"><code class="methodname">SetFontAndColor()</code></a>).
|
||
For example, this code sets only the font shear and
|
||
spacing:
|
||
</p><pre class="programlisting example cpp"><code class="classname">BFont</code> <code class="varname">font</code>;
|
||
<code class="varname">font</code>.<code class="methodname">SetShear</code>(60.0);
|
||
<code class="varname">font</code>.<code class="methodname">SetSpacing</code>(<code class="constant">B_CHAR_SPACING</code>);
|
||
<code class="varname">myView</code>-><code class="methodname">SetFont</code>(&<code class="varname">font</code>, <code class="constant">B_FONT_SHEAR</code> | <code class="constant">B_FONT_SPACING</code>);</pre><p>
|
||
Alternatively, the <code class="classname">BView</code>'s font could have been modified and reset as
|
||
follows:
|
||
</p><pre class="programlisting example cpp"><code class="classname">BFont</code> <code class="varname">font</code>;
|
||
<code class="varname">myView</code>-><code class="methodname">GetFont</code>(&<code class="varname">font</code>);
|
||
<code class="varname">font</code>.<code class="methodname">SetShear</code>(60.0);
|
||
<code class="varname">font</code>.<code class="methodname">SetSpacing</code>(<code class="constant">B_CHAR_SPACING</code>);
|
||
<code class="varname">myView</code>-><code class="methodname">SetFont</code>(&<code class="varname">font</code>);</pre><p>
|
||
Notice that we had to explicitly reset the view's font (through
|
||
<a class="link" href="BView.html#BView_SetFont" title="SetFont(), GetFont()"><code class="methodname">SetFont()</code></a>)
|
||
after changing the font's attributes.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id548523"></a>System Fonts</h3></div></div></div><p>
|
||
The Interface Kit constructs three
|
||
<a class="link" href="BFont.html" title="BFont"><code class="classname">BFont</code></a> objects (plain, bold, and
|
||
fixed)for each application when the application starts up. The values of
|
||
these fonts are set by the user through the FontPanel preferences
|
||
application. You can get to these objects through global pointers :
|
||
</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term">const <span class="type">BFont*</span> <code class="varname">be_plain_font</code></span></p></td><td><p>
|
||
The font that's used to display most gadgets in the user interface,
|
||
such as check box labels and menu items. All
|
||
<a class="link" href="BControl.html" title="BControl"><code class="classname">BControl</code></a>
|
||
objects use this font.
|
||
</p></td></tr><tr><td><p><span class="term">const <span class="type">BFont*</span> <code class="varname">be_bold_font</code></span></p></td><td><p>
|
||
The font that's used to display window titles and
|
||
<a class="link" href="BBox.html" title="BBox"><code class="classname">BBox</code></a> labels.
|
||
</p></td></tr><tr><td><p><span class="term">const <span class="type">BFont*</span> <code class="varname">be_fixed_font</code></span></p></td><td><p>
|
||
The font that's used to display fixed-width characters.
|
||
</p></td></tr></tbody></table><p>
|
||
The global fonts are const objects that can't be modified by your
|
||
application, and aren't updated by the system, even if the user changes
|
||
their definitions while your app is running. The new values take effect
|
||
the next time your application is launched.
|
||
</p><p>
|
||
To use a system font in a view, simply call
|
||
<a class="link" href="BView.html#BView_SetFont" title="SetFont(), GetFont()"><code class="methodname">SetFont()</code></a>:
|
||
</p><pre class="programlisting example cpp"><code class="varname">myView</code>-><code class="methodname">SetFont</code>(<code class="varname">be_bold_font</code>);</pre><p>
|
||
If you want to modify some attributes of a system font, you have to make
|
||
a copy of it first (and modify the copy):
|
||
</p><pre class="programlisting example cpp"><code class="classname">BFont</code> <code class="varname">font</code>(<code class="varname">be_bold_font</code>);
|
||
<code class="varname">font</code>.<code class="methodname">SetSize</code>(13.0);
|
||
<code class="varname">myView</code>-><code class="methodname">SetFont</code>(&<code class="varname">font</code>);</pre><p>
|
||
Applications should respect the user's choices and base all font choices
|
||
on these three system fonts, rather than hard-code font names into the
|
||
application. You should not try to predict the fonts that will be
|
||
installed on the user's machine.
|
||
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BDragger_Overview.html">BDragger</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BListItem_Overview.html">BListItem</a> </div><div id="footerB"><div id="footerBL"><a href="BDragger_Overview.html" title="BDragger"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BListItem_Overview.html" title="BListItem"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|