Font manager.
This object provides a hash of named font objects. Each named font object represents a single font name. Each font object has a slot for the available styles of that font name.
This service provides information about fonts.
See also the runtime LzFont object as
well as the <font> tag for importing fonts.
Example that displays information about a font:
<canvas debug="true" oninit="showArioso()" >
<debug height="300"/>
<font src="ariosor.ttf" name="arioso"/>
<method name="showArioso" >
var f = LzFontManager.getFont("arioso", "plain");
Debug.write("height: " + f.height);
Debug.write("style: " + f.style);
Debug.write("ascent: " + f.ascent);
Debug.write("descent: " + f.descent);
Debug.write("leading: " + f.leading);
for (var i = "A".charCodeAt(0) ; i < "z".charCodeAt(0); i++) {
Debug.write("Char " + String.fromCharCode(i) + ": " + f.advanceTable[i]);
}
</method>
</canvas>
Below is another example that displays some text and aligns visual elements based on the font:
<canvas height="1000" width="1600" >
<font name="vera" src="bitstream-vera-1.10/vera.ttf"/>
<font name="lztahoe8" src="lztahoe8.ttf"/>
<font name="timmons" src="timmonsr.ttf"/>
<font name="helmet" src="helmetr.ttf"/>
<simplelayout axis="y"/>
<class name="lines" width="${canvas.width}" >
<!-- LPS fontmetrics are for the default fontsize of 8 -->
<attribute name="defaultsize" value="8"/>
<!-- External leading is a constant in the LPS 2 pixels -->
<attribute name="leading" value="2"/>
<!-- LFC font metrics are for the default font size; must multiply by factor -->
<attribute name="factor" value="${this.tview.fontsize/defaultsize}"/>
<attribute name="lzfont" value="${this.tview.font}"/>
<!-- external leading -->
<view name="v1" bgcolor="red"
height="${classroot.leading/2}" width="${canvas.width}"/>
<!-- ascent -->
<view name="v2" bgcolor="green"
height="${classroot.lzfont.ascent*classroot.factor}" width="${canvas.width}"
y="${classroot.v1.height + classroot.v1.y}"/>
<!-- descent -->
<view name="v3" bgcolor="blue"
height="${classroot.lzfont.descent*classroot.factor}"
width="${canvas.width}"
y="${classroot.v2.height + classroot.v2.y}"/>
<!-- 1 pixel on bottom -->
<view name="v4" bgcolor="red"
height="${classroot.leading/2}" width="${canvas.width}"
y="${classroot.v3.height + classroot.v3.y}"/>
<!-- For now, we must create a text view to get font attributes -->
<text name="tview" multiline="true" width="${canvas.width}"
text="${this.fontname + ' abcdefghijklmnopqrstyuvwxyzAM'}"/>
</class>
<class name="tester" >
<view width="${canvas.width}" >
<simplelayout axis="y"/>
<lines/>
<lines/>
<lines/>
</view>
</class>
<tester font="helmet" fontsize="20"/>
<tester font="timmons" fontsize="56"/>
<tester font="lztahoe8" fontsize="56"/>
<tester font="vera" fontsize="56"/>
</canvas>
| getFont() | ||
| LzFontManager.getFont(fontname, style) | ||
|
Get the named LzFont of the given style. |
||
| Parameters | ||
| Name | Type | Desc |
| fontname | String | The name of the font. |
| style | String | The style of the font. One of "plain", "bold", "italic" or "bolditalic". If style is null, "plain" is assumed. |
| Returns | ||
| Type | Desc | |
| any | An LzFont object, or undefined if not found | |
|
|
||
Copyright © 2002-2007 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.