WebCOMAL - A Font Viewer

This is a simple font viewer which displays all the characters available in a selection of fonts. The viewer displays the characters in a browser window, along with their ASCII code numbers. The user can choose the display font size before launching the weblet. It was developed while we were looking for graphics-style font characters to use as "enhancers" to the ordinary text output from WebCOMAL. Before tackling this section, you should have worked through the first article on WebCOMAL, webcomal.html and be able to run a COMAL weblet on your system. We haven't put the files onto the downloads page, because they are just about short enough for readers to copy-and-paste the source codes directly from this browser window into either UniCOMAL or MS-Notepad as appropriate. (If you're not sure about copy-and-pasting into UniCOMAL, see the article UniCOMAL and MS-Windows on the main UniCOMAL pages.)

MS-Windows 98 has an utility, in Control Panel, to display the fonts available on the computer. Doing "Start > Settings > Control Panel > Fonts" displays the fonts window. Double-clicking any one of the available fonts gives details about the font, its characteristics, and samples of its characters at various sizes. You don't get all the characters, however, and you don't see quite all of the available fonts. Another way to view Windows fonts is to use the "Character Map" utility. On our system, this is launched by doing "Start > Programs > Accessories > System Tools > Character Map". This one shows every character available in the font, and also has fonts such as Terminal which don't appear in the "Fonts" utility.

We took a selection of fonts which interested us and typed their names into a COMAL DATA block like this:


   DATA "wingdings","webdings","terminal","system"
   DATA "symbol","small fonts","map symbols","fixedsys"
   DATA "arial black","unknown font"

We included "unknown font" to test the response, from the browser, to failing to find one of the requested fonts on the system. This data block was tacked onto the end of the following weblet, then saved as "webfonts\fontsamp.cml":


0100 // Display fonts from Characters 32 to 255
0110 // Webfonts\Fontsamp.cml: for Internet Module
0120 // (C) MacharSoft May 2000
0130 USE internet
0140 start_html("WebCOMAL: Font Samples in Windows")
0150 fontsize$:=get_parameter$("size")
0160 REPEAT
0170   READ font$ // Font names stored in Data Statements
0180   display_font(font$,fontsize$)
0190 UNTIL EOD
0200 end_html
0210 END
0220 //
0230 PROC start_html(title$)
0240   PRINT "<html><head>"
0250   PRINT "<title>"+title$+"</title></head>"
0260   PRINT "<body bgcolor=gold>"
0270   PRINT "<h1>"+title$+"</H1>"
0280 ENDPROC start_html
0290 //
0300 PROC end_html
0310   PRINT "</body></html>"
0320 ENDPROC end_html
0330 //
0340 PROC display_font(f$,fs$)
0350   PRINT "<h3>"+f$+"</h3>"
0360   PRINT "<table>" // Display character number then character in table
0370   FOR character#:=32 TO 255 STEP 8 DO
0380     PRINT "<tr>" // 7 rows of characters in table
0390     FOR char#:=0 TO 7 DO // 8 characters in each row of the table
0400       PRINT "<td width=30 align=right>"
0410       PRINT "<font face=system size="+fontsize$+">"
0420       PRINT STR$(character#+char#)+" "
0430       PRINT "</font>"
0440       PRINT "</td><td width=20 align=center>"
0450       PRINT "<font face="+CHR$(34)+f$+CHR$(34)+" size="+fontsize$+">"
0460       PRINT CHR$(character#+char#)+"  "
0470       PRINT "</font>"
0480       PRINT "</td>"
0490     ENDFOR char#
0500     PRINT "</tr>"
0510   ENDFOR character#
0520   PRINT "</table>"
0530 ENDPROC display_font

Then we wrote this short HTML script, saved as "webfonts\testfonts.html", to launch the weblet:


<html>

<head>
<title>WebCOMAL: Font Samples</title>
</head>

<body>
<h1>Displaying Font Samples from WebCOMAL</h1>
<form action="http://localhost:8080/servlet/comal.ComalServlet" method="POST" target="display">
<input type="hidden" name="COMAL_EXE" value="c:\comal\comal.exe">
<input type="hidden" name="COMAL_PRG" value="c:\comal\webfonts\fontsamp.cml">
<p>Please type a number for the Font Size (1=smallest):  <input name="size" size=2 value="3"> 
<p<input type="submit" value="submit">  <input type="reset" value="reset">
</form>
</body>

</html>

Finally, we ran the ComalServlet as usual, then double-clicked the "webfonts" html script, typed in "8" as the font size, and clicked "Submit". This is part of the resulting page:

You can include whichever fonts you like in the display, by adding extra DATA lines to the weblet, then re-SAVEing the weblet then clicking "Submit" once more in the "testfonts.html" script. The font samples can be printed out from from the webpage at will.



Updated 11 May 2000