Tips   >   Functions   >   FontOps

FontOps

The FontOps function let you calculate the size in pixels of text displayed in windows and size in inches or cms of text displayed in reports.

To view all of the FontOps functions:

  1. Press F9 to open the Catalog.
  2. Click the Functions tab.
  3. Click FontOps in column one. All of the FontOps functions are displayed in column two.

    If you hover or one of the functions a tooltip tip appears providing you with the syntax and a short description of the function.
Tip

You can drag and drop any of the functions into your code. Omnis Studio conveniently copies the function and parameter names into your code.

$replistfonts

Do FontOps.$replistfonts(List) Returns ErrorCode

Populates the specified list with the report fonts installed on your system, and indicates whether or not they are truetype. The list must contain two columns, the first character type, the second boolean. The function returns zero for success, less than zero for failure. Having built the list you can search and manipulate the list using the standard list functions and methods.

; Define the fonts list.
Do FontsList.$cols.$add('font',kCharacter,kSimplechar,100)
Do FontsList.$cols.$add('istruetype',kBoolean)

; Populate the fonts list with the fonts listed in the system class #WIWFONTS
Do FontOps.$replistfonts(FontsList) Returns ErrorCode
If ErrorCode
   OK message (Icon) {Error code: [ErrorCode]}
Else
   OK message (Icon) {There are [FontsList.$linecount] report fonts listed in your system.////The first font in the list is '[FontsList.1.font]'.////The last font in the list is '[FontsList.[FontsList.$linecount].font]'.}
End If

$reptextheight

Do FontOps.$reptextheight(font-name|font-table-index,point-size[,font-style,extra-points]) Returns Height

Returns the height in report units of the specified report font. You specify the font using either the font-name or font-table-index. When called with a font table index. $reptextheight() uses the window font system table of the current library which can be of the font. You can include a font-style constant and a number of extra-points.

; FontOps.$reptextheight(font-name|font-table-index,point-size[,font-style,extra-points])
Calculate FontName as 'Arial'
Do FontOps.$reptextheight(FontName,8) Returns Height
Do FontOps.$reptextheight(FontName,12,kItalic,2) Returns Height
Do FontOps.$reptextheight(FontName,72,kBold+kUnderline) Returns Height

$reptextwidth

Do FontOps.$reptextwidth(string, font-name|font-table-index,point-size[,font-style]) Returns Width

Returns the width in report units required to display the string using the specified report font. You specify the font using either the font-name or font-table-index. When called with a font table index, $reptextwidth() uses the report font system table of the current library which can contain up to 15 fonts numbered 1 to 15. You can include a font-style constant, or a combination of styles.

Calculate String as "Hello World!"
Calculate FontName as 'Arial'
; FontOps.$reptextwidth(string, font-name|font-table-index,point-size[,font-style])
Do FontOps.$reptextwidth(String,FontName,8) Returns Width
Do FontOps.$reptextwidth(String,FontName,12,kItalic) Returns Width
Do FontOps.$reptextwidth(String,FontName,72,kBold+kUnderline) Returns Width

$winlistfonts

Do FontOps.$winlistfonts(List) Returns ErrorCode

Populates the list with the window fonts installed on your system, and indicates whether or not they are truetype. The list must contain two columns, the first character type, the second boolean.

The function returns zero for success, less than zero for failure. Having built the list you can search and manipulate the list using the standard list functions and methods.

; Define the fonts list.
Do FontsList.$cols.$add('font',kCharacter,kSimplechar,100)
Do FontsList.$cols.$add('istruetype',kBoolean)

; Populate the fonts list with the fonts listed in the system class #WIWFONTS
Do FontOps.$winlistfonts(FontsList) Returns ErrorCode
If ErrorCode
   OK message (Icon) {Error code: [ErrorCode]}
Else
   OK message (Icon) {There are [FontsList.$linecount] window fonts listed in your system.////The first font in the list is '[FontsList.1.font]'.////The last font in the list is '[FontsList.[FontsList.$linecount].font]'.}
End If

$wintextheight

Do FontOps.$wintextheight(font-name|font-table-index,point-size[,font-style,extra-points]) Returns Height

Returns the height in screen units of the specified window font. You specify the font using either the font-name or font-table-index. When called with a font table index, $wintextheight() uses the window font system table of the current library. You can include font-style constants and a number of extra-points.

; FontOps.$wintextheight(font-name|font-table-index,point-size[,font-style,extra-points])
Calculate FontName as 'Arial'
Do FontOps.$wintextheight(FontName,8) Returns Height
Do FontOps.$wintextheight(FontName,12,kItalic,2) Returns Height
Do FontOps.$wintextheight(FontName,72,kBold+kUnderline) Returns Height

$wintextwidth

Do FontOps.$wintextwidth(string, font-name|font-table-index,point-size[,font-style]) Returns Width

Returns the width in screen units required to display the string using the specified window font. You specify the font using either the font-name or font-table-index. When called with a font table index, $wintextwidth() uses the window font system table of the current library. You can include font-style constants.

Calculate String as "Hello World!"
Calculate FontName as 'Arial'
; FontOps.$wintextwidth(string, font-name|font-table-index,point-size[,font-style])
Do FontOps.$wintextwidth(String,FontName,8) Returns Width
Do FontOps.$wintextwidth(String,FontName,12,kItalic) Returns Width
Do FontOps.$wintextwidth(String,FontName,72,kBold+kUnderline) Returns Width