hex2otf - Man Page

Convert a GNU Unifont .hex file to an OpenType font

Synopsis

hex2otf [--help] [--version]

hex2otf operand ...

Description

The hex2otf utility generates an OpenType font from a GNU Unifont .hex file.

hex2otf reads a file in Unifont .hex file format, as specified with the hex=filename.hex operand, and creates an OpenType file as specified with the out=filename.otf operand. A combining character offset file may optionally be specified with the pos=combining-file operand.

TrueType and OpenType ID fields are specified with operands of the form id=string.

A dummy GPOS table can be generated with the gpos option. The following subsection describes why this is beneficial.

Gpos Rationale

A dummy GPOS table is useful for positioning combining characters consistently. For example, HarfBuzz will perform fallback mark positioning on certain conditions, trying to put combining marks closer to their base characters. But it does not work well with the blank outlines generated by this utility, because blank outlines do not have relevant glyph extent values. The dummy GPOS table contains no useful position information, but its presence is enough for HarfBuzz to skip the fallback positioning. However, both HarfBuzz and Uniscribe will still precompose characters before rendering. For example, “a\u0301” is rendered exactly as the glyph of U+00E1 (LATIN SMALL LETTER A WITH ACUTE), not the composite of two glyphs.

Output Format Considerations

The font format should be carefully chosen. In general, using the cff and gpos operands together will produce good results on GNU/Linux, *nix, Windows, and macOS systems.  The current status of different formats is as follows:

CFF outline

May cause rendering issues in the Windows Command Prompt program.

CFF 2 outline

Not recognized by Windows.

TrueType outline

On Windows, this appears to be blurred in 16 pixels size due to the ClearType anti-alias mechanism; this can be fixed by embedding bitmaps.

Bitmap-only

Contrary to the OpenType specification, a bitmap-only font has to be accompanied by blank outlines to be recognized.

Future Directions

Some font parameters are hard coded into the source code for convenience. Other approaches may be preferable.

The generated fonts may produce incorrect result for vertical layout. More font parameters might be necessary if such a need arises.

Font size may be reduced by using e.g. CFF subroutines and TrueType font programs.

Options

--help

Print a brief help message and exit.

--version

Print program version information and exit.

Operands

hex=file

Specify the input hex file pathname.

pos=file

Optional. Specify the combining position file pathname.

out=file

Specify the output pathname.

format=word[,word ...]

Specify the font format. Each word shall be one of the following:

cff

Generate CFF outlines.

cff2

Generate CFF 2 outlines.

truetype

Generate TrueType outlines.

blank

Generate blank outlines. Generating a font with only blank outlines is not allowed.

bitmap

Generate embedded bitmap. Required if no outlines are generated.

gpos

Generate dummy GPOS table. See the "Gpos Rationale" section above.

gsub

Generate generic GSUB table with two entries: "DFLT" and "thai". "DFLT" improves glyph positioning in HarfBuzz, especially as relates to glyph reordering.  "thai" directs HarfBuzz not to obtain Thai glyphs from the Unicode Private Use Area.

id=text

Specify font attributes. id shall be an decimal integer from 0 to 255, corresponding to “Name ID” as defined in the OpenType specification, <https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids>. text shall be value of the attribute in English (United States). Characters beyond the ASCII range shall be encoded as UTF-8. Currently defined attributes relevant to Unifont are briefly listed below. Refer to the specification for full details.

ID

Meaning and Notes

0

Copyright notice.

1

Font family name.

2

Font subfamily name.  Should be “Regular”.

3

Unique font identifier.

4

Full font name.

5

Version string.  Should begin with “Version number.number”, where each number is in the range of 0 to 65535.

6

PostScript name.  Less than 64 printable ASCII characters except those in “[](){}<>/%

7

Trademark.

8

Manufacturer name.

9

Designer.

10

Description.

11

Vendor URL.

12

Designer URL.

13

License description, in plain language.

14

License info URL.

18

Compatible full name; Macintosh only.

19

Sample text.

Fontforge Note

Default FontForge package installations can incorrectly ignore the Unicode plane of glyphs beyond Plane 0 in CID-keyed fonts (such as are generated with the format=cff option).  This is caused by the presence of the file Adobe-Identity-0.cidmap, which FontForge interprets incorrectly to determine Unicode code point glyph mappings if present.  This file is located in /usr/share/fontforge/cidmap or a similar directory on GNU/Linux systems.  Removing or renaming Adobe-Identity-0.cidmap will cause FontForge to fall back on OpenType cmap entries in the font.  FontForge will then correctly display all Unicode code points.

Example

Sample usage:

hex2otf hex=unifont.hex pos=combining.txt \
format=cff,gpos,gsub out=unifont.otf

Exit Status

Status values are defined in <stdlib.h>. The program exits with status EXIT_SUCCESS upon successful font generation, or EXIT_FAILURE if an error occurred.  If an error condition is encountered, hex2otf writes a brief diagnostic message to STDERR; in this event, the state of the output font file will be undefined.

See Also

unifont(5), hex2bdf(1)

Author

hex2otf was written by He Zhixiang.

License

hex2otf is Copyright © 2022 He Zhixiang.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Referenced By

bdfimplode(1), hex2bdf(1), hex2sfd(1), hexbraille(1), hexdraw(1), hexkinya(1), hexmerge(1), johab2syllables(1), johab2ucs2(1), unibdf2hex(1), unibmp2hex(1), unibmpbump(1), unicoverage(1), unidup(1), unifont(5), unifont1per(1), unifontchojung(1), unifont-johab631(5), unifontksx(1), unifontpic(1), unifont-viewer(1), unigencircles(1), unigen-hangul(1), unigenwidth(1), unihex2bmp(1), unihex2png(1), unihexfill(1), unihexgen(1), unihexpose(1), unihexrotate(1), unijohab2html(1), unipagecount(1), unipng2hex(1).

2022-03-19 GNU Unifont