Font Control in 4GL Widgets¶
The features were implemented in #3876 which was committed to trunk as revision 11315. The first public release is FWD v4.0.
OpenEdge provides very weak support for fonts. One must define a set of fonts for your environment and at runtime assign fonts from this predefined set.
To configure the
- Define a set of static fonts in your environment (e.g. an
.inifile) and load them into the
FONT-TABLEat session startup; OR
- Force the user to interactively pick a font using
SYSTEM-DIALOG GET-FONTwhich edits the
One cannot programmatically modify the
FONT-TABLE or the attributes of any given entry in the
FONT-TABLE. One can only use the
FONT-TABLE as defined, referencing a specific font in a widget by one of the valid numeric indexes from the
FONT-TABLE. You can switch environments at runtime from a set of predefined configuratons, but you cannot dynamically control/edit the
FONT-TABLE entries using 4GL code (e.g. methods/attributes).
FWD introduces new font-related attributes. The attributes can be used on all widgets that render text. This provides full dynamic/runtime control from 4GL code over the following:
- font name
- font size
- font styles (bold, italics, underline)
One just directly sets the font attributes into the widget.
|Attribute Name||Type||Read Only||Default||Description|
|FONT-NAME||CHARACTER||FALSE||?|| Font name as defined in the server directory (
Please note that bitmap fonts are not supported in FWD. Bitmap (a.k.a. raster) fonts are not natively supported in Java or in web browsers. They are a very old font technology which is device dependent. This means it is fixed size and does not scale well. In a world of many devices with different resolutions, bitmap fonts are a poor fit. For this reason, FWD has not implemented a 3rd party rendering engine for these fonts. Unfortunately, the 4GL on Windows often uses bitmap fonts (examples are
Example set of valid values for Swing GUI client: Serif, SansSerif, Monospaced.
Example set of valid values for Web GUI client: Arial, Times New Roman, Courier.
|FONT-SIZE||INTEGER||FALSE||?|| Font point size. This point size defines a measurement between the baseline of one line to the baseline of the following line in a single spaced text document. The point size is based on typographic points, approximately 1/72 of an inch. When the font size doesn't yield a valid font the widget will be drawn using the font set in the
|FONT-BOLD||LOGICAL||FALSE||FALSE|| A flag that controls text rendering. When
|FONT-ITALIC||LOGICAL||FALSE||FALSE|| A flag that controls text rendering. When
|FONT-UNDERLINE||LOGICAL||FALSE||FALSE|| A flag that controls text rendering. When
DEF VAR edit AS CHAR VIEW-AS FILL-IN SIZE 50 BY 2 LABEL "Sample text" FORMAT "x(50)". DEFINE VARIABLE fonts AS CHARACTER NO-UNDO VIEW-AS SELECTION-LIST INNER-CHARS 15 INNER-LINES 10 SORT LABEL "Select font" . DEF VAR fsize AS INT INITIAL 12 VIEW-AS FILL-IN FORMAT 99 LABEL "Size". DEF VAR bold AS LOGICAL VIEW-AS TOGGLE-BOX LABEL "Bold". DEF VAR italic AS LOGICAL VIEW-AS TOGGLE-BOX LABEL "Italic". DEF VAR lunderline AS LOGICAL VIEW-AS TOGGLE-BOX LABEL "Underline". DEF BUTTON bapply label "Apply". DEF FRAME f edit SKIP(2) fonts fsize bold italic lunderline SKIP bapply WITH SIDE-LABELS. edit:SCREEN-VALUE = "Sample text". fsize:SCREEN-VALUE = "12". fonts:ADD-LAST("<none>"). /* these font names should work in Swing GUI client */ fonts:ADD-LAST("Serif"). fonts:ADD-LAST("SansSerif"). fonts:ADD-LAST("Monospaced"). fonts:ADD-LAST("Dialog"). fonts:ADD-LAST("DialogInput"). /* these font names should work in Web GUI client */ fonts:ADD-LAST("Arial"). fonts:ADD-LAST("Times New Roman"). fonts:ADD-LAST("Courier New"). fonts:ADD-LAST("Courier"). ENABLE ALL WITH FRAME f. ON 'choose':U OF bapply DO: edit:font-name = fonts:screen-value. edit:font-size = integer(fsize:screen-value). edit:font-bold = bold:checked. edit:font-italic = italic:checked. edit:font-underline = lunderline:checked. END. WAIT-FOR CLOSE OF THIS-PROCEDURE.
The following improvement is planned:
- #4611 create Java API for font enumeration (this will be callable from 4GL code using direct Java access AND it will support both the Swing and Web clients)
© 2019-2020 Golden Code Development Corporation. ALL RIGHTS RESERVED.