GNU Unifont  15.1.01
Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes
hex2otf.c File Reference

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"
Include dependency graph for hex2otf.c:

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.
 
#define U16MAX   0xffff
 Maximum UTF-16 code point value.
 
#define U32MAX   0xffffffff
 Maximum UTF-32 code point value.
 
#define PRI_CP   "U+%.4"PRIXFAST32
 Format string to print Unicode code point.
 
#define static_assert(a, b)   (assert(a))
 If "a" is true, return string "b".
 
#define BX(shift, x)   ((uintmax_t)(!!(x)) << (shift))
 Truncate & shift word.
 
#define B0(shift)   BX((shift), 0)
 Clear a given bit in a word.
 
#define B1(shift)   BX((shift), 1)
 Set a given bit in a word.
 
#define GLYPH_MAX_WIDTH   16
 Maximum glyph width, in pixels.
 
#define GLYPH_HEIGHT   16
 Maximum glyph height, in pixels.
 
#define GLYPH_MAX_BYTE_COUNT   (GLYPH_HEIGHT * GLYPH_MAX_WIDTH / 8)
 Number of bytes to represent one bitmap glyph as a binary array.
 
#define DESCENDER   2
 Count of pixels below baseline.
 
#define ASCENDER   (GLYPH_HEIGHT - DESCENDER)
 Count of pixels above baseline.
 
#define FUPEM   64
 Font units per em.
 
#define MAX_GLYPHS   65536
 An OpenType font has at most 65536 glyphs.
 
#define MAX_NAME_IDS   256
 Name IDs 0-255 are used for standard names.
 
#define FU(x)   ((x) * FUPEM / GLYPH_HEIGHT)
 Convert pixels to font units.
 
#define PW(x)   ((x) / (GLYPH_HEIGHT / 8))
 Convert glyph byte count to pixel width.
 
#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.
 
typedef int_least8_t pixels_t
 This type must be able to represent max(GLYPH_MAX_WIDTH, GLYPH_HEIGHT).
 
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.
 
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...
 
BuffernewBuffer (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...