Home / Alt manpages / ppmdmkfont(1)

  • ppmdmkfont(1)
  • User command
  • linux

Create and Verify a Standard Ppmdfont with ppmdmkfont

ppmdmkfont is the oddest generator in Netpbm: no input, no flags, and it builds the exact same font every single run. Run it once and you have made everything it is capable of making. This guide gets that standard font onto disk safely, proves it is genuine, and reads it back with the companion dumper.

Allow about ten minutes. You need a shell, the netpbm package and a writable working directory. The command needs no elevated privileges, and nothing here replaces an existing font, installs anything, or touches a system font directory.

1. Confirm the installed command

Check the executable and the package version before you build anything. Both commands are read-only:

$ command -v ppmdmkfont
/usr/bin/ppmdmkfont
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1
  • Confirm the path first. If command -v prints nothing, install Netpbm through your normal package-management process rather than running an unknown copy from the current directory.
  • Note the package version. The exact number will vary between distributions; what matters is that the command resolves to the Netpbm build you meant to run.

Checkpoint

You have an executable path and a package version. Everything from here only writes to the output path you choose.

2. Choose a new output path

ppmdmkfont has no option for an output filename. The generated Ppmdfont data goes to standard output, so shell redirection supplies the destination:

$ mkdir -p "$HOME/netpbm-font-work"
$ output="$HOME/netpbm-font-work/standard.pmdfont"
$ printf '%s\n' "$output"
/home/you/netpbm-font-work/standard.pmdfont

Replace the example directory with one you own. mkdir -p is safe to rerun, but it will not grant access to a protected location: a system directory such as /usr/local/share may need elevated privileges for the final copy later, not for generating the font. Stay in a user-owned staging directory while testing.

Warning

Do not redirect straight to a path that already holds a useful font. The shell truncates the destination before the program runs, so a failed command can destroy the previous file. Use a new name or the temporary-file pattern in the next step.

3. Generate the font without risking the destination

Write to a temporary file in the same directory, then move it into place only once the command has actually succeeded:

$ temporary="$output.tmp"
$ ppmdmkfont > "$temporary" && mv -- "$temporary" "$output"
$ printf 'exit status: %s\n' "$?"
exit status: 0

There is no input file and no progress output to watch, so exit status is the only signal here. A status of zero means the generator and the mv both completed. Because temporary and output live in the same directory, the rename is a clean hand-off on normal local filesystems, and the old destination, if any, survives right up until the new file is actually ready.

If the generator fails, && stops mv from running at all. Confirm the temporary path before you touch anything:

$ ls -l -- "$temporary" "$output" 2>/dev/null || true

If you used a fresh output path, recovery is simple: leave the old file alone and pick a different temporary name. If you deliberately replaced an existing file, restore it from your own backup. ppmdmkfont has no undo of its own, since it only generates output; the redirection and the move are what decide what gets replaced.

4. Confirm the output was actually created

These checks only look at the file. None of them need root or interpret the font itself:

$ test -s "$output" && echo 'font file is non-empty'
font file is non-empty
$ wc -c -- "$output"
3899 /home/you/netpbm-font-work/standard.pmdfont
$ file -- "$output"
/home/you/netpbm-font-work/standard.pmdfont: data

Treat the byte count as an observation from this build, not a portable contract: a different Netpbm release could produce a different size. file may report only data, because Ppmdfont is a Netpbm-specific binary format, not a common image type. Do not expect a PPM header, readable text or an embedded filename.

For a quick repeatability check, generate a second file and compare the two:

$ second="$output.second"
$ ppmdmkfont > "$second"
$ cmp -- "$output" "$second"
$ printf 'identical output: %s\n' "$?"
identical output: 0

Example

cmp prints nothing and returns zero when two files match exactly. If it reports a difference here, stop and check the executable, the filesystem and the exact commands you ran, rather than trusting a single run.

5. Inspect the font with the companion dumper

Netpbm's ppmddumpfont reads a Ppmdfont file from standard input and writes a human-readable description to standard error. It has no documented arguments either, so feed it through a pipe or a redirect:

$ ppmdmkfont | ppmddumpfont
... human-readable font description ...
$ ppmddumpfont < "$output"
... human-readable font description ...

The exact wording and layout of that description are implementation output, not a stable format to parse in a script. What matters is that the companion program consumes the stream without complaining about a header or format error. Because the report goes to standard error, capture it deliberately if you want to keep it:

$ ppmddumpfont < "$output" 2> "$output.dump"
$ test -s "$output.dump" && echo 'font description captured'
font description captured

6. Use the result for what it actually is

The manual notes that this standard font is already built into libnetpbm, so generating this file is mainly useful as a worked example, or as a concrete Ppmdfont input for other font-related tools. It does not install the font, alter libnetpbm, or make anything the system default.

  • Do not stash it in a shared system directory just to make it exist there. If another program needs a path, point it at the staged file, or copy it into that program's documented data directory as a deliberate, planned change.
  • Expect sudo only for the copy, not the generation. A copy into a protected directory may need it; check the destination and ownership first, and keep the original until the consumer has actually been tested.

Review exactly what you are about to delete before clearing up the test artefacts:

$ printf '%s\n' "$output" "$second" "$output.dump"
/home/you/netpbm-font-work/standard.pmdfont
/home/you/netpbm-font-work/standard.pmdfont.second
/home/you/netpbm-font-work/standard.pmdfont.dump

Delete only files you recognise. The generated font can always be recreated; anything else with the same name cannot be brought back by ppmdmkfont.

Done means

  • Confirmed the path. ppmdmkfont resolves to the intended Netpbm installation, and its version is recorded.
  • Generated safely. A non-empty Ppmdfont file exists at a path you control, written through a temporary file so a failed run could not truncate an existing one.
  • Checked repeatability. A second generation compared byte-identical to the first on this build.
  • Verified with the dumper. ppmddumpfont read the data back without a format complaint.
  • Left the system alone. No system directory, package or persistent Netpbm configuration was changed.