1. show

Paint text string at current point.

1.1. Syntax

string show → -

1.2. Stack Effects

Before:

string

After:

(empty)

1.3. Description

show paints the characters identified by the elements of string on the current page starting at the current point, using the font face, size, and orientation specified by the most recent setfont or selectfont.

The spacing from each character of the string to the next is determined by the character’s width, which is an (x, y) displacement that is part of the character’s definition. When it is finished, show adjusts the current point in the graphics state by the sum of the widths of all the characters shown.

show requires that the current point initially be defined (for example, by moveto); otherwise, it executes the error nocurrentpoint.

If a character code would index beyond the end of the font’s Encoding, or the character mapping algorithm goes out of bounds in other ways, a rangecheck error occurs.

1.4. Parameters

string (string) : The text to display, where each byte is a character code

1.5. Character Encoding

Characters are encoded as integers 0-255 in the string: - Each byte indexes into the font’s Encoding array - The Encoding maps character codes to character names - Character names map to glyph descriptions in CharStrings

1.6. Examples

1.6.1. Basic Text Display

/Helvetica findfont 12 scalefont setfont
100 700 moveto
(Hello, World!) show

1.6.2. Multiple Lines of Text

/Helvetica findfont 12 scalefont setfont

100 700 moveto (Line 1) show
100 685 moveto (Line 2) show
100 670 moveto (Line 3) show

1.6.3. Text with Current Point Tracking

/Helvetica findfont 12 scalefont setfont
100 700 moveto

(Hello ) show
currentpoint       % Get position after "Hello "
(World!) show      % Continue from that point

1.6.4. Centered Text

/centerText {  % string centerText -
  dup stringwidth pop  % Get text width
  2 div               % Half width
  neg 0               % Negative offset
  rmoveto             % Move back
  show                % Show text
} def

300 400 moveto
(Centered Text) centerText

1.7. Errors

invalidaccess : Font or string has restricted access

invalidfont : Current font is not valid

nocurrentpoint : Current point is not defined

rangecheck : Character code exceeds encoding bounds

stackunderflow : No operand on stack

typecheck : Operand is not a string

1.8. Current Point Behavior

The current point is updated by the sum of all character widths:

100 100 moveto
currentpoint pop pop  % x=100, y=100

(ABC) show
currentpoint pop pop  % x=100+width(A)+width(B)+width(C), y=100

For most fonts, character widths move the current point horizontally. However, some fonts (particularly vertical writing fonts) may have vertical width components.

1.9. Character Width Vectors

Each character has a width vector (wx, wy):

width = (wx, wy)

After showing character c:

currentpoint' = currentpoint + width(c)

For a string "ABC":

currentpoint' = currentpoint + width(A) + width(B) + width(C)

1.10. Common Patterns

1.10.1. Right-Aligned Text

/rightShow {  % string x y rightShow -
  moveto
  dup stringwidth pop neg 0 rmoveto
  show
} def

(Right aligned) 500 700 rightShow

1.10.2. Text on a Path

% Show text along a curved path
newpath
200 200 100 0 180 arc

% Convert path to show operations
/charpath true charpath
gsave
  0 setgray fill
grestore

1.10.3. Vertical Text

% Rotate for vertical text
gsave
  100 700 translate
  90 rotate
  0 0 moveto (Vertical) show
grestore

1.11. Performance Considerations

  • show is the fastest text rendering operator

  • Characters are cached for efficiency

  • Font cache improves performance for repeated characters

  • Use show over charpath when possible

1.12. Comparison with Other Text Operators

Operator Purpose

show

Basic text painting (fastest)

ashow

Add uniform spacing to all characters

widthshow

Adjust width of specific character

awidthshow

Combine ashow and widthshow

kshow

Execute procedure between characters (kerning)

cshow

Execute procedure for each character (Level 2)

charpath

Get character outlines as path

1.13. See Also

  • ashow - Show with character spacing adjustment

  • widthshow - Show with selective character width adjustment

  • awidthshow - Combine ashow and widthshow

  • kshow - Show with kerning procedure

  • cshow - Show with procedure per character (Level 2)

  • charpath - Get character outlines as path

  • stringwidth - Calculate text width

  • setfont - Establish current font

  • moveto - Set current point


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.