Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Colors and Fonts : Accessing the current color and font tables : FONT-TABLE handle
 
FONT-TABLE handle
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( ) and GET–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 ) and GET–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.".