Skip to content

Instantly share code, notes, and snippets.

@nst
Created October 26, 2025 18:14
Show Gist options
  • Select an option

  • Save nst/2911baaca917fc626d4de5aedfd5836c to your computer and use it in GitHub Desktop.

Select an option

Save nst/2911baaca917fc626d4de5aedfd5836c to your computer and use it in GitHub Desktop.
%!PS-Adobe-3.0
%%Title: Core 35 PostScript Fonts Showcase
%%Creator: Gemini
%%Pages: 1
%%EndComments
% --- Define Variables ---
/FontSize 12 def
/LineHeight 15 def
/LeftMargin 72 def
/TopMargin 750 def
/BottomMargin 72 def
% Ypos is our "cursor" for the current vertical position
/Ypos TopMargin def
% --- Define the Font List (Array) ---
/FontList [
/AvantGarde-Book
/AvantGarde-BookOblique
/AvantGarde-Demi
/AvantGarde-DemiOblique
/Bookman-Light
/Bookman-LightItalic
/Bookman-Demi
/Bookman-DemiItalic
/Courier
/Courier-Oblique
/Courier-Bold
/Courier-BoldOblique
/Helvetica
/Helvetica-Oblique
/Helvetica-Bold
/Helvetica-BoldOblique
/Helvetica-Narrow
/Helvetica-Narrow-Oblique
/Helvetica-Narrow-Bold
/Helvetica-Narrow-BoldOblique
/NewCenturySchlbk-Roman
/NewCenturySchlbk-Italic
/NewCenturySchlbk-Bold
/NewCenturySchlbk-BoldItalic
/Palatino-Roman
/Palatino-Italic
/Palatino-Bold
/Palatino-BoldItalic
/Times-Roman
/Times-Italic
/Times-Bold
/Times-BoldItalic
/ZapfChancery-MediumItalic
/Symbol
/ZapfDingbats
] def
% --- Define a Procedure to Draw a Line ---
% Takes one argument from the stack: /FontName
/showLine {
% Stack: /FontName
% 1. Check if we need a new page
Ypos LineHeight sub dup /Ypos exch def % Ypos = Ypos - LineHeight
BottomMargin lt {
showpage % Eject the page
/Ypos TopMargin def % Reset Y to top
} if
% 2. Set the font
dup % Stack: /FontName /FontName
findfont FontSize scalefont setfont
% Stack: /FontName
% 3. Position the text
LeftMargin Ypos moveto
% 4. Show the font's name
dup % Stack: /FontName /FontName
% Create a 40-character string to act as a buffer
40 string % Stack: /FontName /FontName (empty_string_40)
% Convert the name object to a string, writing into the buffer
cvs % Stack: /FontName (FontName_as_string)
show % Consumes the string, Stack is now: /FontName
% 5. Show sample text, with special cases for Symbol/Dingbats
dup /Symbol eq {
% It's the Symbol font
pop % Discard the name
% Use octal codes for alpha, beta, gamma...
( Sample: \141\142\143\144\145\146\147 \245\261\256\260\253) show
} {
% Not Symbol, check for Dingbats
dup /ZapfDingbats eq {
% It's the ZapfDingbats font
pop % Discard the name
% Use octal codes for various dingbats
( Sample: \041\042\043\044\045\046\047\050\051\052) show
} {
% It's a regular text font
pop % Discard the name
( Sample: The quick brown fox jumps over the lazy dog. 12345) show
} ifelse
} ifelse
} def
% --- Main Program Execution ---
% 1. Print a title for the page
/Helvetica-Bold findfont 16 scalefont setfont
LeftMargin TopMargin 18 add moveto % Move up a bit for the title
(Core 35 PostScript Fonts Showcase) show
% 2. Loop through the FontList array
FontList {
showLine % The item (e.g., /AvantGarde-Book) is on the stack
} forall
% --- Eject the final page ---
showpage
%%EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment