List all Fonts
This program lists all available fonts on your computer. When you click a font in the list box, the gray text area to the left displays a text using that font. Additional controls are available to select the font size and the font attributes.
The program shows how to work with list boxes, check boxes, and sliders. It also shows how to define and set a font at a control.
See the SoundCheck program for a simpler program that lists and plays all available sounds, and InstrumentCheck for a program that displays all available musical instruments that the computer’s music synthesizer can play.
FontCheck.lgo
; Routine to review all the fonts available to Logo
TO FONTCHECK
IF MEMBER? "FONTWINDOW EVERY "WINDOW SETACTIVEWINDOW "FONTWINDOW STOP
(LOCAL "LINE.FEED "PARAGRAPH "SAMPLE.TEXT "P1 "P2 "P3 "P4)
MAKE "LINE.FEED CHAR 10
MAKE "PARAGRAPH WORD :LINE.FEED :LINE.FEED
MAKE "P1 'It was a dark and stormy night.' from 'A Wrinkle in Time' by Madeline L'Engle.
MAKE "P2 'In an old house in Paris that was covered with vines lived twelve little girls in two straight lines.' from 'Madeline' by Ludwig Bemelmans.
MAKE "P3 'Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much.' from 'Harry Potter and the Philosopher's Stone' (or 'Harry Potter and the Sorcerer's Stone') by J.K. Rowling.
MAKE "P4 'It was the best of times, it was the worst of times ...' from 'A Tale of Two Cities' by Charles Dickens.
MAKE "SAMPLE.TEXT (WORD :P1 :PARAGRAPH :P2 :PARAGRAPH :P3 :PARAGRAPH :P4)
DECLARE "GRAPHICS "FONTWINDOW
PPROP "FONTWINDOW "DRAWSIZE [700 350]
PPROP "FONTWINDOW "POSITION [100 35]
PPROP "FONTWINDOW "TITLE "|FONT Check ... Fonts on your computer available to Terrapin Logo|
DECLARE "LISTBOX "FONTLIST
PPROP "FONTLIST "SIZE [200 300]
PPROP "FONTLIST "POSITION [90 0]
PPROP "FONTLIST "RUN [FONTSET]
PPROP "FONTLIST "TOOLTIP "|Click to select FONT|
DECLARE "BUTTON "FONTCLOSE
PPROP "FONTCLOSE "POSITION [260 70]
PPROP "FONTCLOSE "TEXT "|Close|
PPROP "FONTCLOSE "RUN [ERASE "FONTWINDOW]
PPROP "FONTCLOSE "TOOLTIP "|Click to close the Font Check window|
DECLARE "SCROLLBAR "FONTSIZE
PPROP "FONTSIZE "POSITION [260 0]
PPROPS "FONTSIZE [MINIMUM 8 MAXIMUM 24 VALUE 8 SMALLINC 1 LARGEINC 4]
PPROP "FONTSIZE "TOOLTIP "|Adjust font size from 8 to 24|
PPROP "FONTSIZE "RUN [FONTSET]
DECLARE "STATICTEXT "FONTNOTE
PPROP "FONTNOTE "POSITION [260 -20]
PPROP "FONTNOTE "TEXT "|Font size|
PPROP "FONTNOTE "TOOLTIP "|Current font size|
DECLARE "STATICTEXT "FONTATTRIBUTE
PPROP "FONTATTRIBUTE "POSITION [260 -103]
PPROP "FONTATTRIBUTE "TEXT "|Attribute |
PPROP "FONTATTRIBUTE "TOOLTIP "|Bold + Italic + Underline|
DECLARE "CHECKBOX "BOLD
PPROP "BOLD "POSITION [260 -47]
PPROP "BOLD "TEXT "|Bold (1)|
PPROP "BOLD "TOOLTIP "|Click to check; click again to clear|
PPROP "BOLD "RUN [IF GPROP "BOLD "STATE [PPROP "BOLD "VALUE 1] [PPROP "BOLD "VALUE 0] FONTSET]
PPROP "BOLD "VALUE 0
DECLARE "CHECKBOX "ITALIC
PPROP "ITALIC "POSITION [260 -66]
PPROP "ITALIC "TEXT "|Italic (2)|
PPROP "ITALIC "TOOLTIP "|Click to check; click again to clear|
PPROP "ITALIC "RUN [IF GPROP "ITALIC "STATE [PPROP "ITALIC "VALUE 2] [PPROP "ITALIC "VALUE 0] FONTSET]
PPROP "ITALIC "VALUE 0
DECLARE "CHECKBOX "UNDERLINE
PPROP "UNDERLINE "POSITION [260 -85]
PPROP "UNDERLINE "TEXT "|Underline (4)|
PPROP "UNDERLINE "TOOLTIP "|Click to check; click again to clear|
PPROP "UNDERLINE "RUN [IF GPROP "UNDERLINE "STATE [PPROP "UNDERLINE "VALUE 4] [PPROP "UNDERLINE "VALUE 0] FONTSET]
PPROP "UNDERLINE "VALUE 0
FOREACH FONTS [
IGNORE ASK "FONTLIST [ADDSORTED "?]
]
DECLARE "STATICTEXT "FONTSAMPLE
PPROP "FONTSAMPLE "SIZE [300 300]
PPROP "FONTSAMPLE "POSITION [-170 0]
PPROP "FONTSAMPLE "TOOLTIP "|Samples from famous authors|
PPROP "FONTSAMPLE "TEXT :SAMPLE.TEXT
; set the sample font to get things started
PPROP "FONTLIST "INDEX 0
FONTSET
SETACTIVEWINDOW "FONTWINDOW
END
TO FONTSET
(LOCAL "FS.FONT "FS.SIZE "FS.ATTRIBUTE)
MAKE "FS.FONT GPROP "FONTLIST "TEXT
MAKE "FS.SIZE INT GPROP "FONTSIZE "VALUE
MAKE "FS.ATTRIBUTE (SUM GPROP "BOLD "VALUE GPROP "ITALIC "VALUE GPROP "UNDERLINE "VALUE)
PPROP "FONTSAMPLE "FONT (LIST :FS.FONT :FS.SIZE :FS.ATTRIBUTE)
PPROP "FONTNOTE "TEXT WORD "|Font size | :FS.SIZE
PPROP "FONTATTRIBUTE "TEXT WORD "|Attribute | :FS.ATTRIBUTE
END
FONTCHECK
Procedure | FONTCHECK |
Description | Lists and shows all available fonts |
Level | Intermediate |
Tags | Fonts, Controls |