Drawing the Occidental Glyphs Using VARKON

Contents

  1. Introduction
  2. Project Architecture
  3. Data Files
  4. Active Module (main()) and makefile
  5. Driver (driver.MBS) and Interactive Input
  6. Show One Table (show_one_table.MBS)
  7. Check a Table (check_table.MBS)
  8. Display a Table (display_table.MBS)
  9. Show One Range (show_one_range.MBS)
  10. Check a Range (check_range.MBS)
  11. Display a Range (display_range.MBS)
  12. Show One Glyph (show_one_glyph.MBS)
  13. Check a Glyph (check_glyph.MBS)
  14. Display a Glyph (display_glyph.MBS)
  15. Get a Glyph's Radius (get_glyph_radius.MBS)
  16. Read a Glyph (read_glyph.MBS)
  17. Draw a Glyph (draw_glyph.MBS)
  18. Plot All Tables, Ranges, and Glyphs (plot_all.MBS)
  19. Converting PLT to Postscript and PNG
  20. Tarball of this Page, the Data, and the Code

1 - Introduction

In exploring a repertory of glyphs, it's handy to have pictures of them. Given the glyph data, these can be created quite easily using my CAD program of choice, VARKON®. This chapter explores the use of VARKON to draw the glyphs. If you're just interested in seeing the glyphs as drawn, skip it and go to the next chapter, The Occidental Glyph Repertory by Ranges.

Just to avoid confusion, I'll state what might be the obvious. Although one of my purposes in this project was to adapt some of the Hershey glyphs to provide new fonts for VARKON, the drawings here are done as ordinary VARKON drawings. They do not employ VARKON's font mechanism at all.

This web page, and the files linked to it, contain all of the Hershey data files and the complete VARKON MBS code for displaying individual glyphs, ranges of glyphs, and tables of ranges of glyphs. Although I started working on these with earlier versions of VARKON, as shown here they require at least VARKON 1.18A because the MBS code now uses long module names.

Note: If you use any of the code here, use the versions in the files. Do not cut-and-paste from the web page, as it may have XML entities substituted for some of the literal characters present in the files.

For more information on VARKON, see its home page at: http://www.tech.oru.se/cad/varkon/

(Aside: This entire exercise may be seen as an extended argument for Literate Programming, but for the present to have sidestepped one more time into Literate Programming tools, especially as used with XML, would have prolonged a project that already had taken two years too long. Next time.)

2 - Project Architecture

Here is a diagram of the overall organization of this VARKON project.

                              project: hershey
                                  job: main
                       [Active Module: main()]
                                     |
                                  driver()
                                     |
               +---------------------+------------------------+--------+
               |                     |                        |        |
        show_one_table()             |                        |     plot_all()
          /         \                |                        |
check_table()  display_table()       |                        |
                              \      |                        |
                              show_one_range()                |
                                 /         \                  |
                         check_range()  display_range()       |
                                                       \      |
                                                       show_one_glyph()
                                                         /         \
                                                 check_glyph()  display_glyph()


                                  get_glyph_radius()  read_glyph() draw_glyph()

Text Files:
   makefile
   $HOME/hershey_data/data_glyphs_occidental.txt
   $HOME/hershey_data/list_glyphs_occidental.txt
   $HOME/hershey_data/list_ranges_occidental.txt
   $HOME/hershey_data/list_tables_occidental.txt
   $HOME/hershey_plots/
   GNU General Public License 2 (gpl.txt)

In the sections which follow, I'll do a depth-first, left-to-right traversal of this architecture by MBS module.

3 - Data Files

This VARKON project assumes the existence of four data files.

The data file data_glyphs_occidental.txt is the result of processing the Hershey Occidental glyph data as presented in the GNU Plotutils, version 2.4.1. See the prior chapter "The GNU Plotutils' Distribution for information on how this extraction was accomplished. This file must reside in a subdirectory called "hershey_data" of the VARKON user's home directory.

The three data files list_glyphs_occidental.txt, list_ranges_occidental.txt, and list_tables_occidental.txt also must reside in the subdirectory called "hershey_data" of the VARKON user's home directory. These files contain the glyph annotations and the subdivisions of the glyphs into "ranges" and "tables."

The overall subject of organizing principles within the occidental glyphs has been discussed previously in the chapter "Organizing Principles within the Occidental Glyphs."

The annotation of the glyphs (list_glyphs_occidental.txt) has been discussed previously in the chapter "Annotating the Occidental Glyph Data."

The division of the occidental glyphs into "ranges" (list_ranges_occidental.txt) has been discussed previously in the chapter "Dividing the Glyphs into Ranges."

The division of the occidental glyphs into "tables" of ranges (list_tables_occidental.txt) has been discussed previously in the chapter "Dividing the Glyphs into Tables."

The project also relies on the existence of a subdirectory called "hershey_plots" in the VARKON user's home directory.

4 - Active Module (main()) and makefile

This is not the place to discuss VARKON in general. Suffice it to say that in VARKON drawings are represented by programs in VARKON's own programming language, "MBS." Drawings may be edited interactively (with changes automatically reflected back into MBS terms), or constructed by writing and compiling MBS programs, or a mixture of the two approaches. I prefer to work entirely by writing MBS programs.

Each VARKON "project" may consist of one or more "jobs." Each job in turn has at any one time an "Active Module" which is its main MBS program. The Active Module for this job is very simple:

GLOBAL DRAWING MODULE main();


BEGINMODULE

  clear_gm();
  clear_pm();
  part(#1,driver(0));

ENDMODULE

(If you're running these examples, just create a new VARKON project for them, create a job within it (I call my "main"), and type the above Active Module main() in by hand.)

Outside of the "main" module, all of the MBS modules are handwritten and compiled externally using VARKON's mbsc compiler. The process of compiling them is coordinated in the VARKON mbs directory using the following "makefile":

ROOTS=$(basename $(wildcard *.MBS))
OBJS=$(patsubst %,../lib/%.MBO,$(ROOTS))

all: $(OBJS)

$(OBJS): ../lib/%.MBO : %.MBS
        mbsc $*.MBS
        mv   $*.MBO ../lib

clean:
        rm -f *.MBO
        rm -f ../lib/*.MBO

# references: info make, Static Pattern Rules
#             info make, Automatic Variables

5 - Driver (driver.MBS) and Interactive Input

Since VARKON strips comments from the Active Module, I wished to keep it as small as possible and removed the overall driver for the program to a separate, mbsc-compiled, module: "driver.MBS".

This driver() module will put up a window containing several buttons indicating the various things that may be drawn (in VARKON, a drawing can have its own user interface in this manner). There are three general categories of actions, pertaining to tables, ranges, and glyphs. Each may be shown using plain glyph displays or boxed glyph displays.

driver actions

For each type of drawing, the driver pops up a VARKON inpmt() input window which asks for more information (which table, which range, which individual glyph). For example:

interactive selection window

(Note: When a glyph is displayed, it is also plotted automatically. When a range is displayed, all of its glyphs are plotted automatically. When a table is displayed, all of its ranges and all of the glyphs in the ranges are also plotted automatically. This isn't efficient, but efficiency isn't the point here; once generated, these plots (converted to postscript or to bitmapped images) will be what I refer to for the most part.)

The driver is a straightforward example of setting up VARKON windows and buttons and then running an event loop; it isn't worth going through in detail. Here is the source: driver.MBS.

6 - Show One Table (one_table.MBS)

The glyph ranges may be plotted together in three tables which contain at most 8 range displays across and 8 range displays down. Each table fits, with bare legibility (if that) on a sheet of US letter size paper. The MBS module for orchestrating the printing of one of these tables is "show_one_table.MBS".

Here's an example of such a table. As displayed here as a fixed-size image, it is barely readable. As generated within VARKON, however, you can zoom and pan to examine details very closely. It does take a while to generate - from about 80 seconds for table 0 (plain) to about five minutes for table 2 (boxed) on a 900MHz processor based system.

table 0 of hershey glyphs

As can be seen below, the module is trivial. It simply calls check_table() to verify that a valid table number was requested and to get its name, and then calls display_table() to display it. The only refinement is that it creates a coordinate system (at (0,0)) in which the table will be displayed (also, as it turns out, at (0,0) in that coordinate system). This allows the table to be repositioned (using display_table()) if that might be desirable later.

7 - Check a Table (check_table.MBS)

[Note: At present, you'll just have to read code for most of this.]

check_table.MBS

8 - Display a Table (display_table.MBS)

display_table.MBS

9 - Show One Range (show_one_range.MBS)

show_one_range.MBS

10 - Check a Range (check_range.MBS)

check_range.MBS

11 - Display a Range (display_range.MBS)

display_range.MBS

12 - Show One Glyph (show_one_glyph.MBS)

show_one_glyph.MBS

13 - Check a Glyph (check_glyph.MBS)

check_glyph.MBS

14 - Display a Glyph (display_glyph.MBS)

display_glyph.MBS

15 - Get a Glyph's "Radius" (get_glyph_radius.MBS)

This module, get_glyph_radius.MBS, is the first of three low-level modules which do the heavy lifting. It involves VARKON file I/O and the ad hoc parsing of lines from a file. Because of this, its need for error detection is much greater. I don't pretend fully to have met that need, but there is some attention to it.

The "radius" is the half-width of the display box surrounding the glyph (it is purely a convention of my display; it has nothing to do with the size of the glyph's encoding matrix or with the left and right edges of the glyph as encoded).

This "radius" is characteristic not arbitrarily of individual glyphs but rather uniformly across ranges of glyphs (this assures the evenness of the display of an entire range). It is therefore encoded in the file "list_ranges_occidental.txt". I assume that a copy of this file has been placed in the subdirectory "hershey_data" of the home directory of the VARKON user.

16 - Read a Glyph (read_glyph.MBS)

This module, read_glyph.MBS, reads the glyph's data from the file data_glyphs_occidental.txt, a copy of which is assumed to exist in the "hershey_data" directory of the VARKON user's home directory.

17 - Draw a Glyph (draw_glyph.MBS)

Finally (whew), we draw a glyph: draw_glyph.MBS.

18 - Plot All Tables, Ranges, and Glyphs (plot_all.MBS)

Note: Plotting everything takes quite some time.

19 - Converting PLT to Postscript and PNG

VARKON outputs "plots" (it is a CAD [meta]program, after all) as ".PLT" suffixed files. These may be converted to Postscript using the "postscript" program supplied with VARKON. From Postscript, these plots may be converted further to bitmapped images in, say, PNG format using tools such as ImageMagick or The GIMP.

Here is a utility, written as a GNU make(1) makefile, which orchestrates the conversion from PLT to Postscript. It is intended to be run from the hershey_plots directory.



(So as to avoid confusion with the "hershey" project makefile, this makefile is called "makefile-convert". In use in $HOME/hershey_plots, it may simply be renamed "makefile" or it may be used with the "-f" parameter to GNU make(1).) Here it is as an ASCII file: makefile-convert

20 - Tarball of this Page, the Data, and the Code

drawing-varkon-0.1.tar.gz

Exploring Dr. Hershey's Typography
CircuitousRoot