Important: The information in this document is obsolete and should not be used for new development.
Text in QuickDraw Pictures
This section describes aspects of how text is stored in picture files, including related limitations and restrictions, such as the following:
- The
grayishTextOr
transfer mode is not stored in pictures files, and therefore you cannot use it for printing.- Inside a picture definition,
DrawText
cannot have abyteCount
greater than 255.
Fonts
Whenever you record text in a picture file, QuickDraw stores the name of the current font and uses it when playing back the picture. This is true for pictures drawn in both the original and color graphics ports. The opcode that QuickDraw uses to save this information is$002C
. Here is its data type:
PictFontInfo = Record length: Integer; {length of data in bytes} fontID: Integer; {ID in the source system} fontName:STR255; End;QuickDraw saves this information only one time for each font used in a picture.
The code in Listing 3-10 generates a picture file containing the font information that Listing 3-11 shows.Listing 3-10 Generating a picture file with font information
GetFNum ('Venice', theFontID); {Set a font before opening PICT} TextFont (theFontID); pHand2 := OpenPicture (pictRect); MoveTo(20,20); DrawString(' Better be Venice'); GetFNum('Geneva', theFontID); TextFont(theFontID); MoveTo(20,40); DrawString('Geneva'); GetFNum('Geneva', theFontID); TextFont(theFontID); MoveTo(20,60); DrawString('Geneva'); ClosePicture;When QuickDraw plays back a picture, it uses the font family ID (fontID
) as a reference into the list of font names which are used to set the correct font on the target system.Listing 3-11 A picture file with font information
OpCode 0x002C {9, "0005 0656 656E 6963 65"} /* save current font */ TxFont 'venice' DHDVText {20, 20, " Better be Venice"} OpCode 0x002C {9, /* save next font name */ "0003 0647 656E 6576 61"} TxFont 'geneva' DVText {20, "Geneva"} OpCode 0x002C {11, /* ditto */ "0002 084E 6577 2059 6F72 6B"} TxFont 'geneva' /* second Geneva does not need another $002C */ DVText {20, "Geneva"}Text With Multiple Style Runs
If you used theGetFormatOrder
procedure to determine the correct order in which to draw text consisting of multiple style runs, the style runs are stored in display order when you record the text in a picture file. To reconstruct the storage order of the text from the picture file, an application that reads the style runs into memory from the picture file must then use theGetFormatOrder
procedure to reverse the display order to storage order. Finally, the application must write the text into memory again, following the order thatGetFormatOrder
returns.For example, suppose you have a a text string consisting of three style runs with different text directions--A (right-to-left), B (left-to-right), and C (left-to-right)--in storage order. You number them: A=1, B=2, C=3.
You call
GetFormatOrder
for these style runs with a line direction of right to left, and it returns 2, 3, 1. When you draw the style runs in display order and record them in a picture file, they are written to the picture file in display order. Suppose that after you record the picture file, an application cuts and pastes the text. Now the style runs are written to memory in display order: B, C, A.To get the proper storage order, you call
GetFormatOrder
again, with the same line direction that you used the first time you calledGetFormatOrder
to determine the display order, and it produces the original storage order: A, B, C.