QuickDraw – Rotated Text

Yellow circle with rotated textI added support for rotated text in my QuickDraw viewer. While in 2024, this might sound like a trivial thing, you have to remember QuickDraw was designed in a time when text mode was the norm and graphical user interfaces were cutting edge, and text was aligned with the screen, not rotated.

Basically, original QuickDraw did not support rotated text, but the Postscript printers did. So rotated text was handled by having two variants of the data: a bitmap rendering of the text, and a text drawing instruction with some additional information explaining the rotation. As often in these case, there was some hacking around to make sure either version would be selected and instructions the screen renderer would ignore.

Basically it works by using this sequence of instructions:

  1. A QuickDraw comment marks the beginning of a text block (textBegin), it contains extra rendering information (center of the text, angle of rotation).
  2. A Bitmap rendering instruction draws the rendering of the rotated text
  3. A clip instruction blocks further drawing.
  4. A text instruction write the text that should be drawn (rotated).
  5. A QuickDraw comment marks the end of the text block.
  6. The clip is reset so drawing can continue.

So on a screen renderer, the text instruction is ignored because of the clip. When the renderer is a printer (or my program), all non text instruction in the text block are ignored: both the bitmap rendering and the clip operations have no effect, and the renderer just executes the text drawing instruction.

Now this kind of technique is hardly unique, early implementation of Javascript in web-pages had to use a similar tricks: browsers would ignore tags they don’t know, but display the content of these tags as text. As the content of the <script> was not text, the first thing it would contain was an HTML comment start. That comment start would be ignored by browsers would understood the script tag, and older browsers would just see an unknown tag with a large HTML comment inside.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.