Font Tool
Volume Number: 5
Issue Number: 3
Column Tag: Pascal Procedures
Related Info: Font Manager
How To Write a Font Tool for MPW
By Randy Leonard, Jacksonville, FL
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
[Randy Leonard is currently employed by TML Systems, Inc. while completing
his Master’s thesis in computer science at the University of Central Florida. His
thesis involves improving the efficiency of several key algorithms in constructive
solid geometry (CSG). The thesis is written entirely with TML Pascal II and he uses
several of his own MPW Tools to aid in his development.]
The introduction of the Macintosh Programmer’s Workshop (MPW) v3.0 this
January requires that we revisit this programming environment and study its new and
exciting features as well as the significant features of previous versions of the
product. This article discusses how the MPW environment can be enhanced with the
addition of your own integrated programming tools. The type of commands introduced
here are capable of executing in the background while running MPW v3.0. This
capability enables you to continue your most important task in the foreground while
such tasks as compiling and linking of programs occur in the background. Indeed, the
tool introduced here may also run in the background.
Macintosh Programmer’s Workshop
The Macintosh Programmer’s Workshop is the official Macintosh development
environment from Apple Computer, Inc. The MPW Shell is a complete development
system for the Macintosh that includes, among other things, a multi- windowing text
editor and a command processor. Also included with MPW is a linker, make facility,
resource compiler, resource decompiler, source code management system, and more.
There is also complete online help as well as an optional graphical interface for just
about every command available in MPW.
MPW has often times been accused of having a steep learning curve. The author
believes this false accusation can be based upon two pretexts. The first is due to
unfamiliarity with the product [if you come from Big Blue or have been inVAXinated, it
might be familiar, but still not easy-ed]. The second is due to the extraordinary power
that MPW can provide its advanced users via the command line environment and
MPW’s advanced command processor. The truth of the matter is that MPW is as easy to
learn and use as any other programming environment if you were to utilize only those
features found in MPW that the other programming environments provide.
The true beauty of MPW is found in its open architecture. That is, anyone can
expand the functionality of MPW to suit his own needs. There exist two methods of
adding new commands to MPW: scripts and tools. This two part article will
demonstrate how to create new programming tools and how to fully integrate these
tools into the MPW environment. This month’s article will give the motivation for
writing your own MPW tool and show how it is done. Part two, to appear next month,
will demonstrate how to integrate the tool into the MPW’s online help facility and how
to develop a graphical interface for the new command.
MPW Tools
Tools provide a method of adding commands that are not inherent to the MPW
command processor. For example, the TML Pascal II compiler is an extension to the
MPW environment and is therefore implemented as a tool. Other examples of MPW
Tools are the canonical speller Canon and TMLPasMat. TML Systems, in fact, used
these two tools to put the finishing touches on both its Source Code Library II and
example programs found on the TML Pascal II distribution disk. Canon adjusts all
identifiers in source code files so they have the same same capitalization as found in
Inside Macintosh. TMLPasMat will format all Pascal source code files to a consistent
format that you define. These two tools were e specially helpful since programming
styles of the programmers at TML Systems vary.
However, we needed even more help in providing a consistent format for all
source code files that left our office. As it turns out, some programmers at TML
Systems prefer different fonts and different font sizes for their work. Some
programmers would print their work on the laser writer reduced to 75% while others
would print at 100%. Some prefer different tab settings and still others have large
screens on which to edit their programs. This last problem could be e specially
annoying to our customers with small screens since only a small part of the window of
a text file would appear on their screen when they opened the file. Each customer could
easily resolve the problem by resizing the window for his screen, but what if the
window appeared off-screen to begin with!
Another problem unrelated to each programmer’s taste was the problem of USYM
resources. The TML Pascal II compiler writes symbol table information for separately
compiled units to the resource fork of the main unit source code file as USYM
resources. This is perhaps a more favorable solution than creating separate files to
hold the information as other compilers do. Deleting a file that contains symbol table
information is easy, but how do you easily erase resources from the resource fork of a
source code file?
To solve the above problems, we developed an MPW tool that changed the font of
MPW text files to any specified font and font size. Tab spacing is set to any defined
value and the window is made to appear on any Macintosh screen with the top left
corner slightly staggered from other windows and the bottom right corner extending to
the bottom right of the screen. The page setup is reset to print at 100%. All USYM and
other resources are optionally deleted as well. We call this tool ChangeTextRes.
Below, we explain how to implement this tool, but first a little background.
What Every Tool has in Common
MPW Tools are usually invoked from the command line of the MPW Shell. The
command line of an MPW command is simply the line on which the MPW command
exists. Parameters are passed to the tool by placing them on the command line. A
graphical interface for the tool, called the Commando, does exist, but is not typically