Topic: APLX Help : System Classes : List of Classes : ChooseFont
[ Previous | Next | Contents | Index | APL Home ]


Not implemented under MacOS


The ChooseFont class implements the pre-defined font-selection dialog. This is a top-level object (i.e. it should not be opened as the child of a window).

To use the dialog, you must first create it using ⎕NEW. (Alternatively, you can create it as a top-level object using the New or Create method of ⎕WI). It will remain hidden at this stage. You can set the initially-selected font by setting the font property.

The style property is impelemted under Windows only (it is ignored under Linux). It defines the fonts which can be selected:

  0 = Screen fonts only
  1 = Printer fonts
  2 = Both

You can also add the following to style:

  4 = Include strikeout/underline/color effects
  8 = Exclude OEM fonts
  16 = ANSI character set fonts only (no Symbol)
  32 = Fixed Pitch only
  64 = Scalable only
  128 = TrueType only

If you have included 4 in the style property, you can also optionally set the initial color selection as the first element of the color property (foreground color only).

Under Windows, if you want to restrict the range of valid font sizes, set the range property to be a two-element vector of the minimum and maximum size, in the current scale of the object. (Remember that the scale defaults to 1, 'character' units.) Setting range to be an empty vector means there is no restriction. (This property is not available under Linux.)

When you are ready to show the dialog, call the Show method. This displays the modal dialog. The user can then select a font; if the Cancel button is pressed, the Show method returns 0. If the OK button is pressed, the Show method returns 1. The font property will contain the selected font as a 4-element nested vector of (Font Face) (Size) (Style) (Character set). You can also read the color property to retrieve the color (if any) selected by the user (only the first element is used).


[1]   ⍝ Sample function demonstrating use of the ChooseFont object
[2]   ⍝
[3]   ⍝ Can't run this on a Mac, because it doesn't support the
[4]   ⍝ ChooseFont object
[5]   ⎕IO←1
[6]   VERSION←'⎕' ⎕WI 'version'
[7]   →(VERSION[2]=0)/MAC
[8]   DLG←'⎕' ⎕NEW 'ChooseFont' ⋄ DLG.scale←3
[9]   ⍝
[10]  ⍝ Say we want to offer 'effects' (color and strikeout etc)
[12]  ⍝
[13]  ⍝ Set initial values, Arial 12-point bold, red
[14]  DLG.font←('Arial' 12 1)
[15]  DLG.color←255
[16]  ⍝
[17]  ⍝ Show the dialog. If user presses Cancel, quit
[18]  :If 1=DLG.Show
[19]    ⍝ He pressed OK
[20]    'Selected font: ',⍕DLG.font
[21]    'Selected color: ',⍕1↑DLG.color
[22]  :EndIf
[23]  →0
[24]  MAC:
[25]  'This demo cannot be run on the Macintosh because the'
[26]  'ChooseFont object is not supported'


children class color data events font methods name opened properties range scale self style tie


Close Create Delete New Open Send Set Show Trigger


onClose onDestroy onOpen onSend

Topic: APLX Help : System Classes : List of Classes : ChooseFont
[ Previous | Next | Contents | Index | APL Home ]