BDFMANGLE(1)

NAME
bdfmangle - transform a bdf font file into another bdf font file

SYNOPSIS
bdfmangle BDFFILE MGLFILE...

DESCRIPTION
Bdfmangle is a tool to select, rename, or reorder glyphs in a bdf font file. It reads a font file (or a concatenation of bdf font files via cat BDFFILE1 BDFFILE2 ... | bdfmangle - MGLFILE ...), manipulates the preamble and the glyphs of the font file as specified in MGLFILEs and prints the result to standard output.

MGL COMMAND SYNOPSIS
When bdfmangle reads the font(s), it stores the first preamble that it encounters (discarding any further preambles) and the glyphs (bitmaps) of the font(s). Every glyph is stored independently under its name (the string following the STARTCHAR keyword) and under its encoding (the number following the ENCODING keyword). Formally, a glyph

    STARTCHAR glyphname
    ENCODING number
    glyphdata
    ENDCHAR

is turned into

    names[glyphname] := glyphdata;
    numbers[number] := glyphdata;

If several glyphs have the same name or the same encoding, the last one overwrites the earlier ones. The preamble and glyphs are then processed according to the commands in the mgl file(s). Commands are separated by newlines. In contrast to bdf files, numbers in mgl files can be specified either decimally, or octally (with a 0 prefix) or hexadecimally (with a 0x prefix).

  Preamble commands

FONT fontnamesuffix
    Replaces the trailing part of the font name in the preamble by fontnamesuffix. The length of the the replaced part is determined by the number of hyphens in fontnamesuffix (the total number of hyphens is left unchanged).

DEFAULT_CHAR number
    Replaces the DEFAULT_CHAR declaration in the preamble.

CHARSET_REGISTRY string
    Replaces the CHARSET_REGISTRY declaration in the preamble.

CHARSET_ENCODING string
    Replaces the CHARSET_ENCODING declaration in the preamble.

  Output commands

PUT glyphname [number]
    Prints the glyph stored at glyphname with its old name and the encoding number. If no number is specified, the encoding of the last glyph printed is incremented by 1.

PUTAS glyphname newglyphname [number]
    Prints the glyph stored at glyphname with the new name newglyphname and the encoding number. If no number is specified, the encoding of the last glyph printed is incremented by 1.

PUTENC oldencoding [number]
    Prints the glyph stored at oldencoding with its old name and the encoding number. If no number is specified, the encoding of the last glyph printed is incremented by 1.

PUTENCAS oldencoding newglyphname [number]
    Prints the glyph stored at oldencoding with the new name newglyphname and the encoding number. If no number is specified, the encoding of the last glyph printed is incremented by 1.

  Copy commands

COPYTO glyphname newglyphname
    Copies the glyph stored at glyphname to newglyphname, i.e., names[newglyphname] := names[glyphname]; The glyph is afterwards accessible both under its old and its new name. If some other glyph was previously stored at newglyphname, it is no longer accessible by its name (but it may still be accessible by its encoding).

COPYTOENC glyphname newnumber
    Copies the glyph stored at glyphname to the encoding newnumber, i.e., numbers[newnumber] := names[glyphname]; The glyph is afterwards accessible both under its old name and its new encoding. If some other glyph was previously stored at the encoding newnumber, it is no longer accessible by its encoding (but it may still be accessible by its name).

COPYENCTO number newglyphname
    Copies the glyph stored at the encoding number to newglyphname, i.e., names[newglyphname] := numbers[number]; The glyph is afterwards accessible both under the encoding number and its new name. If some other glyph was previously stored at newglyphname, it is no longer accessible by its name (but it may still be accessible by its encoding).

COPYENCTOENC number newnumber
    Copies the glyph stored at the encoding number to the encoding newnumber, i.e., numbers[newnumber] := numbers[number]; The glyph is afterwards accessible both under its old and its new encoding. If some other glyph was previously stored at the encoding newnumber, it is no longer accessible by its encoding (but it may still be accessible by its name).

  Error handling commands

NODEFAULT
    Specifies that bdfmangle is aborted if unassigned glyph names or encodings are referenced.

DEFAULT glyphname
    Specifies that the glyph with the name glyphname is taken as a replacement whenever an unassigned glyph name or encoding is referenced.

DEFAULTENC number
    Specifies that the glyph with the the encoding number is taken as a replacement whenever an unassigned glyph name or encoding is referenced.

DEFAULTOMIT
    Specifies that print commands using unassigned glyph names or encodings are ignored.

  Other commands

INCLUDE filename
    Includes the mgl file filename.

IFDEF glyphname cmd
    If there is a glyph stored at glyphname, executes the mgl command cmd; otherwise does nothing.

IFUNDEF glyphname cmd
    If there is no glyph stored at glyphname, executes the mgl command cmd; otherwise does nothing.

IFDEFENC number cmd
    If there is a glyph stored at the encoding number, executes the mgl command cmd; otherwise does nothing.

IFUNDEFENC number cmd
    If there is no glyph stored at the encoding number, executes the mgl command cmd; otherwise does nothing.

IFFONT string cmd
    If the FONT declaration in the preamble contains string as a substring, executes the mgl command cmd; otherwise does nothing.

IFNOTFONT string cmd
    If the FONT declaration in the preamble does not contain string as a substring, executes the mgl command cmd; otherwise does nothing.

COMMENT arbitrary-text
    Adds the COMMENT to the output bdf file.

# arbitrary-text
    Does nothing. This is for comments that should not be copied to the output.

LIMITATIONS
Glyph names may not contain whitespace.

There is a limit on the number of nested inclusion commands.

If the input of bdfmangle is a concatenation of bdf font files, the second and all further preambles are discarded, even if it contains copyright or licensing information that has to be kept intact. It may be necessary to restore such data manually.

COPYRIGHT
Copyright © 2012-2015 Uwe Waldmann.

Bdfmangle may be freely used, copied, or modified under the terms of the MIT license.