GNU Unifont 16.0.02
Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes
|
hex2otf - Convert GNU Unifont .hex file to OpenType font More...
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hex2otf.h"
Go to the source code of this file.
Data Structures | |
struct | Buffer |
Generic data structure for a linked list of buffer elements. More... | |
struct | Glyph |
Data structure to hold data for one bitmap glyph. More... | |
struct | Font |
Data structure to hold information for one font. More... | |
struct | Table |
Data structure for an OpenType table. More... | |
struct | TableRecord |
Data structure for data associated with one OpenType table. More... | |
struct | Options |
Data structure to hold options for OpenType font output. More... | |
Macros | |
#define | VERSION "1.0.1" |
Program version, for "--version" option. More... | |
#define | U16MAX 0xffff |
Maximum UTF-16 code point value. More... | |
#define | U32MAX 0xffffffff |
Maximum UTF-32 code point value. More... | |
#define | PRI_CP "U+%.4"PRIXFAST32 |
Format string to print Unicode code point. More... | |
#define | static_assert(a, b) (assert(a)) |
If "a" is true, return string "b". More... | |
#define | BX(shift, x) ((uintmax_t)(!!(x)) << (shift)) |
Truncate & shift word. More... | |
#define | B0(shift) BX((shift), 0) |
Clear a given bit in a word. More... | |
#define | B1(shift) BX((shift), 1) |
Set a given bit in a word. More... | |
#define | GLYPH_MAX_WIDTH 16 |
Maximum glyph width, in pixels. More... | |
#define | GLYPH_HEIGHT 16 |
Maximum glyph height, in pixels. More... | |
#define | GLYPH_MAX_BYTE_COUNT (GLYPH_HEIGHT * GLYPH_MAX_WIDTH / 8) |
Number of bytes to represent one bitmap glyph as a binary array. More... | |
#define | DESCENDER 2 |
Count of pixels below baseline. More... | |
#define | ASCENDER (GLYPH_HEIGHT - DESCENDER) |
Count of pixels above baseline. More... | |
#define | FUPEM 64 |
Font units per em. More... | |
#define | MAX_GLYPHS 65536 |
An OpenType font has at most 65536 glyphs. More... | |
#define | MAX_NAME_IDS 256 |
Name IDs 0-255 are used for standard names. More... | |
#define | FU(x) ((x) * FUPEM / GLYPH_HEIGHT) |
Convert pixels to font units. More... | |
#define | PW(x) ((x) / (GLYPH_HEIGHT / 8)) |
Convert glyph byte count to pixel width. More... | |
#define | defineStore(name, type) |
Temporary define to look up an element in an array of given type. More... | |
#define | addByte(shift) |
#define | getRowBit(rows, x, y) ((rows)[(y)] & x0 >> (x)) |
#define | flipRowBit(rows, x, y) ((rows)[(y)] ^= x0 >> (x)) |
#define | stringCount (sizeof strings / sizeof *strings) |
#define | cacheCFF32(buf, x) (cacheU8 ((buf), 29), cacheU32 ((buf), (x))) |
Typedefs | |
typedef unsigned char | byte |
Definition of "byte" type as an unsigned char. More... | |
typedef int_least8_t | pixels_t |
This type must be able to represent max(GLYPH_MAX_WIDTH, GLYPH_HEIGHT). More... | |
typedef struct Buffer | Buffer |
Generic data structure for a linked list of buffer elements. More... | |
typedef const char * | NameStrings[MAX_NAME_IDS] |
Array of OpenType names indexed directly by Name IDs. More... | |
typedef struct Glyph | Glyph |
Data structure to hold data for one bitmap glyph. More... | |
typedef struct Font | Font |
Data structure to hold information for one font. | |
typedef struct Table | Table |
Data structure for an OpenType table. More... | |
typedef struct Options | Options |
Data structure to hold options for OpenType font output. More... | |
Enumerations | |
enum | LocaFormat { LOCA_OFFSET16 = 0 , LOCA_OFFSET32 = 1 } |
Index to Location ("loca") offset information. More... | |
enum | ContourOp { OP_CLOSE , OP_POINT } |
Specify the current contour drawing operation. More... | |
enum | FillSide { FILL_LEFT , FILL_RIGHT } |
Fill to the left side (CFF) or right side (TrueType) of a contour. More... | |
Functions | |
void | fail (const char *reason,...) |
Print an error message on stderr, then exit. More... | |
void | initBuffers (size_t count) |
Initialize an array of buffer pointers to all zeroes. More... | |
void | cleanBuffers () |
Free all allocated buffer pointers. More... | |
Buffer * | newBuffer (size_t initialCapacity) |
Create a new buffer. More... | |
void | ensureBuffer (Buffer *buf, size_t needed) |
Ensure that the buffer has at least the specified minimum size. More... | |
void | freeBuffer (Buffer *buf) |
Free the memory previously allocated for a buffer. More... | |
defineStore (storeU8, uint_least8_t) | |
void | cacheU8 (Buffer *buf, uint_fast8_t value) |
Append one unsigned byte to the end of a byte array. More... | |
void | cacheU16 (Buffer *buf, uint_fast16_t value) |
Append two unsigned bytes to the end of a byte array. More... | |
void | cacheU32 (Buffer *buf, uint_fast32_t value) |
Append four unsigned bytes to the end of a byte array. More... | |
void | cacheCFFOperand (Buffer *buf, int_fast32_t value) |
Cache charstring number encoding in a CFF buffer. More... | |
void | cacheZeros (Buffer *buf, size_t count) |
Append 1 to 4 bytes of zeroes to a buffer, for padding. More... | |
void | cacheBytes (Buffer *restrict buf, const void *restrict src, size_t count) |
Append a string of bytes to a buffer. More... | |
void | cacheBuffer (Buffer *restrict bufDest, const Buffer *restrict bufSrc) |
Append bytes of a table to a byte buffer. More... | |
void | writeBytes (const byte bytes[], size_t count, FILE *file) |
Write an array of bytes to an output file. More... | |
void | writeU16 (uint_fast16_t value, FILE *file) |
Write an unsigned 16-bit value to an output file. More... | |
void | writeU32 (uint_fast32_t value, FILE *file) |
Write an unsigned 32-bit value to an output file. More... | |
void | addTable (Font *font, const char tag[static 4], Buffer *content) |
Add a TrueType or OpenType table to the font. More... | |
void | organizeTables (Font *font, bool isCFF) |
Sort tables according to OpenType recommendations. More... | |
int | byTableTag (const void *a, const void *b) |
Compare tables by 4-byte unsigned table tag value. More... | |
void | writeFont (Font *font, bool isCFF, const char *fileName) |
Write OpenType font to output file. More... | |
bool | readCodePoint (uint_fast32_t *codePoint, const char *fileName, FILE *file) |
Read up to 6 hexadecimal digits and a colon from file. More... | |
void | readGlyphs (Font *font, const char *fileName) |
Read glyph definitions from a Unifont .hex format file. More... | |
int | byCodePoint (const void *a, const void *b) |
Compare two Unicode code points to determine which is greater. More... | |
void | positionGlyphs (Font *font, const char *fileName, pixels_t *xMin) |
Position a glyph within a 16-by-16 pixel bounding box. More... | |
void | sortGlyphs (Font *font) |
Sort the glyphs in a font by Unicode code point. More... | |
void | buildOutline (Buffer *result, const byte bitmap[], const size_t byteCount, const enum FillSide fillSide) |
Build a glyph outline. More... | |
void | prepareOffsets (size_t *sizes) |
Prepare 32-bit glyph offsets in a font table. More... | |
Buffer * | prepareStringIndex (const NameStrings names) |
Prepare a font name string index. More... | |
void | fillCFF (Font *font, int version, const NameStrings names) |
Add a CFF table to a font. More... | |
void | fillTrueType (Font *font, enum LocaFormat *format, uint_fast16_t *maxPoints, uint_fast16_t *maxContours) |
Add a TrueType table to a font. More... | |
void | fillBlankOutline (Font *font) |
Create a dummy blank outline in a font table. More... | |
void | fillBitmap (Font *font) |
Fill OpenType bitmap data and location tables. More... | |
void | fillHeadTable (Font *font, enum LocaFormat locaFormat, pixels_t xMin) |
Fill a "head" font table. More... | |
void | fillHheaTable (Font *font, pixels_t xMin) |
Fill a "hhea" font table. More... | |
void | fillMaxpTable (Font *font, bool isCFF, uint_fast16_t maxPoints, uint_fast16_t maxContours) |
Fill a "maxp" font table. More... | |
void | fillOS2Table (Font *font) |
Fill an "OS/2" font table. More... | |
void | fillHmtxTable (Font *font) |
Fill an "hmtx" font table. More... | |
void | fillCmapTable (Font *font) |
Fill a "cmap" font table. More... | |
void | fillPostTable (Font *font) |
Fill a "post" font table. More... | |
void | fillGposTable (Font *font) |
Fill a "GPOS" font table. More... | |
void | fillGsubTable (Font *font) |
Fill a "GSUB" font table. More... | |
void | cacheStringAsUTF16BE (Buffer *buf, const char *str) |
Cache a string as a big-ending UTF-16 surrogate pair. More... | |
void | fillNameTable (Font *font, NameStrings nameStrings) |
Fill a "name" font table. More... | |
void | printVersion () |
Print program version string on stdout. More... | |
void | printHelp () |
Print help message to stdout and then exit. More... | |
const char * | matchToken (const char *operand, const char *key, char delimiter) |
Match a command line option with its key for enabling. More... | |
Options | parseOptions (char *const argv[const]) |
Parse command line options. More... | |
int | main (int argc, char *argv[]) |
The main function. More... | |
Variables | |
Buffer * | allBuffers |
Initial allocation of empty array of buffer pointers. More... | |
size_t | bufferCount |
Number of buffers in a Buffer * array. More... | |
size_t | nextBufferIndex |
Index number to tail element of Buffer * array. More... | |
hex2otf - Convert GNU Unifont .hex file to OpenType font
This program reads a Unifont .hex format file and a file containing combining mark offset information, and produces an OpenType font file.
Definition in file hex2otf.c.
#define addByte | ( | shift | ) |
#define ASCENDER (GLYPH_HEIGHT - DESCENDER) |
#define B0 | ( | shift | ) | BX((shift), 0) |
#define B1 | ( | shift | ) | BX((shift), 1) |
#define BX | ( | shift, | |
x | |||
) | ((uintmax_t)(!!(x)) << (shift)) |
#define defineStore | ( | name, | |
type | |||
) |
Temporary define to look up an element in an array of given type.
This defintion is used to create lookup functions to return a given element in unsigned arrays of size 8, 16, and 32 bytes, and in an array of pixels.
#define FU | ( | x | ) | ((x) * FUPEM / GLYPH_HEIGHT) |
#define GLYPH_MAX_BYTE_COUNT (GLYPH_HEIGHT * GLYPH_MAX_WIDTH / 8) |
#define MAX_GLYPHS 65536 |
#define MAX_NAME_IDS 256 |
#define PRI_CP "U+%.4"PRIXFAST32 |
#define PW | ( | x | ) | ((x) / (GLYPH_HEIGHT / 8)) |
#define static_assert | ( | a, | |
b | |||
) | (assert(a)) |
#define VERSION "1.0.1" |
Generic data structure for a linked list of buffer elements.
A buffer can act as a vector (when filled with 'store*' functions), or a temporary output area (when filled with 'cache*' functions). The 'store*' functions use native endian. The 'cache*' functions use big endian or other formats in OpenType. Beware of memory alignment.
typedef unsigned char byte |
Data structure to hold data for one bitmap glyph.
This data structure holds data to represent one Unifont bitmap glyph: Unicode code point, number of bytes in its bitmap array, whether or not it is a combining character, and an offset from the glyph origin to the start of the bitmap.
typedef const char* NameStrings[MAX_NAME_IDS] |
Data structure to hold options for OpenType font output.
This data structure holds the status of options that can be specified as command line arguments for creating the output OpenType font file.
typedef int_least8_t pixels_t |
Data structure for an OpenType table.
This data structure contains a table tag and a pointer to the start of the buffer that holds data for this OpenType table.
For information on the OpenType tables and their structure, see https://docs.microsoft.com/en-us/typography/opentype/spec/otff#font-tables.
enum ContourOp |
enum FillSide |
enum LocaFormat |
Index to Location ("loca") offset information.
This enumerated type encodes the type of offset to locations in a table. It denotes Offset16 (16-bit) and Offset32 (32-bit) offset types.
Enumerator | |
---|---|
LOCA_OFFSET16 | Offset to location is a 16-bit Offset16 value. |
LOCA_OFFSET32 | Offset to location is a 32-bit Offset32 value. |
Definition at line 658 of file hex2otf.c.
Add a TrueType or OpenType table to the font.
This function adds a TrueType or OpenType table to a font. The 4-byte table tag is passed as an unsigned 32-bit integer in big-endian format.
[in,out] | font | The font to which a font table will be added. |
[in] | tag | The 4-byte table name. |
[in] | content | The table bytes to add, of type Buffer *. |
Definition at line 694 of file hex2otf.c.
void buildOutline | ( | Buffer * | result, |
const byte | bitmap[], | ||
const size_t | byteCount, | ||
const enum FillSide | fillSide | ||
) |
Build a glyph outline.
This function builds a glyph outline from a Unifont glyph bitmap.
[out] | result | The resulting glyph outline. |
[in] | bitmap | A bitmap array. |
[in] | byteCount | the number of bytes in the input bitmap array. |
[in] | fillSide | Enumerated indicator to fill left or right side. |
Get the value of a given bit that is in a given row.
Invert the value of a given bit that is in a given row.
Definition at line 1160 of file hex2otf.c.
int byCodePoint | ( | const void * | a, |
const void * | b | ||
) |
Compare two Unicode code points to determine which is greater.
This function compares the Unicode code points contained within two Glyph data structures. The function returns 1 if the first code point is greater, and -1 if the second is greater.
[in] | a | A Glyph data structure containing the first code point. |
[in] | b | A Glyph data structure containing the second code point. |
Definition at line 1040 of file hex2otf.c.
int byTableTag | ( | const void * | a, |
const void * | b | ||
) |
Compare tables by 4-byte unsigned table tag value.
This function takes two pointers to a TableRecord data structure and extracts the four-byte tag structure element for each. The two 32-bit numbers are then compared. If the first tag is greater than the first, then gt = 1 and lt = 0, and so 1 - 0 = 1 is returned. If the first is less than the second, then gt = 0 and lt = 1, and so 0 - 1 = -1 is returned.
[in] | a | Pointer to the first TableRecord structure. |
[in] | b | Pointer to the second TableRecord structure. |
Definition at line 767 of file hex2otf.c.
Append bytes of a table to a byte buffer.
[in,out] | bufDest | The buffer to which the new bytes are appended. |
[in] | bufSrc | The bytes to append to the buffer array. |
Definition at line 523 of file hex2otf.c.
void cacheBytes | ( | Buffer *restrict | buf, |
const void *restrict | src, | ||
size_t | count | ||
) |
Append a string of bytes to a buffer.
This function appends an array of 1 to 4 bytes to the end of a buffer.
[in,out] | buf | The buffer to which the bytes are appended. |
[in] | src | The array of bytes to append to the buffer. |
[in] | count | The number of bytes containing zeroes to append. |
Definition at line 509 of file hex2otf.c.
void cacheCFFOperand | ( | Buffer * | buf, |
int_fast32_t | value | ||
) |
Cache charstring number encoding in a CFF buffer.
This function caches two's complement 8-, 16-, and 32-bit words as per Adobe's Type 2 Charstring encoding for operands. These operands are used in Compact Font Format data structures.
Byte values can have offsets, for which this function compensates, optionally followed by additional bytes:
Byte Range Offset Bytes Adjusted Range ---------- ------ ----- -------------- 0 to 11 0 1 0 to 11 (operators) 12 0 2 Next byte is 8-bit op code 13 to 18 0 1 13 to 18 (operators) 19 to 20 0 2+ hintmask and cntrmask operators 21 to 27 0 1 21 to 27 (operators) 28 0 3 16-bit 2's complement number 29 to 31 0 1 29 to 31 (operators) 32 to 246 -139 1 -107 to +107 247 to 250 +108 2 +108 to +1131 251 to 254 -108 2 -108 to -1131 255 0 5 16-bit integer and 16-bit fraction
[in,out] | buf | The buffer to which the operand value is appended. |
[in] | value | The operand value. |
Definition at line 460 of file hex2otf.c.
void cacheStringAsUTF16BE | ( | Buffer * | buf, |
const char * | str | ||
) |
Cache a string as a big-ending UTF-16 surrogate pair.
This function encodes a UTF-8 string as a big-endian UTF-16 surrogate pair.
[in,out] | buf | Pointer to a Buffer struct to update. |
[in] | str | The character array to encode. |
Definition at line 2316 of file hex2otf.c.
void cacheU16 | ( | Buffer * | buf, |
uint_fast16_t | value | ||
) |
Append two unsigned bytes to the end of a byte array.
This function adds two bytes to the end of a byte array. The buffer is updated to account for the newly-added bytes.
[in,out] | buf | The array of bytes to which to append two new bytes. |
[in] | value | The 16-bit unsigned value to append to the buf array. |
Definition at line 412 of file hex2otf.c.
void cacheU32 | ( | Buffer * | buf, |
uint_fast32_t | value | ||
) |
Append four unsigned bytes to the end of a byte array.
This function adds four bytes to the end of a byte array. The buffer is updated to account for the newly-added bytes.
[in,out] | buf | The array of bytes to which to append four new bytes. |
[in] | value | The 32-bit unsigned value to append to the buf array. |
Definition at line 427 of file hex2otf.c.
void cacheU8 | ( | Buffer * | buf, |
uint_fast8_t | value | ||
) |
Append one unsigned byte to the end of a byte array.
This function adds one byte to the end of a byte array. The buffer is updated to account for the newly-added byte.
[in,out] | buf | The array of bytes to which to append a new byte. |
[in] | value | The 8-bit unsigned value to append to the buf array. |
Definition at line 397 of file hex2otf.c.
void cacheZeros | ( | Buffer * | buf, |
size_t | count | ||
) |
Append 1 to 4 bytes of zeroes to a buffer, for padding.
[in,out] | buf | The buffer to which the operand value is appended. |
[in] | count | The number of bytes containing zeroes to append. |
Definition at line 491 of file hex2otf.c.
void cleanBuffers | ( | ) |
Free all allocated buffer pointers.
This function frees all buffer pointers previously allocated in the initBuffers function.
Definition at line 170 of file hex2otf.c.
defineStore | ( | storeU8 | , |
uint_least8_t | |||
) |
Definition at line 356 of file hex2otf.c.
void ensureBuffer | ( | Buffer * | buf, |
size_t | needed | ||
) |
Ensure that the buffer has at least the specified minimum size.
This function takes a buffer array of type Buffer and the necessary minimum number of elements as inputs, and attempts to increase the size of the buffer if it must be larger.
If the buffer is too small and cannot be resized, the program will terminate with an error message and an exit status of EXIT_FAILURE.
[in,out] | buf | The buffer to check. |
[in] | needed | The required minimum number of elements in the buffer. |
Definition at line 239 of file hex2otf.c.
void fail | ( | const char * | reason, |
... | |||
) |
Print an error message on stderr, then exit.
This function prints the provided error string and optional following arguments to stderr, and then exits with a status of EXIT_FAILURE.
[in] | reason | The output string to describe the error. |
[in] | ... | Optional following arguments to output. |
Definition at line 113 of file hex2otf.c.
void fillBitmap | ( | Font * | font | ) |
Fill OpenType bitmap data and location tables.
This function fills an Embedded Bitmap Data (EBDT) Table and an Embedded Bitmap Location (EBLC) Table with glyph bitmap information. These tables enable embedding bitmaps in OpenType fonts. No Embedded Bitmap Scaling (EBSC) table is used for the bitmap glyphs, only EBDT and EBLC.
[in,out] | font | Pointer to a Font struct in which to add bitmaps. |
Definition at line 1728 of file hex2otf.c.
void fillBlankOutline | ( | Font * | font | ) |
Create a dummy blank outline in a font table.
[in,out] | font | Pointer to a Font struct to insert a blank outline. |
Definition at line 1697 of file hex2otf.c.
void fillCFF | ( | Font * | font, |
int | version, | ||
const NameStrings | names | ||
) |
Add a CFF table to a font.
[in,out] | font | Pointer to a Font struct to contain the CFF table. |
[in] | version | Version of CFF table, with value 1 or 2. |
[in] | names | List of NameStrings. |
Use fixed width integer for variables to simplify offset calculation.
Definition at line 1329 of file hex2otf.c.
void fillCmapTable | ( | Font * | font | ) |
Fill a "cmap" font table.
The "cmap" table contains character to glyph index mapping information.
[in,out] | font | The Font struct to which to add the table. |
Definition at line 2109 of file hex2otf.c.
void fillGposTable | ( | Font * | font | ) |
Fill a "GPOS" font table.
The "GPOS" table contains information for glyph positioning.
[in,out] | font | The Font struct to which to add the table. |
Definition at line 2241 of file hex2otf.c.
void fillGsubTable | ( | Font * | font | ) |
Fill a "GSUB" font table.
The "GSUB" table contains information for glyph substitution.
[in,out] | font | The Font struct to which to add the table. |
Definition at line 2269 of file hex2otf.c.
void fillHeadTable | ( | Font * | font, |
enum LocaFormat | locaFormat, | ||
pixels_t | xMin | ||
) |
Fill a "head" font table.
The "head" table contains font header information common to the whole font.
[in,out] | font | The Font struct to which to add the table. |
[in] | locaFormat | The "loca" offset index location table. |
[in] | xMin | The minimum x-coordinate for a glyph. |
Definition at line 1853 of file hex2otf.c.
Fill a "hhea" font table.
The "hhea" table contains horizontal header information, for example left and right side bearings.
[in,out] | font | The Font struct to which to add the table. |
[in] | xMin | The minimum x-coordinate for a glyph. |
Definition at line 1918 of file hex2otf.c.
void fillHmtxTable | ( | Font * | font | ) |
Fill an "hmtx" font table.
The "hmtx" table contains horizontal metrics information.
[in,out] | font | The Font struct to which to add the table. |
Definition at line 2087 of file hex2otf.c.
void fillMaxpTable | ( | Font * | font, |
bool | isCFF, | ||
uint_fast16_t | maxPoints, | ||
uint_fast16_t | maxContours | ||
) |
Fill a "maxp" font table.
The "maxp" table contains maximum profile information, such as the memory required to contain the font.
[in,out] | font | The Font struct to which to add the table. |
[in] | isCFF | true if a CFF font is included, false otherwise. |
[in] | maxPoints | Maximum points in a non-composite glyph. |
[in] | maxContours | Maximum contours in a non-composite glyph. |
Definition at line 1954 of file hex2otf.c.
void fillNameTable | ( | Font * | font, |
NameStrings | nameStrings | ||
) |
Fill a "name" font table.
The "name" table contains name information, for example for Name IDs.
[in,out] | font | The Font struct to which to add the table. |
[in] | names | List of NameStrings. |
Definition at line 2366 of file hex2otf.c.
void fillOS2Table | ( | Font * | font | ) |
Fill an "OS/2" font table.
The "OS/2" table contains OS/2 and Windows font metrics information.
[in,out] | font | The Font struct to which to add the table. |
Definition at line 1986 of file hex2otf.c.
void fillPostTable | ( | Font * | font | ) |
void fillTrueType | ( | Font * | font, |
enum LocaFormat * | format, | ||
uint_fast16_t * | maxPoints, | ||
uint_fast16_t * | maxContours | ||
) |
Add a TrueType table to a font.
[in,out] | font | Pointer to a Font struct to contain the TrueType table. |
[in] | format | The TrueType "loca" table format, Offset16 or Offset32. |
[in] | names | List of NameStrings. |
Definition at line 1597 of file hex2otf.c.
void freeBuffer | ( | Buffer * | buf | ) |
void initBuffers | ( | size_t | count | ) |
Initialize an array of buffer pointers to all zeroes.
This function initializes the "allBuffers" array of buffer pointers to all zeroes.
[in] | count | The number of buffer array pointers to allocate. |
Definition at line 152 of file hex2otf.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
The main function.
[in] | argc | The number of command-line arguments. |
[in] | argv | The array of command-line arguments. |
Definition at line 2603 of file hex2otf.c.
const char * matchToken | ( | const char * | operand, |
const char * | key, | ||
char | delimiter | ||
) |
Match a command line option with its key for enabling.
[in] | operand | A pointer to the specified operand. |
[in] | key | Pointer to the option structure. |
[in] | delimeter | The delimiter to end searching. |
Definition at line 2470 of file hex2otf.c.
Buffer * newBuffer | ( | size_t | initialCapacity | ) |
Create a new buffer.
This function creates a new buffer array of type Buffer, with an initial size of initialCapacity elements.
[in] | initialCapacity | The initial number of elements in the buffer. |
Definition at line 188 of file hex2otf.c.
void organizeTables | ( | Font * | font, |
bool | isCFF | ||
) |
Sort tables according to OpenType recommendations.
The various tables in a font are sorted in an order recommended for TrueType font files.
[in,out] | font | The font in which to sort tables. |
[in] | isCFF | True iff Compact Font Format (CFF) is being used. |
Definition at line 711 of file hex2otf.c.
Options parseOptions | ( | char *const | argv[const ] | ) |
Parse command line options.
Option Data Type Description ------ --------- ----------- truetype bool Generate TrueType outlines blankOutline bool Generate blank outlines bitmap bool Generate embedded bitmap gpos bool Generate a dummy GPOS table gsub bool Generate a dummy GSUB table cff int Generate CFF 1 or CFF 2 outlines hex const char * Name of Unifont .hex file pos const char * Name of Unifont combining data file out const char * Name of output font file nameStrings NameStrings Array of TrueType font Name IDs
[in] | argv | Pointer to array of command line options. |
Definition at line 2500 of file hex2otf.c.
Position a glyph within a 16-by-16 pixel bounding box.
Position a glyph within the 16-by-16 pixel drawing area and note whether or not the glyph is a combining character.
N.B.: Glyphs must be sorted by code point before calling this function.
[in,out] | font | Font data structure pointer to store glyphs. |
[in] | fileName | Name of glyph file to read. |
[in] | xMin | Minimum x-axis value (for left side bearing). |
Definition at line 1061 of file hex2otf.c.
void prepareOffsets | ( | size_t * | sizes | ) |
Prepare 32-bit glyph offsets in a font table.
[in] | sizes | Array of glyph sizes, for offset calculations. |
Definition at line 1275 of file hex2otf.c.
Buffer * prepareStringIndex | ( | const NameStrings | names | ) |
Prepare a font name string index.
[in] | names | List of name strings. |
Get the number of elements in array char *strings[].
Definition at line 1291 of file hex2otf.c.
void printHelp | ( | ) |
Print help message to stdout and then exit.
Print help message if invoked with the "--help" option, and then exit successfully.
Definition at line 2426 of file hex2otf.c.
void printVersion | ( | ) |
Print program version string on stdout.
Print program version if invoked with the "--version" option, and then exit successfully.
Definition at line 2407 of file hex2otf.c.
bool readCodePoint | ( | uint_fast32_t * | codePoint, |
const char * | fileName, | ||
FILE * | file | ||
) |
Read up to 6 hexadecimal digits and a colon from file.
This function reads up to 6 hexadecimal digits followed by a colon from a file.
If the end of the file is reached, the function returns true. The file name is provided to include in an error message if the end of file was reached unexpectedly.
[out] | codePoint | The Unicode code point. |
[in] | fileName | The name of the input file. |
[in] | file | Pointer to the input file stream. |
Definition at line 919 of file hex2otf.c.
void readGlyphs | ( | Font * | font, |
const char * | fileName | ||
) |
Read glyph definitions from a Unifont .hex format file.
This function reads in the glyph bitmaps contained in a Unifont .hex format file. These input files contain one glyph bitmap per line. Each line is of the form
<hexadecimal code point> ':' <hexadecimal bitmap sequence>
The code point field typically consists of 4 hexadecimal digits for a code point in Unicode Plane 0, and 6 hexadecimal digits for code points above Plane 0. The hexadecimal bitmap sequence is 32 hexadecimal digits long for a glyph that is 8 pixels wide by 16 pixels high, and 64 hexadecimal digits long for a glyph that is 16 pixels wide by 16 pixels high.
[in,out] | font | The font data structure to update with new glyphs. |
[in] | fileName | The name of the Unifont .hex format input file. |
Definition at line 966 of file hex2otf.c.
void sortGlyphs | ( | Font * | font | ) |
Sort the glyphs in a font by Unicode code point.
This function reads in an array of glyphs and sorts them by Unicode code point. If a duplicate code point is encountered, that will result in a fatal error with an error message to stderr.
[in,out] | font | Pointer to a Font structure with glyphs to sort. |
Definition at line 1119 of file hex2otf.c.
void writeBytes | ( | const byte | bytes[], |
size_t | count, | ||
FILE * | file | ||
) |
Write an array of bytes to an output file.
[in] | bytes | An array of unsigned bytes to write. |
[in] | file | The file pointer for writing, of type FILE *. |
Definition at line 538 of file hex2otf.c.
void writeFont | ( | Font * | font, |
bool | isCFF, | ||
const char * | fileName | ||
) |
Write OpenType font to output file.
This function writes the constructed OpenType font to the output file named "filename".
[in] | font | Pointer to the font, of type Font *. |
[in] | isCFF | Boolean indicating whether the font has CFF data. |
[in] | filename | The name of the font file to create. |
Add a byte shifted by 24, 16, 8, or 0 bits.
Definition at line 786 of file hex2otf.c.
void writeU16 | ( | uint_fast16_t | value, |
FILE * | file | ||
) |
Write an unsigned 16-bit value to an output file.
This function writes a 16-bit unsigned value in big-endian order to an output file specified with a file pointer.
[in] | value | The 16-bit value to write. |
[in] | file | The file pointer for writing, of type FILE *. |
Definition at line 554 of file hex2otf.c.
void writeU32 | ( | uint_fast32_t | value, |
FILE * | file | ||
) |
Write an unsigned 32-bit value to an output file.
This function writes a 32-bit unsigned value in big-endian order to an output file specified with a file pointer.
[in] | value | The 32-bit value to write. |
[in] | file | The file pointer for writing, of type FILE *. |
Definition at line 574 of file hex2otf.c.
Buffer* allBuffers |