| 1 |
#ifndef CARYLL_cff_UTIL_H |
| 2 |
#define CARYLL_cff_UTIL_H |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
#include <stdio.h> |
| 6 |
#include <stdlib.h> |
| 7 |
#include <string.h> |
| 8 |
#include "support/util.h" |
| 9 |
|
| 10 |
// clang-format off |
| 11 |
// CFF DICT Operators |
| 12 |
enum { |
| 13 |
op_version = 0x00, op_Copyright = 0x0c00, |
| 14 |
op_Notice = 0x01, op_isFixedPitch = 0x0c01, |
| 15 |
op_FullName = 0x02, op_ItalicAngle = 0x0c02, |
| 16 |
op_FamilyName = 0x03, op_UnderlinePosition = 0x0c03, |
| 17 |
op_Weight = 0x04, op_UnderlineThickness = 0x0c04, |
| 18 |
op_FontBBox = 0x05, op_PaintType = 0x0c05, |
| 19 |
op_BlueValues = 0x06, op_CharstringType = 0x0c06, |
| 20 |
op_OtherBlues = 0x07, op_FontMatrix = 0x0c07, |
| 21 |
op_FamilyBlues = 0x08, op_StrokeWidth = 0x0c08, |
| 22 |
op_FamilyOtherBlues = 0x09, op_BlueScale = 0x0c09, |
| 23 |
op_StdHW = 0x0a, op_BlueShift = 0x0c0a, |
| 24 |
op_StdVW = 0x0b, op_BlueFuzz = 0x0c0b, |
| 25 |
/* 0x0c escape */ op_StemSnapH = 0x0c0c, |
| 26 |
op_UniqueID = 0x0d, op_StemSnapV = 0x0c0d, |
| 27 |
op_XUID = 0x0e, op_ForceBold = 0x0c0e, |
| 28 |
op_charset = 0x0f, /* 0x0c0f Reserved */ |
| 29 |
op_Encoding = 0x10, /* 0x0c10 Reserved */ |
| 30 |
op_CharStrings = 0x11, op_LanguageGroup = 0x0c11, |
| 31 |
op_Private = 0x12, op_ExpansionFactor = 0x0c12, |
| 32 |
op_Subrs = 0x13, op_initialRandomSeed = 0x0c13, |
| 33 |
op_defaultWidthX = 0x14, op_SyntheicBase = 0x0c14, |
| 34 |
op_nominalWidthX = 0x15, op_PostScript = 0x0c15, |
| 35 |
op_vsindex = 0x16, op_BaseFontName = 0x0c16, |
| 36 |
op_blend = 0x17, op_BaseFontBlend = 0x0c17, |
| 37 |
op_vstore = 0x18, /* 0x0c18 Reserved */ |
| 38 |
op_maxstack = 0x19, /* 0x0c19 Reserved */ |
| 39 |
/* 0x0c1a Reserved */ |
| 40 |
/* 0x0c1b Reserved */ |
| 41 |
/* 0x0c1c Reserved */ |
| 42 |
/* 0x0c1d Reserved */ |
| 43 |
op_ROS = 0x0c1e, |
| 44 |
op_CIDFontVersion = 0x0c1f, |
| 45 |
op_CIDFontRevision = 0x0c20, |
| 46 |
op_CIDFontType = 0x0c21, |
| 47 |
op_CIDCount = 0x0c22, |
| 48 |
op_UIDBase = 0x0c23, |
| 49 |
op_FDArray = 0x0c24, |
| 50 |
op_FDSelect = 0x0c25, |
| 51 |
op_FontName = 0x0c26, |
| 52 |
}; |
| 53 |
|
| 54 |
// Type2 CharString Operators |
| 55 |
enum { |
| 56 |
/* 0x00 Reserved */ /* 0x0c00 Reserved */ |
| 57 |
op_hstem = 0x01, /* 0x0c01 Reserved */ |
| 58 |
/* 0x02 Reserved */ /* 0x0c02 Reserved */ |
| 59 |
op_vstem = 0x03, op_and = 0x0c03, |
| 60 |
op_vmoveto = 0x04, op_or = 0x0c04, |
| 61 |
op_rlineto = 0x05, op_not = 0x0c05, |
| 62 |
op_hlineto = 0x06, /* 0x0c06 Reserved */ |
| 63 |
op_vlineto = 0x07, /* 0x0c07 Reserved */ |
| 64 |
op_rrcurveto = 0x08, /* 0x0c08 Reserved */ |
| 65 |
/* 0x09 Reserved */ op_abs = 0x0c09, |
| 66 |
op_callsubr = 0x0a, op_add = 0x0c0a, |
| 67 |
op_return = 0x0b, op_sub = 0x0c0b, |
| 68 |
/* 0x0c escape */ op_div = 0x0c0c, |
| 69 |
/* 0x0d Reserved */ /* 0x0c0d Reserved */ |
| 70 |
op_endchar = 0x0e, op_neg = 0x0c0e, |
| 71 |
op_cff2vsidx = 0x0f, op_eq = 0x0c0f, |
| 72 |
op_cff2blend = 0x10, /* 0x0c10 Reserved */ |
| 73 |
/* 0x11 Reserved */ /* 0x0c11 Reserved */ |
| 74 |
op_hstemhm = 0x12, op_drop = 0x0c12, |
| 75 |
op_hintmask = 0x13, /* 0x0c13 Reserved */ |
| 76 |
op_cntrmask = 0x14, op_put = 0x0c14, |
| 77 |
op_rmoveto = 0x15, op_get = 0x0c15, |
| 78 |
op_hmoveto = 0x16, op_ifelse = 0x0c16, |
| 79 |
op_vstemhm = 0x17, op_random = 0x0c17, |
| 80 |
op_rcurveline = 0x18, op_mul = 0x0c18, |
| 81 |
op_rlinecurve = 0x19, /* 0x0c19 Reserved */ |
| 82 |
op_vvcurveto = 0x1a, op_sqrt = 0x0c1a, |
| 83 |
op_hhcurveto = 0x1b, op_dup = 0x0c1b, |
| 84 |
/* 0x1c short int */ op_exch = 0x0c1c, |
| 85 |
op_callgsubr = 0x1d, op_index = 0x0c1d, |
| 86 |
op_vhcurveto = 0x1e, op_roll = 0x0c1e, |
| 87 |
op_hvcurveto = 0x1f, /* 0x0c1f Reserved */ |
| 88 |
/* 0x0c20 Reserved */ |
| 89 |
/* 0x0c21 Reserved */ |
| 90 |
op_hflex = 0x0c22, |
| 91 |
op_flex = 0x0c23, |
| 92 |
op_hflex1 = 0x0c24, |
| 93 |
op_flex1 = 0x0c25, |
| 94 |
}; |
| 95 |
// clang-format on |
| 96 |
|
| 97 |
// parser util functions |
| 98 |
static INLINE uint32_t gu1(uint8_t *s, uint32_t p) { |
| 99 |
uint32_t b0 = *(s + p); |
| 100 |
return b0; |
| 101 |
} |
| 102 |
|
| 103 |
static INLINE uint32_t gu2(uint8_t *s, uint32_t p) { |
| 104 |
uint32_t b0 = *(s + p) << 8; |
| 105 |
uint32_t b1 = *(s + p + 1); |
| 106 |
return b0 | b1; |
| 107 |
} |
| 108 |
|
| 109 |
static INLINE uint32_t gu3(uint8_t *s, uint32_t p) { |
| 110 |
uint32_t b0 = *(s + p) << 16; |
| 111 |
uint32_t b1 = *(s + p + 1) << 8; |
| 112 |
uint32_t b2 = *(s + p + 2); |
| 113 |
return b0 | b1 | b2; |
| 114 |
} |
| 115 |
static INLINE uint32_t gu4(uint8_t *s, uint32_t p) { |
| 116 |
uint32_t b0 = *(s + p) << 24; |
| 117 |
uint32_t b1 = *(s + p + 1) << 16; |
| 118 |
uint32_t b2 = *(s + p + 2) << 8; |
| 119 |
uint32_t b3 = *(s + p + 3); |
| 120 |
return b0 | b1 | b2 | b3; |
| 121 |
} |
| 122 |
|
| 123 |
#endif |