This component is deprecated.
Developers should use roFont methods (GetOneLineHeight and GetOneLineWidth).
The roFontMetrics object allows you to get display size information for a specific font returned by the roFontRegistry.Get() method.
Supported Interfaces
Description
In order to use this object, you must first initialize the roFontMetrics object with a font name that had been previously registered with the roFontRegistry, then the total rendered size of strings in that font can be returned by roFontMetrics.Size().
This object is created with a string that represents the font to use in its size calculations:
- CreateObject("roFontMetrics", String font)
Example: simple use of roFontRegistry and roFontMetrics to render a string on the roImageCanvas
helloString = "Hello ImageCanvas"
fontReg = CreateObject("roFontRegistry")
fontReg.Register("pkg:/fonts/LCDMono.ttf")
font = fontReg.Get("LCDMono",36,50,false) ' 36pt, 50 is normal
' weight, no italics
fontMetrics = CreateObject("roFontMetrics", font)
stringSize = fontMetrics.size(helloString)
canvasItem = {
Text:helloString
TextAttrs:{Color:"#FFCCCCCC", Font:font,
HAlign:"HCenter",
VAlign:"VCenter", Direction:"LeftToRight"}
TargetRect:{x:390,y:357, w:stringSize.w,h:stringSize.h}
}
canvas = CreateObject("roImageCanvas")
port = CreateObject("roMessagePort")
canvas.SetMessagePort(m.port)
'Set opaque background
canvas.SetLayer(0, {Color:"#FF000000", CompositionMode:"Source"})
canvas.SetRequireAllImagesToDraw(true)
canvas.SetLayer(1, canvasItem)
canvas.Show()