How do I Create an ANSI Font Menu?

This lesson will show you how to creation an option menu that displays all of the ANSI fonts available on the computer.

Create An Option Button

Create An Option Button

Drag an option button from the Tools palette onto a stack.

Build The Font List

Build The Font List

Open the script editor of the option menu and enter the script below. This option menu will respond to the "BuildANSIFontList" message and populate the option menu with ANSI fonts.

The script begins by getting all available fonts on the system (1) and sorting them (2). The script then checks the fontlanguage of each font and filters out any fonts that are not ANSI fonts (3) before assigning the font list to the option menu.

==========

Copy & Paste

==========

command BuildANSIFontList
	put the fontnames into theListOfAllFonts
	
	## sort list of fonts
	sort theListOfAllFonts
	
	## Strip out non-ANSI fonts
	repeat for each line theFont in theListOfAllFonts
		if the fontlanguage of theFont is "ANSI" then
			put theFont & cr after theANSIFonts
		end if
	end repeat
	
	## Get rid of trailing CR
	delete the last char of theANSIFonts
	
	set the text of me to theANSIFonts
end BuildANSIFontList

Build Font List

Build Font List

Build the font list by sending "BuildANSIFontList" to the button by right-clicking on the menu and selecting the Send Message > BuildANSIFontList menu item. Alternatively you can use the Message Box to send the message to the menu.

Preview The List

Preview The List

Switch to Run mode. Click on the option menu to view the list of fonts.

0 Comments

Add your comment

E-Mail me when someone replies to this comment