FONT-TABLE handle
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The NUM–ENTRIES attribute sets and returns
the number of fonts available in the font table. The FONT–TABLE methods
return information about font sizes. Each method takes an optional
font number as an argument:
-
GET–TEXT–HEIGHT–CHARS( )andGET–TEXT–HEIGHT–PIXELS( )return the height of the default font in either character units or pixels. You can pass a font number to these methods to get the height of a specific font. This example looks for the first font from the start of the font table with a height of at least two character units:DEFINE VARIABLE font-number AS INTEGER NO-UNDO. DEFINE VARIABLE max-count AS INTEGER NO-UNDO. max-count = FONT-TABLE:NUM-ENTRIES + 1. REPEAT font-number = 1 to max-count: IF font-number = max-count THEN LEAVE. IF FONT-TABLE:GET-TEXT-HEIGHT-CHARS(font-number) >= 2 THEN LEAVE. END. -
GET–TEXT–WIDTH–CHARS(string)andGET–TEXT–WIDTH–PIXELS(string)return the width of the passed string expression in the default font in either character units or pixels. You can optionally pass a font number to these methods to get the width of the string in a specific font. This example tests whether a title for a new window will fit based on the font of the current window:DEFINE VARIABLE font-number AS INTEGER NO-UNDO. DEFINE VARIABLE in-title AS CHARACTER NO-UNDO. font-number = CURRENT-WINDOW:FONT. SET in-title. IF FONT-TABLE:GET-TEXT-WIDTH-CHARS(font-number, in-title) > 80 THEN MESSAGE "Title" in-title "cannot fit in new window.".