Graphics Programs Reference
In-Depth Information
Showing Text
The
Tj
operator shows text at the current position. This, in combination with the text
positioning operators we have already seen would suffice. However, for convenience
and brevity, three additional operators (
'
,
''
, and
TJ
) are provided. These are shortcuts
for common combinations of text-showing and text-positioning. The text showing op-
erators are summarized in
Table 6-3
.
Table 6-3. Operators for showing text
Operands
Operator
Function
string
Tj
Show
string
at the current position.
string
'
Go to the next line, taking into account the leading and text matrices, and show
string
at the
new position. The same as using
T*
followed by
Tj
.
wordspace
,
charspace
,
string
Set the word spacing to
wordspace
and the character spacing to
charspace
. Go to the next line,
taking into account the leading and text matrices, and show
string
at the new position. The
same the sequence
wordspace
Tw
charspace
Tc
string
'
.
''
array
TJ
This operator allows a text string to be shown with adjustments for individual glyph positions
(for example, kerning). The array contains strings and numbers, in any combination. String
entries are shown as normal; number entries adjust the text matrix horizontally by subtracting
that amount (expressed in thousandths of a unit of text space).
We will now go through some examples of showing text, using the standard font and
the Latin-1 based PDFDocEncoding for simplicity. As always, these examples can be
found in the online resources.
Character and word spacing
Here is our first example, where we show some lines of text using various operators.
The result is illustrated in
Figure 6-1
:
BT
/F0 36 Tf
1 0 0 1 120 350 Tm
50 TL
(Character and Word Spacing) Tj T*
3 Tc
(Character and Word Spacing) Tj T*
10 Tw
(Character and Word Spacing) Tj
ET
In this example we have:
1. Used
Tf
to select font
/F0
at 36 points.
2. Used
Tm
to set the text position to (120, 350).
3. Used
TL
to set the leading to 50 points.
4. Shown a string with
Tj
, and used
T*
to move to the next line.