HBF2GF(1)
πΈ NAME πΈ
hbf2gf β the little icon that converts a CJK bitmap font into subfonts that TeX and Omega can actually use π (yes bestie, this is the HBF2GF(1) page from the General Commands Manual, and we're doing this together π«Ά)
β¨ SYNOPSIS β¨
hbf2gf [-q] configuration-file[.cfg]
hbf2gf [-q] [-p] [-g] [-n] subfont-name x-resolution
[y-scale | y-resolution]
hbf2gf -t [-q] subfont-name
hbf2gf --version | --help
π DESCRIPTION π
okay so here's the tea: CJK bitmap fonts literally cannot be used with TeX directly, because these fonts have way more than 256 characters in them, and 256 is the absolute limit of a TeX font. so sad. π the fix? you split those fonts into subfonts, and that is exactly what hbf2gf does. main character energy, no cap.
and like, the name says it all: hbf2gf works with CJK fonts in a specific format called Hanzi Bitmap Font (HBF) format β¨. what even is it? it's just the CJK bitmap file(s) plus a text file, and that text file looks a lot like the BDF format from the X Window System β it describes the bitmap font files: the encoding, the size, etc. the GF files it produces can then be converted with gftopk into standard PK files. slay π
so hbf2gf can be called in three modes, bestie, and you gotta know all three:
hbf2gf [-q] configuration-file[.cfg]
this call normally creates a whole set of GF files, one PL file, and a batch file that you have to run after hbf2gf finishes. that script will then call gftopk to convert all the GF files into PK files, and it will call pltotf to convert the PL file into a TFM file. and finally it copies the TFM file around so that every PK file has its own TFM file (they're all identical, periodt).
if ofm_file is set to βyesβ in the configuration file, OFM and OVF files get created too π
-q makes hbf2gf quiet π€«
hbf2gf [-q] [-p] [-g] [-n] subfont-name x-resolution [y-scale | y-resolution]
this mode is made for use with mktexpk and its derivates. only one GF file plus a PL file for the given subfont gets computed, and it takes the horizontal resolution plus a vertical scaling factor (if the value is smaller than 10) β or, otherwise, the vertical resolution β straight from the command line, ignoring the nmb_fonts parameter of the configuration file. rude but valid.
the last two characters (which get interpreted as the subfont number) are stripped off to get the name for the configuration file (which must end with β.cfgβ). no job file gets created.
- if option
-pis set, no PL file is created. - if
-gis set, no GF file is created. - the extension can be controlled with
-n; if set, the extension is β.gfβ, otherwise β.<resolution>gfβ. -qmakeshbf2gfquiet π€«
hbf2gf -t [-q] subfont-name
this mode is for use with scripts like mktexpk; it tests whether the specified subfont name leads to an hbf2gf configuration file. it returns 0 on success and prints out the name of that configuration file (as long as the -q switch isn't set). β οΈ this test isn't a thorough one; it only removes the last two characters and checks whether a configuration file with that name exists. lowkey lazy, but it's what we have π
see the next section for more details about configuration files π
specifying the option --version returns the current version of hbf2gf and the used file search library (e.g. kpathsea). usage information is shown with the --help parameter.
π CONFIGURATION FILE π
here's a sample configuration file (gsfs14.cfg) for a 56Γ56 Chinese font in GB encoding π note that all the information about the font lives in the jfs56.hbf file. see the FILE SEARCHING section for how HBF fonts and hbf2gf configuration files are found. see the AVAILABILITY section for where to get CJK fonts together with their HBF files:
hbf_header jfs56.hbf
mag_x 1
threshold 128
comment jianti fansongti 56x56 pixel font
design_size 14.4
y_offset -13
nmb_files -1
output_name gsfs14
checksum 123456789
dpi_x 300
pk_files no
tfm_files yes
coding codingscheme GuoBiao encoded TeX text
pk_directory $HBF_TARGET/pk/modeless/gb2312/gsfs14/
tfm_directory $HBF_TARGET/tfm/gb2312/gsfs14/
a configuration file is a plain text file made of keywords and their arguments π
- a keyword must start a line β otherwise the whole line gets ignored π
- if the word starting a line isn't a keyword, the line gets ignored too
- empty lines get skipped as well
- the search for keywords is case insensitive; but the arguments are taken exactly as given (except βyesβ and βnoβ, which can be written uppercase or lowercase)
- each keyword has one argument, which must be separated from the keyword by whitespace (blanks or tabs) and must be on the same line
- each line must not be longer than
256characters π
you can use environment variables in the configuration file β¨ the escape character that starts an environment variable in the configuration file is always β$β, even on operating systems like DOS which have other conventions. hbf2gf only recognizes environment variable names which start with a letter or an underscore, followed by alphanumeric characters or underscores. you can surround the variable with braces to show where the variable name ends, for example ${FOO}. to get an actual dollar sign you must write β$$β πΈ
β οΈ the expansion of environment variables inhbf2gfitself (without the help of eitherkpathsea,emtexdir, or MiKTeX searching routines) is very limited; this feature has been carried over from previous versions. it can't expand variables set intexmf.cnf; it also can't handle more than one directory as the variable's value. don't use it except for the βpk_directoryβ and βtfm_directoryβ parameters! π¨
here's the list of all the necessary keywords:
hbf_headerβ the HBF header file name of the input font(s).hbf2gfuses the given searching mechanism (kpathsea,emtexdir, or MiKTeX) to locate this file. πoutput_nameβ the name stem of the output files. a running two digit decimal number starting with β01β gets appended. for Unicode fonts see the keywordunicodebelow. this value is in almost all cases identical to the name of the configuration file. π
and now all the optional keywords β¨:
x_offsetβ increases the character width. gets applied on both sides; default for non-rotated glyphs is the value given in the HBF header (HBF_BITMAP_BOUNDING_BOX) scaled todesign_size(in pixels).y_offsetβ shifts all characters up or down; default for non-rotated glyphs is the value given in the HBF header (HBF_BITMAP_BOUNDING_BOX) scaled todesign_size(in pixels).design_sizeβ the design size (in points) of the font.x_offsetandy_offsetrefer to this size. default is10.0.slantβ the slant of the font (given as Delta_x / Delta_y). only values in the range0 β€ slant β€ 1are allowed. default is0.0.rotationβ if set to βyesβ, all glyphs get rotated 90 degrees counter-clockwise. the default offsets as given in the HBF header get ignored (and set to0). default is βnoβ.mag_x,mag_yβ scaling values of the characters to reach design size. if only one magnification is given, x and y values are assumed to be equal. default ismag_x = mag_y = 1.0.thresholdβ a value between1and254defining a threshold for converting the internal graymap into the output bitmap; lower values cut more pixels. default value is128.commentβ a comment describing the font; default is none.nmb_fontsβ the number of subfonts to create. default value is-1for creating all fonts.unicodeβ if βyesβ, a two digit hexadecimal number gets used as a running number, starting with the value of the first byte of the first code range. default is βnoβ.min_charβ the minimum value of the encoding. you should set this value to get correct subfile offsets if it isn't identical to the lowest character code in the HBF file. πdpi_x,dpi_yβ the horizontal and vertical resolution (in dpi) of the printer. if only one resolution is given, x and y values are assumed to be equal. default is300.checksumβ a checksum to identify the GF files with the appropriate TFM files. the default value of this unsigned 32bit integer is0.codingβ a comment describing the coding scheme; default is none.pk_directoryβ the destination directory of the PK files; default: none. β οΈ attention! the batch file will not check whether this directory exists.tfm_directoryβ the destination directory of the TFM files; default: none. β οΈ attention! the batch file will not check whether this directory exists.pk_filesβ whether to create PK files or not; default is βyesβ.tfm_filesβ whether to create TFM files or not; default is βyesβ.ofm_fileβ whether to create an OPL file or not; default is βnoβ. the batch file will then useovp2ovfof the Omega distribution to convert it into an OFM and an OVF file. the OPL file simply maps all subfonts back to a single Omega font. π«Άlong_extensionβ if βyesβ, PK files will include the resolution in the extension (e.g.gsso1201.300pk). this affects the batch file only (default is βyesβ).rm_commandβ the shell command to remove files; default: βrmβ.cp_commandβ the shell command to copy files; default: βcpβ.job_extensionβ the extension of the batch file which callsgftopkandpltotfto convert the GF and the PL files into PK and TFM files respectively; default is none.
π FILE SEARCHING π
So here's the thing, bestie β hbf2gf doesn't just vibe around the filesystem by itself. It uses one of three libraries to go find its files: kpathsea, emtexdir, or MiKTeX. And ngl, they're not all for everyone:
emtexdironly works on operating systems with an MS-DOSish background, aka MS-DOS, OS/2, Windows. It's giving retro πMiKTeXis for Win32 systems.
π kpathsea π
The actual version of kpathsea gets shown right on your screen if you call hbf2gf --version. Cute, right?
Here's the lil table of file type β the kpathsea variable it answers to:
.hbfβMISCFONTS.cfgβHBF2GFINPUTS
Please go consult the info files of kpathsea for the deets on these variables, fr fr. The decision of which naming scheme to use for variables happens during compilation. Not your problem, it's the compiler's π«Ά
You should set the TEXMFCNF variable to the directory where your texmf.cnf configuration file resides.
And here's the proper command to find out what value a kpathsea variable is actually set to (we're using MISCFONTS as our example because she's the main character today). This is especially useful if a variable isn't set in texmf.cnf or in the environment β because then you get the default value that's hard-coded into the kpathsea library, and that's the tea you actually wanted π
kpsewhich -progname=hbf2gf -expand-var='$MISCFONTS'
We select the program name too, because it's possible to specify variables which are searched only for a certain program β in our example it would be MISCFONTS.hbf2gf. iykyk β¨
A similar but not identical method is to say:
kpsewhich -progname=hbf2gf -show-path='misc fonts'
- A full list of format types can be obtained by saying
kpsewhich --helpon the command line prompt.
This is exactly how hbf2gf searches for files. The disadvantage? All variables get expanded, which can cause very long strings. So it's giving novel-length, not bite-size π
π emtexdir π
Here's the list of suffixes and their related environment variables to be set in autoexec.bat (or in config.sys for OS/2, bestie):
.hbfβHBFONTS.cfgβHBFCFG
If one of the variables isn't set, a warning message is emitted. Heads up π’
The current directory will always be searched. And as usual, one exclamation mark appended to a directory path causes subdirectories one level deep to be searched; two exclamation marks causes all subdirectories to be searched. Example:
HBFONTS=c:\fonts\hbf!!;d:\myfonts\hbf!
Constructions like c:\fonts!!\hbf aren't possible. Don't try it, she said what she said π
π¦ MikTeX π¦
Please consult the documentation files of MiKTeX for more details. That's the whole vibe here, go read their docs π«Ά
β οΈ LIMITATIONS β οΈ
The x and y output size must not exceed MAX_CHAR_SIZE, which is defined at compile time. Its default value is 1023 (pixel). So if you're out here trying to go bigger than that, no you're not π
π SEE ALSO π
ttf2pk(1)hbf2gf.wβ this is the source code written in CWEB, which can be converted into a pretty-printed TeX document usingcweave. The CJK package also contains a preformattedhbf2gf.pdffile. So iconic of her to ship both β- the CJK documentation files (
hbf2gf.txt) - the Hanzi Bitmap File (HBF) standard version 1.3; available at
ftp.ifcss.org - the Omega documentation available at
ftp.ens.frand the CTAN hosts and mirrors
π FILES π
*.cfgβ Thehbf2gfconfiguration scripts.*.hbfβ HBF header files which describe fixed-width bitmap fonts. Note that the bitmap font name(s) themselves as specified in the header files are irrelevant forhbf2gf. Like, don't even worry about them, she's not looking π«Ά
πΈ AVAILABILITY πΈ
hbf2gf is part of the CJK macro package for LaTeX 2e, available at the CTAN hosts and its mirrors.
CJK fonts together with HBF header files can be found at ftp.ifcss.org and its mirrors. Go get your fonts, bestie π
π AUTHORS π
- Werner Lemberg
<wl@gnu.org> - Ross Paterson (the HBF API)
<ross@soi.city.ac.uk>
And that's the whole page, babes π This was CJK Version 4.8.5, dated 16-Oct-2021, and it's HBF2GF(1) β go forth and convert those HBF header files, you absolute legend π
β¨
π¦ where this page comes from
- alpine 3.24: texlive-doc 2026.0-r0 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- arch rolling: texlive-doc 2026.1-1 Β· GPL
- debian bookworm: latex-cjk-common 4.8.5-1 Β· GPL-2.0-or-later
- debian trixie: latex-cjk-common 4.8.5-1 Β· GPL-2.0-or-later
- fedora 43: texlive-cjkutils 11:svn60833-93.fc43 Β· LPPL-1.3c
- fedora 43: texlive-cjkutils 11:svn60833-95.fc43.1 Β· LPPL-1.3c
- fedora 44: texlive-cjkutils 12:svn60833-105.fc44 Β· LPPL-1.3c
- fedora 44: texlive-cjkutils 12:svn60833-111.fc44 Β· LPPL-1.3c
- opensuse-leap 16.0: texlive-cjkutils-doc 2025.221.4.8.5svn60833-160000.3.1 Β· GPL-2.0-or-later
- ubuntu noble: latex-cjk-common 4.8.5-1 Β· GPL-2.0-or-later
- ubuntu questing: latex-cjk-common 4.8.5-2
- ubuntu resolute: latex-cjk-common 4.8.5-2build1 Β· GPL-2.0-or-later
- ubuntu stonking: latex-cjk-common 4.8.5-3 Β· GPL-2.0-or-later
- Copyright (C) 1994-2021 Werner Lemberg <wl@gnu.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms