FGL Programming Guide for Thermal Printers
Try the free online BOCA FGL editor — design a ticket visually and get the FGL program generated live, or import an existing one: BOCA FGL Ticket Editor →
1. What is FGL
FGL (Friendly Graphics Language), also known as Ghostwriter Printer Language, is a command language for controlling thermal printers. It's widely used in ticketing, event management, boarding passes, and label printing where thermal (direct or transfer) printers are the standard.
Unlike page description languages such as PostScript or PCL, FGL is a lightweight, stream-based protocol. You send a sequence of angle-bracket commands followed by data, and the printer renders the output directly. There is no document model — you position each element (text, barcode, line, image) using absolute coordinates in dots.
FGL supports:
- Up to 16 built-in fonts (F1–F13, F16) with scaling and international character sets
- 1D barcodes: Code39, Code128, EAN-13, EAN-8, UPC, Codabar, Interleaved 2of5
- 2D barcodes: QR codes, PDF-417, Data Matrix, Aztec
- Line drawing, box drawing, and shading patterns
- Dot-addressable graphics, PCX/BMP image support, and stored logos
- Inverse (white-on-black) printing
- Element rotation in 90-degree increments
- Print control: cut, no-cut, repeat, ticket counting, multi-path
Typical ticket sizes are 2.125" × 5.5" (credit card width) or 2.125" × 3.375" at 200 or 300 DPI resolution. This guide is based on the official BOCA Systems FGL46 Programming Guide combined with practical implementation experience.
Compatibility note: FGL has evolved through several revisions (FGL26, FGL42, FGL44, FGL46). Some commands are version-specific — for example, 2D barcodes (PDF-417, Data Matrix, Aztec) require FGL46, and QR versions 2, 11 and 15 need later FGL46 revisions. Use the <S2> command to check your printer's firmware version and always test on target hardware.
2. Command Structure
Every FGL command is enclosed in angle brackets. Commands are chained together without separators, and the data to be printed follows immediately after the command sequence.
<COMMAND><COMMAND>data
For example, to print text with a specific font at a given position:
<F3><HW1,1><NR><RC100,50>Hello World<HW1,1>
Reading left to right:
<F3>— select font 3 (OCR-B, 17×31)<HW1,1>— set height and width scaling to 1×<NR>— no rotation<RC100,50>— position at row 100, column 50 (in dots)Hello World— the text to print<HW1,1>— back to normal size after the text (the reset for<HW>)
A complete print job is terminated with a print command. <p> prints and cuts; <q> prints without cutting, even on a printer with a cutter. The raw byte 0CH (form feed, sent without brackets) also prints and cuts, and 1DH prints without cutting. This example ends with <q>, so the ticket stays attached:
<F3><HW1,1><NR><RC100,50>Hello World<HW1,1>
<q>
Comments: FGL has no comment syntax. The # lines in this guide's examples are notes for the reader: anything outside angle brackets is printed, so strip them before you send a job.
3. Coordinate System & DPI
FGL uses a dot-based coordinate system. The <RCrow,column> command positions elements where:
- Row = Y-axis position (distance from top edge, in dots)
- Column = X-axis position (distance from left edge, in dots)
The origin <RC0,0> is the top-left corner of the ticket.
Dots vs. inches: To convert inches to dots, multiply by the printer DPI. At 300 DPI, 1 inch = 300 dots. A position of 0.5" from the top and 1" from the left becomes <RC150,300>.
Common Ticket Sizes
| Size (inches) | At 200 DPI | At 300 DPI |
|---|---|---|
| 2.0" × 5.5" | 400 × 1100 | 600 × 1650 |
| 2.125" × 5.5" | 425 × 1100 | 637 × 1650 |
| 2.5" × 5.5" | 500 × 1100 | 750 × 1650 |
| 2.7" × 5.5" | 540 × 1100 | 810 × 1650 |
These sizes are nominal: inches times DPI. Real heads are 203.2 and 304.9 DPI, and the printer keeps a small margin. The guide puts the last printable position of a 2" × 5.5" ticket at 200 DPI at row 383, column 1049. The printing length is the ticket length minus 0.142", and the measured length varies by 1–8 dots between black marks, so avoid the last three or four dot columns.
When working in landscape orientation, width and height are swapped. A 2.125" × 5.5" ticket in landscape has the longer dimension as its width (1650 dots at 300 DPI).
4. Text & Fonts
FGL provides up to 16 built-in fonts, selected with the <Fn> command. Each font has a fixed character size and sits in a fixed box, both width × height in dots. The box sets the advance between characters and between lines, and <BSw,h> changes it. Fonts are defined in dots, so the same font prints about a third smaller on a 300 DPI head than on a 200 DPI one. The table leaves out F5 (5×11 in a 7×12 box, non-rotated only, meant for special customers; since font file F46SB06L it is the same as F2) and F14–F15, which are for Miltope users only:
| Command | Name | Character (dots) | Box (dots) | Style |
|---|---|---|---|---|
<F1> | Font 1 | 5×7 | 7×8 | Basic ASCII |
<F2> | Font 2 | 8×16 | 10×18 | Basic ASCII |
<F3> | OCR-B | 17×31 | 20×33 | OCR-B standard |
<F4> | OCR-A | 5×9 | 7×11 | OCR-A standard |
<F6> | Large OCR-B | 30×52 | 34×56 | OCR-B large |
<F7> | OCR-A Full | 15×29 | 20×31 | Full OCR-A set |
<F8> | Courier | 20×40 | 20×33 | Courier |
<F9> | Small OCR-B | 13×20 | 13×22 | OCR-B compact |
<F10> | Prestige | 25×41 | 28×41 | Bold Prestige |
<F11> | Script | 25×49 | 26×49 | Script |
<F12> | Orator | 46×91 | 47×91 | Tall, bold |
<F13> | Courier Intl | 20×40 | 20×42 | Courier + international |
<F16> | Cyrillic | 18×31 | 20×33 | Cyrillic character set |
Correction (October 21, 2026): Earlier versions labelled the two size columns “Cell (200 DPI)” and “Cell (300 DPI)”. BOCA lists one pair per font: the character size and the box it sits in. Lay text out by the box: F3 advances 20 dots per character and 33 dots per line. The command reference also listed <ECM> / <ECMD> for extended characters; they do not exist, and extended characters go through the <TTn> translation table.
Font Scaling
The <HWheight,width> command scales the selected font. Values are integer multipliers:
# Double-height, normal-width text
<F3><HW2,1><NR><RC100,50>Tall Text<HW1,1>
# Triple-width, double-height
<F3><HW2,3><NR><RC200,50>Wide & Tall<HW1,1>
Always reset scaling with <HW1,1> after scaled text. The scaling stays in effect for every text that follows on the ticket until the next <HW>. Each new ticket starts at normal size again.
Correction (October 15, 2026): Earlier versions of this guide reset scaling with <WH1,1>. FGL has no <WH> command, so the printer skips it and the scaling stays in effect: the next text without its own <HW> prints magnified. Use <HW1,1>.
Full Text Command Pattern
<Fn><HWh,w><ROTATION><RCrow,col>text<HW1,1>
5. Rotation
FGL supports four rotation states in 90-degree increments:
| Command | Rotation | Description |
|---|---|---|
<NR> | 0° | No rotation (default, left to right) |
<RR> | 90° | Rotate right (top to bottom) |
<RU> | 180° | Rotate upside down (right to left) |
<RL> | 270° | Rotate left (bottom to top) |
The rotation command is placed before the position command. The <RC> coordinates always refer to the element's anchor point, which shifts depending on the rotation angle.
# Normal text
<F3><HW1,1><NR><RC100,50>Normal<HW1,1>
# Same text rotated 90 degrees clockwise
<F3><HW1,1><RR><RC100,50>Rotated<HW1,1>
Tip: When rotating elements at 180° or 270°, you may need to adjust the <RC> coordinates to account for the shifted anchor point. The top-left origin moves to the opposite corner after rotation.
6. 1D Barcodes
Correction (October 21, 2026): Earlier versions of this section and the next used commands that FGL46 does not have: <A=N>-style legacy selects, <p417>, <dm> and <az>. They also called the number after P/L a bar width, printed QR data without braces, and gave made-up PDF-417, Data Matrix and Aztec parameters. Both sections now follow the BOCA FGL46 Programming Guide (rev 16.7).
FGL supports several 1D barcode symbologies. Each has a tag letter, and most need start/stop or guard characters in the data:
| Symbology | Tag | Data format | Example data |
|---|---|---|---|
| Code 39 | N | Bracketed by * | *CODE39* |
| Code 128 | O | Bracketed by ^ | ^CODE128^ |
| EAN-13 | E | Parity digit, then J 6 digits K 6 digits L | 9J014561K780128L |
| EAN-8 | U | J 4 digits K 4 digits L | J1234K5670L |
| UPC-A | U | J 6 digits K 6 digits L | J401234K567893L |
| USS-Codabar | C | Start/stop character A–D | A123456B |
| Interleaved 2of5 | F | Even number of digits, bracketed by : | :123456: |
J, K and L are the left guard, centre and right guard. The printer calculates the check digits itself: it replaces a wrong UPC or EAN check digit, and for Code 128 it adds shift characters and switches between start codes B and C.
Barcode Command Structure
<ROTATION><RCrow,col><Xn><BI><TAGorientationsize>data
Breaking down the commands:
| Command | Purpose | Values |
|---|---|---|
<Xn> | Narrow bar width in dots; it makes the code longer, not taller | 1–9. The guide suggests at least <X2> at 200 DPI and <X3> at 300 DPI |
<BI> | Human-readable line under the code, in font 1 | Applies to the next barcode only |
| Tag letter | Symbology | Uppercase N O E U C F ignore rotation; lowercase n o e u c f follow it |
| Orientation | Bar direction | P = picket fence (the code runs along the ticket), L = ladder (the code runs across the ticket) |
| Size | Bar height in units of 8 dots | Optional; default 4 (32 dots) |
Code 39 and Interleaved 2of5 default to a 2:1 wide-to-narrow ratio. An X after the tag selects 3:1, as in <NXP5> or <FXL>. The guide reserves Y for a future 5:2 ratio.
Barcode Orientation
A picket fence code prints left to right under <NR> or right to left under <RU>. A ladder code prints top to bottom under <RR> or bottom to top under <RL>. No other rotation applies.
<NP5>— Code 39, picket fence, 40 dots tall<OL4>— Code 128, ladder, 32 dots wide
An uppercase tag is the old style, kept for older FGL printers: rotation commands do not affect it, so it prints only left to right (fence) or top to bottom (ladder). The lowercase tag, added in FGL44, follows the rotation command, so <RU> and <RL> need it. The orientation letter stays uppercase:
# Code 39, picket fence, 40 dots tall, with interpretation
<NR><RC200,50><X2><BI><NP5>*TICKET-001*
# Code 128, picket fence, 32 dots tall, with interpretation
<NR><RC300,50><X2><BI><OP4>^ABC-12345^
# Same barcode right to left: lowercase tag; it builds up and to the left of its start
<RU><RC340,600><X2><BI><oP4>^ABC-12345^
7. 2D Barcodes (QR, PDF-417, Data Matrix, Aztec)
FGL46 supports four 2D barcode symbologies. Each takes optional parameters and its data in curly braces, {data}. Keep { and } out of the data: FGL cannot escape them, except as ~123 and ~125 with Apply Tilde on. The printer always draws a 2D barcode at <HW1,1>, whatever height/width is in effect for the text around it.
QR Codes
QR codes are the most commonly used 2D barcode in FGL:
<NR><RCrow,col><QRVversion><QRsize>{data}
<QRVn> selects the symbol version, 2, 7, 11 or 15 (default 7), for the QR codes that follow it. <QRn> prints the code at point size n, 3–16 (default 6). The guide does not give the point size in dots, so measure the printed symbol before you fit it into a tight layout.
| Version | Modules | Binary | Alphanumeric | Numeric |
|---|---|---|---|---|
<QRV2> | 25 × 25 | 26 | 38 | 63 |
<QRV7> | 45 × 45 | 122 | 178 | 293 |
<QRV11> | 61 × 61 | 251 | 366 | 604 |
<QRV15> | 77 × 77 | 412 | 600 | 991 |
The capacities are the maximum characters at the default error correction level, M. The full form is <QRsize,tilde,mode,level>{data}:
- Apply tilde 0 or 1: with 1,
~dddencodes the character with decimal ASCII code ddd. - Encode mode 0 = binary (default), 1 = alphanumeric (upper-case letters only), 2 = numeric.
- Error correction 0 = M (15%, default), 1 = L (7%), 2 = H (30%), 3 = Q (25%). Note the order: 0 is M, not L.
# Version 2, point size 6, for a short URL
<NR><RC50,400><QRV2><QR6>{https://example.com}
# Version 7 (the default), point size 4
<NR><RC50,400><QRV7><QR4>{EVT-2024-ABCD-1234-WXYZ}
# Point size 8, binary, error correction H
<NR><RC50,400><QR8,0,0,2>{EVT-2024-ABCD-1234-WXYZ}
Firmware matters here. QR needs FGL46G36 or later. <QRV> with version 2 needs FGL46G76, M44 or N6; version 15 needs FGL46M132 or N94; version 11 and every correction level other than M need FGL46M138 or N100.
PDF-417
PDF-417 is a stacked 2D barcode used in transport and on ID documents. Every parameter is optional, so <PDF>{data} works:
<PDFcolumns,rows,errLevel,truncate,mode,tilde>{data}
| Parameter | Range | Meaning |
|---|---|---|
| Columns | 0–30 | Data columns; sets the width. 0 = automatic |
| Rows | 0–10 | Minimum rows. The guide recommends leaving it at 0 |
| Error level | 0–8 | Reed-Solomon level. 0 = automatic |
| Truncate | 0 or 1 | 1 removes the right-hand side: smaller, but less tolerant of damage |
| Mode | 0 or 1 | 0 = binary (default); 1 = text, only ASCII 9, 10, 13 and 32–127, but smaller |
| Apply tilde | 0 or 1 | 1 enables ~ddd character codes |
The symbol size comes from the font: <F30>–<F49> are PDF-417 fonts from 4 to 12 point, and <F30> is the default.
# 12-point PDF-417 (F44), 3 columns, 2 rows
<NR><RC150,150><F44><PDF3,2>{Ticket: EVT-2024-001234}
# Apply tilde on: ~064 encodes @, so this prints @TEXT
<NR><RC300,50><PDF10,0,0,0,0,1>{~064TEXT}
Data Matrix
Data Matrix packs data into a small square. Every parameter is optional:
<DTMtilde,encodeMode,format>{data}
- Apply tilde 0 or 1 (default 0): enables
~dddcharacter codes. - Encode mode 0 = BASE256 (default), 1 = C40, 2 = TEXT, 3 = ASCII.
- Preferred format 0–29 (default 0): the smallest symbol size. Data that does not fit gets a larger symbol.
Fonts <F50>–<F60> set the size, from 2 to 14 point (default <F50>). The 2-point size is hard to scan with anything less than a top-end scanner.
# 6-point Data Matrix (F54), all defaults
<NR><RC100,50><F54><DTM>{https://example.com/verify/12345}
# C40 encoding, which suits upper-case text
<NR><RC100,300><F54><DTM0,1,0>{COMPACT-ID-789}
Aztec
Aztec codes are used on boarding passes (IATA BCBP) and need no quiet zone, so they save space. Both parameters are optional:
<AZtilde,errorCorrection>{data}
- Apply tilde 0 or 1 (default 0): enables
~dddcodes, such as~029(GS) and~030(RS) to separate fields. - Error correction 5–95 (default 21).
There is no layer parameter. Fonts <F80>–<F93> set the size, from 4 to 24 point (default <F80>).
# 6-point Aztec (F82), all defaults
<NR><RC100,50><F82><AZ>{M1SMITH/JOHN EABC123 JFKLHRBA 0742 231Y}
# Apply tilde on, error correction 50: ~029 inserts a GS separator
<NR><RC100,300><F82><AZ1,50>{AB~029CD}
Note: 2D barcodes need new enough firmware and resident font file: PDF-417 and Data Matrix need FGL46E6 and font file SB01, QR needs FGL46G36 and SB03, Aztec needs FGL46G44 and SB04 (SB07 contains them all). Check the firmware with <S2>. The guide says a 2D barcode prints in the current rotation mode, but test rotated 2D codes on your printer before you rely on them. If rotation fails, rotate the whole ticket layout instead.
8. Lines & Boxes
FGL draws horizontal lines, vertical lines and box outlines with configurable thickness:
<NR><RCrow,col><LTthickness><HXlength> # horizontal
<NR><RCrow,col><LTthickness><VXlength> # vertical
| Command | Purpose |
|---|---|
<LTn> | Line thickness in dots (e.g., <LT1> = 1 dot, <LT3> = 3 dots) |
<HXn> | Draw horizontal line of n dots length |
<VXn> | Draw vertical line of n dots length |
Send <LT> right before the line or box it applies to: the thickness falls back to one dot after each one. A horizontal line thickens downward and a vertical line to the right. The guide recommends a new <RC> after every line or box, because the cursor position afterwards is not obvious.
# Thin horizontal separator (1px, 400 dots wide)
<NR><RC250,30><LT1><HX400>
# Thick vertical border (3px, 490 dots tall)
<NR><RC30,95><LT3><VX490>
# Box outline (four lines)
<NR><RC100,100><LT1><HX200> # top
<NR><RC300,100><LT1><HX200> # bottom
<NR><RC100,100><LT1><VX200> # left
<NR><RC100,300><LT1><VX200> # right
Lines always use <NR> (no rotation). To change the line direction, switch between <HX> and <VX>. When drawing lines at 180° or 270° angles programmatically, adjust the starting coordinates by subtracting the line length from the appropriate axis.
Box Drawing
FGL also has a box command, which draws the outline in one command instead of four lines:
<NR><RCrow,col><LTthickness><BXheight,width>
<BXr,c> (Draw Box) draws an outline r dot rows tall and c dot columns wide from the current position. An <LT> right before it sets the border, which grows toward the centre and may be at most half the shorter side:
# Box outline 200x400 with a 2-dot border
<NR><RC100,50><LT2><BX200,400>
Correction (October 21, 2026): Earlier versions drew boxes with <DBr,c> and called the result a filled rectangle. In FGL46 <DB> is the “cash draw B” command. Boxes are <BXr,c>, and they are outlines.
9. Graphics (Images)
FGL's graphics mode lets you control individual dots on the ticket. This is used for logos, icons, and any image content. The printer receives column-by-column data where each byte represents 8 vertical dots.
Graphics Commands
FGL has two graphics modes:
| Command | Mode | Data Format |
|---|---|---|
<Gn> | Binary graphics | Raw bytes (values 0–255) |
<gn> | ASCII graphics | Hex string (2 chars per byte) |
The ASCII mode (<g>) is more commonly used in software implementations because it avoids encoding issues with binary data. The n parameter in <gn> is the total number of hex characters (not byte count). Since each byte requires two hex characters, n must always be even. For example, 60 columns of dot data = 60 bytes = 120 hex chars, so you'd use <g120>.
How Dot Data Works
Each byte represents a column of 8 dots. The MSB is the top dot and the LSB is the bottom dot. A 1 bit prints a black dot; a 0 is blank.
In ASCII graphics mode, this byte is sent as the two characters A5.
Multi-Row Images
Since each graphics command covers only 8 vertical dots, taller images are split into horizontal strips. Each strip is a separate FGL command, positioned 8 dots below the previous one:
# Image: 60px wide, 24px tall = 3 strips of 8px each
# Each strip has 60 columns × 2 hex chars = 120 hex chars
<NR><RC100,50><g120>FF00FF00...hex data for row 0-7...
<NR><RC108,50><g120>AA55AA55...hex data for row 8-15...
<NR><RC116,50><g120>0F0F0F0F...hex data for row 16-23...
Image Conversion Algorithm
To convert a standard image (PNG, BMP) to FGL graphics data:
- Convert to monochrome. Each pixel becomes either black (1) or white (0). A common approach is to threshold the alpha channel: opacity > 120 = black dot.
- Split into 8-pixel strips. Divide the image height into chunks of 8 rows. If the height isn't a multiple of 8, pad the last strip with zeros.
- Scan column by column. For each strip, iterate over each column (x position). Collect the 8 vertical pixels into a single byte, with the topmost pixel as the MSB.
- Encode as hex. Convert each byte to a 2-character hex string (zero-padded). Concatenate all columns into one hex string per strip.
- Generate FGL commands. For each strip, emit
<NR><RCy,x><gn>hexdatawhere y increments by 8 for each strip.
Pseudocode:
// Convert image to FGL ASCII graphics commands
function imageToFGL(imageData, width, height, startRow, startCol) {
const strips = Math.ceil(height / 8)
const commands = []
for (let strip = 0; strip < strips; strip++) {
let hex = ""
for (let x = 0; x < width; x++) {
let byte = 0
for (let bit = 0; bit < 8; bit++) {
let y = strip * 8 + bit
if (isBlackPixel(imageData, x, y))
byte |= 1 << (7 - bit) // MSB = top dot
}
hex += byte.toString(16).padStart(2, "0")
}
const row = startRow + strip * 8
commands.push(
`<NR><RC${row},${startCol}><g${hex.length}>${hex}`
)
}
return commands.join("\n")
}
10. Inverse Printing & Visual Effects
FGL supports inverse (white-on-black) printing for visual emphasis. This is commonly used for section headers, highlight bars, and status indicators on tickets.
| Command | Description |
|---|---|
<EI> | Enable inverse mode — all subsequent text prints white on black background |
<DI> | Disable inverse mode — return to normal black on white |
# Black bar with white text header
<EI><F6><HW1,1><NR><RC40,50> VIP ACCESS <HW1,1><DI>
# Normal text below
<F3><HW1,1><NR><RC100,50>Section A - Row 5<HW1,1>
Tip: Add spaces around inverse text (e.g., VIP ACCESS ) to create padding within the black background area.
Shading Patterns
FGL42/44/46 printers can shade text with built-in patterns. <ES> shades everything that follows until <DS>:
| Command | Description |
|---|---|
<ES> | Enable shading |
<DS> | Disable shading |
<PAn> | Pattern number, 0–25 (default 14, medium fine dots) |
<PAB> | Shade the background (default) |
<PAF> | Shade the foreground, the characters themselves |
Patterns 1–6 are coarse dots and 11–16 fine dots, light to dark. 0 and 10 are white, 9 and 19 black, 20–23 vertical, horizontal and diagonal lines, 24 a square grid and 25 a diagonal grid. Background shading fills the whole character box, which <BS> can resize.
# Large text shaded with coarse dot pattern 3
<PAF><PA3><F12><ES>SHADING TEST<DS>
Overwrite Mode
By default, data printed in the same area is OR’ed together. Between <OWE> and <OWD>, new data replaces whatever lies under it, which helps with text inside an image or a 2D barcode:
<OWE>— enable overwrite: the following data erases what is under it.<OWD>— disable overwrite: back to OR.
<RC10,10><OWE>test<OWD>
Correction (October 21, 2026): Earlier versions listed <SPn>, <SPBn> and <SPFn> for shading, and <OVR> / <OVD> as other names for overwrite. FGL46 has none of them. Patterns are <PAn>, <PAB> and <PAF>, and <SPr,c> sets a logo's starting point.
11. Print Control & Status
FGL provides several commands for controlling how and when tickets are printed, cut, and counted. Most lowercase commands (all except <p>, <q>, <n> and <t>) are stored in flash and survive a power cycle: send them once at setup, never with every ticket.
Correction (October 21, 2026): Earlier versions of this section listed commands that FGL46 does not have, among them <SR>, <PROM>, <DSA>, <DIAG>, <REPn>, <PH>, <PTC>, <LVn> and <PTH1>. They also said <q> prints and cuts; <q> prints without a cut, <p> cuts. The tables below follow the BOCA FGL46 Programming Guide (rev 16.7). A printer prints an unknown command as text, so check any command you copied from the old version.
Print & Cut Commands
| Command | Description |
|---|---|
<p> | Print and cut the ticket (the normal print command) |
<q> | Print without cutting, even on a printer with a cutter |
0CH (FF) | Raw byte, sent without brackets: print and cut |
1DH | Raw byte, sent without brackets: print without cutting |
<z> | Print, cut and eject (escrow printers with an eject motor) |
<YNC> / <YC> | No-cut / cut mode, for Windows drivers. Send each on a ticket of its own: other data on that ticket is ignored |
Repeat & Hold
| Command | Description |
|---|---|
<REn> | Print n copies in addition to the first (total = n+1). May appear anywhere before the print command |
<h> | Print and cut, then hold the ticket image: text on the following tickets replaces the text at the same position |
<r> | Like <h>, but nothing is cut until a normal print command |
The hold commands <h> and <r> speed up runs where only a few fields change (name, seat, barcode): send the full ticket once, then only the changed fields, each ticket ending with <h>; end the last one with <p> or clear with <CB>. Replace the same font and size only: the image is replaced in 8-dot bands, so keep other text at least 8 dots below a replaced field. Not supported with soft fonts, nor on Mag and Dual printers.
Ticket Counting
| Command | Description |
|---|---|
<PC> | Print the 7-digit user ticket count at the current position (at most two per ticket, e.g. main ticket and stub) |
<TCnnnnnnn> | Load the user ticket count for this ticket; all 7 digits required (<TC0000005>). It resets to 0 at power off |
<rtcn> | Reset the resettable count of path n (printed on the test ticket as RTC; the permanent count, PTC, cannot be reset) |
Buffer & State
| Command | Description |
|---|---|
<CB> | Clear the ticket buffer and restore the default fonts. The printer clears itself after each ticket, and the guide advises against <CB> in production because it slows printing |
<me> / <md> | Multiple ticket mode on (default) / off. Off removes the small gap the cutter cycle leaves about one inch from the edge, at about 0.5 s per ticket (flash) |
<mb> | Multiple buffer mode (default, flash) |
<sb1> / <sb2> | Single buffer mode for FGL2-era software: busy after each print command (<sb2>: also when the buffer is full). Not recommended (flash) |
<PP> | Purge mode until power off: on paper out, discard unprinted tickets instead of finishing them after reload |
Status & Diagnostics
Status commands let your application query the printer state for error handling and monitoring. They need status enabled on the interface you use (control panel STATUS ENABLED?). In the factory default solicited mode <s91> the printer sends on its own only power on (12H), ticket printed (ACK 06H), low paper (0FH) and X-ON/X-OFF; everything else answers a request. In an error state it answers only <S92> and deletes all other data, so send <S92> before each job and wait for 41H. Do not poll constantly: the guide warns that excessive status requests produce misleading answers.
| Command | Description |
|---|---|
<S92> | Solicited status request: 41H = good, otherwise a code from the status table (10H out of paper, 18H paper jam, 0FH low paper, …) |
<S1> | One-byte status. In <s91> mode it does not answer in an error state; use <S92> |
<S2> | Ticket count and firmware as text: 0004616 PROM = FGL46R10 |
<S7> | Free download (logo/font) memory as 8 hex digits: 00019000 = 100K |
<DM> | Diagnostic mode until power off: the printer prints every byte it receives as a character instead of processing it |
<ME> / <MD> | CRT messages on / off (default off): also send an ASCII message such as OUT OF TICKETS to the CRT port |
No command reports the print head resolution. It is the factory setting HEAD DPI? (200, 300 or 600), printed on the configuration test ticket. Never send <dpi200>, <dpi300> or <dpi600>: the guide warns that a wrong setting damages the print head.
Networked Printers: Error Handling
Over Ethernet the printer takes raw TCP on ports 9100, 9101 and 9102, and the connection is bidirectional: status replies come back on the same socket. In the default <s91> mode the printer sends only three messages unprompted: ticket printed (ACK, 06H), low paper (0FH) and power on (12H), plus X-ON / X-OFF (11H / 13H) when its buffer empties or fills. Everything else you have to ask for with <S92>:
| Code | Meaning |
|---|---|
| 41H | Good status |
| 10H | Out of paper |
| 0FH | Low paper |
| 18H | Paper jam |
| 1DH | Cutter jam |
| 19H / 15H | Illegal data / NAK (illegal print command) |
| 14H | Bad flash memory |
| 1AH | Power-up problem |
| 1CH | Download error (bad font, logo or file operation) |
| 13H | X-OFF: busy, the reply comes later |
Warning: in a fault state the printer answers only <S92> and deletes everything else it receives. A ticket sent to a printer that is out of paper is lost, and no error comes back. Check the status before you send.
A safe sequence for each ticket:
- Send
<S92>. Go on only on 41H, or on 0FH with a low-paper warning to the operator. - Send the ticket and wait for ACK (06H).
- If no ACK arrives within a few seconds, send
<S92>again to learn why: 10H, 18H, 1DH and so on.
Do not poll. BOCA warns that excessive status requests give misleading answers, and recommends asking only at startup, right before printing and shortly after. A reply can take a few seconds while a ticket is printing. Printers with a presenter can use the single-ticket mode <s90>, which also reports ticket waiting (17H) and ticket taken (16H).
Two more channels exist, though not on every printer. SNMP, on firmware FGL46N68 / M106 and later, reports LowPaper, NoPaper, Cutter or Paper Jammed in hrPrinterDetectedErrorState and hrDeviceStatus, and can send SNMPv1 traps to an address set on the printer's SNMP web page. The printer can also send e-mail alerts.
Networked Printers: Finding the DPI
Nothing on the network reports the head resolution:
| Channel | Returns | DPI |
|---|---|---|
Raw TCP, <S2> | Ticket count and firmware: 0004616 PROM = FGL46R10 | No |
Raw TCP, <S1> / <S92> | One status byte | No |
| SNMP (FGL46N68 / M106 and later) | sysDescr BOCA SYSTEMS PRINTER, device and printer status. No Printer-MIB | No |
| Web server, port 80 | Configure Printer and Realtime Status pages. BOCA says the Realtime format is “subject to change” | Unconfirmed |
The DPI is printed on the configuration test ticket. Over USB the IEEE 1284 Device ID may carry it: a 300 DPI unit we tested reported MDL:46 300. In an application, store the DPI in the printer's profile when you register it. Prefill it from the USB model string where you can, otherwise ask the operator, and confirm with a calibration ticket: a frame laid out for 300 DPI fills the ticket on a 300 DPI head and prints 1.5 times larger, past the edge, on a 200 DPI head.
Print Intensity
The <pin> command sets the print intensity: 1 light, 2 medium light, 3 normal, 4 medium dark, 5 short head life. It is a flash setting meant for experienced users; higher values shorten the head's life. Print speed <psn> (0–7, 7 slowest) also affects darkness: slower prints darker. For fine tuning, <lven> changes how long the head voltage stays on, from -5 to +5 (default 0, 10% per step; on a dual printer, for the active path). It is not meant to compensate for poor stock, and large values greatly shorten head life.
Dual Path / Multi-Printer
BOCA printers with dual paths can target specific print paths:
<P1>/<P2>— print on ticket path 1 / 2 (uppercase:<p>is the print command)<pb><pb1>— dual printer mode<pb2>— dual supply mode
12. Logo Storage & Recall
FGL printers can store logos in flash memory for fast recall, avoiding the need to transmit image data with every ticket.
Logo Commands
| Command | Description |
|---|---|
<SPr,c> | Set starting point (position) for the next logo |
<LOn> | Print factory-resident logo n (after <SPr,c>) |
<LDn> | Print downloaded (custom) logo n (after <SPr,c>) |
Correction (October 21, 2026): Earlier versions of this section recalled logos with <RLn> and <PLn> and assigned IDs with <FIn>. In FGL46 <PL#> sets the printing length, <RL> rotates left, and <FI> does not exist. Logos are printed with <LOn> (resident) and <LDn> (downloaded), IDs are set with <IDn>, and <DFn> takes a delete code, not a file ID: <DF1> deletes every downloaded file.
Downloading Logos
Custom logos are uploaded to the printer's flash memory using file operations:
| Command | Description |
|---|---|
<IDn> | Assign ID n to the next downloaded logo or soft font (logos up to 511); otherwise IDs are assigned in sequence: <LD1>, <LD2>, … |
<PF> | Permanent file mode: store in flash, kept across power cycles (not on FGL26) |
<TF> | Temporary file mode: store in RAM, lost at power off |
<pf> / <tf> | Change the default storage mode (permanent is the default) |
<DFn> | Delete by code n: 1 all files (= ESC c), 2 all temporary, 5 all logos, 6 temporary logos, 8 one logo (after <IDn>), 9 reclaim flash space |
ESC c | Clear entire download area and reset pointers |
PCX & BMP Image Files
On FGL42/44/46 printers, you can send standard image files directly instead of converting to dot data:
# Send a PCX image file (FGL42/44/46)
<SP100,50><pcx><G3500>...3500 bytes of PCX data...
# Send a BMP image file (FGL26/46)
<SP100,50><bmp><G4200>...4200 bytes of BMP data...
The <SPr,c> positions the image, and <Gn> specifies the exact byte count of the file data that follows. There must be no extra characters between the command and the file bytes.
Stored logos vs. inline graphics: For logos that appear on every ticket, download once to flash and recall with <SPr,c><LDn>. This is significantly faster than sending the image data with each ticket. Use inline <g> graphics only for dynamic or one-off images.
13. Building an FGL Generator (Lessons Learned)
If you're building software that generates FGL programmatically (a layout editor, print server, or ticket system), the following patterns come from real production experience. These are the problems the official documentation doesn't warn you about.
The Rotation Origin Problem
This is the single most confusing aspect of FGL programming. When you rotate an element, its origin point shifts to a different corner. The <RC> command always refers to the origin point, and if you don't account for the shift, your elements will "jump" to unexpected positions after rotation.
The origin corner for each rotation angle:
When the <RC> command places an element, it uses the origin corner appropriate for the rotation angle. So when generating FGL, you must compute the correct anchor point based on the current rotation.
Angle Normalization
User interactions (drag-rotate in an editor, API input) can produce arbitrary angles: negative values, values over 360, or decimals like 89.7°. FGL only supports 0/90/180/270. Always normalize:
function normalizeAngle(angle) {
return (Math.round(angle) + 360) % 360
}
// -90 → 270
// 450 → 90
// 89.7 → 90
Center-Point Rotation Technique
If your editor allows visual drag-rotation, rotating around the corner origin causes elements to "jump". The solution is to rotate around the element's center, then recalculate the top-left position for FGL output:
function rotateElement(el, newAngle) {
// 1. Find the center of the element
const cx = el.x + el.width / 2
const cy = el.y + el.height / 2
// 2. Compute the new top-left after rotation around center
const origin = getOriginCorner(newAngle)
const hw = el.width / 2, hh = el.height / 2
const dx = origin.x === "left" ? -hw : hw
const dy = origin.y === "top" ? -hh : hh
el.x = Math.round(cx + dx)
el.y = Math.round(cy + dy)
el.angle = newAngle
}
function getOriginCorner(angle) {
const map = {
0: { x: "left", y: "top" },
90: { x: "left", y: "bottom" },
180: { x: "right", y: "bottom" },
270: { x: "right", y: "top" },
}
return map[angle]
}
This ensures the element stays visually anchored at its center during rotation, then the coordinates are recalculated for FGL output.
Coordinate Rounding — Always Round to Integers
FGL coordinates are integers (dot positions). Fractional values cause unpredictable behavior. After any calculation, round and clamp:
function sanitizeCoords(props) {
return {
top: Math.max(0, Math.round(props.top)),
left: Math.max(0, Math.round(props.left)),
strokeWidth: Math.round(props.strokeWidth),
length: Math.round(props.length),
}
}
Negative coordinates are silently accepted by some printers but produce no output. Always clamp to 0 minimum. If an element partially extends off-ticket, the printer will clip — but negative RC values may cause firmware-specific behavior.
The Landscape Lock
Most BOCA printers expect FGL data in landscape orientation regardless of how the ticket physically feeds through the printer. In landscape mode, width and height are swapped:
function toTicketDots(widthInch, heightInch, dpi, landscape) {
// In landscape, swap so the longer edge is always width
if (landscape) {
return { w: Math.round(heightInch * dpi), h: Math.round(widthInch * dpi) }
}
return { w: Math.round(widthInch * dpi), h: Math.round(heightInch * dpi) }
}
// 2.125" x 5.5" ticket at 300 DPI, landscape:
// w = 5.5 * 300 = 1650 dots
// h = 2.125 * 300 = 637 dots
If your system allows portrait editing, you must convert to landscape coordinates before generating FGL:
function buildFGL(elements, ticket) {
// Ensure landscape coordinates for FGL
const size = toTicketDots(ticket.width, ticket.height, ticket.dpi, true)
const commands = elements.map(el => {
const coords = toLandscapeCoords(el, size)
return elementToFGL(el.type, coords, el.props)
})
return commands.join("\n") + "\n<q>"
}
Line Coordinate Adjustment for Rotation
Lines in FGL are always drawn with <NR> (no rotation tag). Instead of rotating the line, you switch between <HX> (horizontal) and <VX> (vertical). But at 180° and 270°, the starting coordinate must be adjusted by subtracting the line length:
function lineFGL(x, y, angle, thickness, length) {
const dir = (angle === 0 || angle === 180) ? "HX" : "VX"
// Shift start point for 180/270 so the line extends correctly
if (angle === 180) x -= length
if (angle === 270) y -= length
return `<NR><RC${y},${x}><LT${thickness}><${dir}${length}>`
}
Without this adjustment, 180° and 270° lines will start at the wrong end and extend off-ticket.
Image Rotation Without FGL Rotation
FGL graphics mode (<g>) does not support rotation commands. To print a rotated image, you must pre-rotate the source image on the canvas/server side before converting to dot data:
function rotateImage(img, angle) {
const c = document.createElement("canvas")
const ctx = c.getContext("2d")
const swap = angle === 90 || angle === 270
c.width = swap ? img.height : img.width
c.height = swap ? img.width : img.height
ctx.translate(c.width / 2, c.height / 2)
ctx.rotate(angle * Math.PI / 180)
ctx.drawImage(img, -img.width / 2, -img.height / 2)
return ctx.getImageData(0, 0, c.width, c.height)
}
Then feed the rotated pixel data into the 1-bit compression algorithm from Section 9.
Schema Serialization — Save/Load Designs
If you're building an editor, you'll need a serialization format to save and reload layouts. A practical JSON schema:
{
"version": 1,
"ticket": {
"width": 2.125, "height": 5.5,
"dpi": 300,
"landscape": true
},
"elements": [
{
"type": "text",
"x": 50, "y": 100, "angle": 0,
"font": 3, "scaleH": 1, "scaleW": 1,
"content": "Hello World",
"bind": null
},
{
"type": "barcode",
"x": 50, "y": 200, "angle": 0,
"symbology": "code128",
"expand": 2, "barWidth": 5,
"interpretation": true
}
]
}
Key practices:
- Version field — always validate before loading. Prevents loading incompatible files from older/newer formats.
- Ticket metadata is essential — without DPI and orientation, coordinates are meaningless. Always store them alongside elements.
- Keep elements minimal — only persist properties that define the layout, not runtime state or computed values.
- Use
bindfor dynamic fields — elements with abindkey get their content replaced at print time (see Dynamic Data Fields below).
Dynamic Data Fields (Placeholders)
In production, most tickets have a mix of static layout (logos, borders, labels) and dynamic data (name, seat, barcode). Use a bind field to mark elements whose content is replaced at print time:
const ROTATIONS = { 0: "NR", 90: "RR", 180: "RU", 270: "RL" }
function textToFGL(el, data) {
// Use bound data if available, otherwise static content
const text = el.bind && data[el.bind] ? data[el.bind] : el.content
const rot = ROTATIONS[el.angle]
return `<F${el.font}><HW${el.scaleH},${el.scaleW}>`
+ `<${rot}><RC${el.y},${el.x}>${text}<HW1,1>`
}
// Usage: fill in dynamic fields at print time
const fgl = textToFGL(
{ font: 3, scaleH: 1, scaleW: 1, angle: 0, x: 50, y: 100, bind: "guest_name" },
{ guest_name: "John Smith", seat: "A-12" }
)
The editor stores placeholder values like "Guest Name" in content, while the bind key maps to a data field. At print time, your server supplies real values through the data object.
Parallel FGL Generation
Image-to-FGL conversion can be slow (canvas rendering, pixel scanning). Since element order doesn't matter in FGL — only coordinates determine placement — you can generate all elements in parallel:
// Slow: each image blocks the next
let fgl = ""
for (const el of elements) {
fgl += await toFGL(el, data)
}
// Fast: all conversions run concurrently
const parts = await Promise.all(elements.map(el => toFGL(el, data)))
const fgl = parts.join("\n") + "\n<q>"
This is safe because each element produces an independent FGL command — there is no shared state between them.
14. Composing a Full Layout
A complete FGL layout is simply a concatenation of individual element commands, terminated by a print command: <p> to cut, or <q> to leave the ticket uncut, as here. Each element occupies one or more lines, and the printer processes them sequentially.
Example: Event Ticket
# ── Text elements ──
<F12><HW1,1><NR><RC40,50>SUMMER FEST 2024<HW1,1>
<F3><HW1,1><NR><RC140,50>Main Stage - Section A<HW1,1>
<F9><HW1,1><NR><RC180,50>June 15, 2024 - 7:00 PM<HW1,1>
<F9><HW1,1><NR><RC210,50>Gate: North Row: 12 Seat: 34<HW1,1>
# ── Separator line ──
<NR><RC250,40><LT1><HX560>
# ── Barcode ──
<NR><RC280,50><X2><BI><OP4>^EVT-2024-001234^
# ── QR code (right side) ──
<NR><RC270,480><QRV7><QR4>{https://verify.example.com/EVT-2024-001234}
# ── Rotated side text ──
<F1><HW1,1><RR><RC30,620>ADMIT ONE<HW1,1>
# ── End of ticket ──
<q>
Key points:
- Each element is independent — order doesn't affect rendering, only the
<RC>coordinates determine placement. - The
<q>at the end prints the ticket without cutting it. End with<p>to print and cut. - Multiple elements can overlap if their coordinates intersect (overlapping dots are OR’ed together; wrap the top element in
<OWE>…<OWD>to replace what lies under it). - All coordinates must be within the physical ticket dimensions. Content outside the print area is clipped.
15. Practical Tips
DPI Awareness
Always know your printer's DPI before calculating coordinates. A layout designed for 300 DPI prints 1.5 times larger on a 200 DPI printer and runs off the ticket; a 200 DPI layout prints at two thirds of its size on a 300 DPI printer. Keep coordinates as DPI-relative calculations:
// Calculate position from inches
const DPI = 300
const row = Math.round(0.5 * DPI) // 150 dots = 0.5 inch from top
const col = Math.round(1.0 * DPI) // 300 dots = 1.0 inch from left
Orientation Locking
Many FGL printers expect ticket data in landscape orientation regardless of how the physical ticket is oriented in the printer. If your printer uses landscape-first coordinate mapping, ensure all coordinates are calculated with the longer dimension as width. Swap your width/height values accordingly before generating FGL.
Placeholder Patterns
When building dynamic systems where data is injected at print time, use placeholder tokens in your FGL templates:
<F3><HW1,1><NR><RC100,50>{{event_name}}<HW1,1>
<NR><RC280,50><X2><BI><OP4>^{{ticket_code}}^
<NR><RC280,480><QRV7><QR4>{{{validation_url}}}
<q>
Your print server replaces the {{...}} tokens with actual data before sending the FGL stream to the printer.
High-Speed Printing
For high-throughput scenarios (event gates, transit turnstiles), minimize per-ticket data transfer:
- Use stored logos — download once, recall with
<LDn>on every ticket - Use hold mode — ending a ticket with
<h>keeps its image in the buffer; send only the changed fields for each following ticket - Minimize graphics — ASCII graphics (
<g>) transmit 2x the data of binary (<G>). Use binary mode if your transport supports 8-bit data - Use
<REn>for identical copies instead of re-sending the ticket
Common Pitfalls
- Forgetting the print command — Without
<p>or<q>(or the bytes 0CH / 1DH) at the end, the printer holds the data and never prints. - Binary vs. ASCII graphics — If your system can't send raw bytes, always use the lowercase
<g>command for ASCII hex encoding. The byte count in<gn>must be even. - Font bleeding — Always reset with
<HW1,1>after scaled text, or the next text element on the ticket inherits the scaling.<WH1,1>does not reset it: FGL has no such command. - Coordinate overflow — Verify that all positions plus element dimensions fit within the ticket's dot area. Out-of-bounds content is silently clipped.
- Inverse mode leaking — Always pair
<EI>with<DI>. If you forget to disable inverse mode, all subsequent text will be white-on-black. - Barcode rotation tags — An uppercase barcode tag ignores rotation commands. Use the lowercase tag (
o,n, …) for codes printed right to left (<RU>) or bottom to top (<RL>). - Status polling — Send
<S92>before a job and print only on 41H: in an error state the printer silently deletes everything else. Common answers: 10H out of paper, 18H paper jam, 1DH cutter jam. - Logo vs. inline graphics — Download frequently-used logos to flash memory once and recall with
<LDn>. Sending inline graphics with every ticket wastes bandwidth and slows throughput. - Buffer overflow — Complex tickets with large images may exceed the buffer. Use
<S7>to check free download memory. Consider splitting image data or reducing resolution.
Debugging Workflow
- Start with
<DM>(diagnostic mode) to see exactly which bytes reach the printer; press the test button if the data does not fill a ticket. Power-cycle to leave the mode. - Test positioning with simple text at known coordinates before adding complex elements.
- Use
<S2>to verify firmware version — some commands require specific FGL versions (e.g., 2D barcodes need FGL46). - Send
<CB>between test jobs to clear the buffer and reset state. - Verify barcode data integrity: scan printed barcodes and compare with the input data.
Ticket Length Configuration
If your ticket stock differs from the factory default, configure the printing length:
<PLn>— printing length in dot columns until power off (cannot exceed the measured ticket length)<pln>— store the printing length in flash; this turns off ticket measuring at power on<tln>— store the ticket length in flash, for labels whose gap makes the ticket longer than the print (send before<pln>)<dpl>— delete both stored lengths and measure the ticket again at power on
Command Reference
Text & Positioning
| Command | Description |
|---|---|
<Fn> | Select font (n = 1–13, 16) |
<HWh,w> | Set font height/width scaling |
<HW1,1> | Back to normal size: the reset for <HWh,w> (FGL has no <WH> command) |
<BSw,h> | Modify character box size (width, height) |
<SDn> | Divide the font size by n; after <HW> it gives fractions (<HW2,2><SD3> = 2/3) |
<RCr,c> | Position at row, column (in dots) |
<NR> | No rotation (0°) |
<RR> | Rotate right (90°) |
<RU> | Rotate upside down (180°) |
<RL> | Rotate left (270°) |
<EI> | Enable inverse printing (white on black) |
<DI> | Disable inverse printing |
<TTn> | Translation table for extended characters (e.g. 1 = code page 1252 to 437) |
<TTCPn> | Code page for TrueType fonts |
Barcodes
| Command | Description |
|---|---|
<Xn> | Barcode expansion factor (1–9) |
<NXPn> | 3:1 bar ratio: X after the tag (Code 39, I2of5 only) |
<BI> | Barcode interpretation (human-readable text) |
<QRVn> | QR version: 2, 7, 11 or 15 (default 7) |
<QRn>{data} | QR code, point size 3–16 (default 6) |
<PDF>{data} | PDF-417 (optional: columns, rows, level, truncate, mode, tilde) |
<DTM>{data} | Data Matrix (optional: tilde, encode mode, format) |
<AZ>{data} | Aztec (optional: tilde, error correction) |
Lines, Boxes & Graphics
| Command | Description |
|---|---|
<LTn> | Line thickness in dots |
<HXn> | Horizontal line of n dots |
<VXn> | Vertical line of n dots |
<BXr,c> | Draw box outline r dots tall, c dots wide |
<Gn> | Binary graphics mode (n bytes) |
<gn> | ASCII graphics mode (n hex chars) |
Logo & File Operations
| Command | Description |
|---|---|
<SPr,c> | Set starting point for logo (row, col) |
<LOn> | Print resident (factory) logo n |
<LDn> | Print downloaded logo n |
<IDn> | Assign ID to the next download |
<PF> | Permanent file mode |
<TF> | Temporary file mode |
<DFn> | Delete files by code (<DF1> = all) |
Print Control
| Command | Description |
|---|---|
<p> | Print and cut |
<q> | Print, no cut |
0CH | Raw byte: print and cut |
<REn> | Print n additional copies |
<h> | Print and hold image for field replacement |
<CB> | Clear buffer and reset fonts |
<pin> | Print intensity (1–5, flash) |
<PC> | Print ticket count on ticket |
<S92> | Request printer status (41H = good) |
<S2> | Request ticket count and firmware |
<S7> | Report free download memory |
<DM> | Enter diagnostic mode |
Further Reading
- BOCA FGL Ticket Editor — free in-browser ticket designer that generates FGL as you lay out the ticket
- BOCA Systems FGL46 Programming Guide (PDF) — Official reference for the latest FGL command set
- BOCA Systems, Inc. — Manufacturer of FGL-compatible thermal printers