| 1 |
/* |
| 2 |
operator to string. |
| 3 |
*/ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <string.h> |
| 9 |
|
| 10 |
#include "libcff.h" |
| 11 |
|
| 12 |
const char *op_cff_name(uint32_t op) { |
| 13 |
switch (op) { |
| 14 |
case op_version: |
| 15 |
return "Version"; |
| 16 |
case op_Notice: |
| 17 |
return "Notice"; |
| 18 |
case op_FullName: |
| 19 |
return "FullName"; |
| 20 |
case op_FamilyName: |
| 21 |
return "FamilyName"; |
| 22 |
case op_Weight: |
| 23 |
return "Weight"; |
| 24 |
case op_FontBBox: |
| 25 |
return "FontBBox"; |
| 26 |
case op_BlueValues: |
| 27 |
return "BlueValues"; |
| 28 |
case op_OtherBlues: |
| 29 |
return "OtherBlues"; |
| 30 |
case op_FamilyBlues: |
| 31 |
return "FamilyBlues"; |
| 32 |
case op_FamilyOtherBlues: |
| 33 |
return "FamilyOtherBlues"; |
| 34 |
case op_StdHW: |
| 35 |
return "StdHW"; |
| 36 |
case op_StdVW: |
| 37 |
return "StdVW"; |
| 38 |
case op_UniqueID: |
| 39 |
return "UniqueID"; |
| 40 |
case op_XUID: |
| 41 |
return "XUID"; |
| 42 |
case op_charset: |
| 43 |
return "charset"; |
| 44 |
case op_Encoding: |
| 45 |
return "Encoding"; |
| 46 |
case op_CharStrings: |
| 47 |
return "CharStrings"; |
| 48 |
case op_Private: |
| 49 |
return "Private"; |
| 50 |
case op_Subrs: |
| 51 |
return "Subrs"; |
| 52 |
case op_defaultWidthX: |
| 53 |
return "defaultWidthX"; |
| 54 |
case op_nominalWidthX: |
| 55 |
return "nominalWidthX"; |
| 56 |
case op_Copyright: |
| 57 |
return "Copyright"; |
| 58 |
case op_isFixedPitch: |
| 59 |
return "isFixedPitch"; |
| 60 |
case op_ItalicAngle: |
| 61 |
return "ItalicAngle"; |
| 62 |
case op_UnderlinePosition: |
| 63 |
return "UnderlinePosition"; |
| 64 |
case op_UnderlineThickness: |
| 65 |
return "UnderlineThickness"; |
| 66 |
case op_PaintType: |
| 67 |
return "PaintType"; |
| 68 |
case op_CharstringType: |
| 69 |
return "CharstringType"; |
| 70 |
case op_FontMatrix: |
| 71 |
return "FontMatrix"; |
| 72 |
case op_StrokeWidth: |
| 73 |
return "StrokeWidth"; |
| 74 |
case op_BlueScale: |
| 75 |
return "BlueScale"; |
| 76 |
case op_BlueShift: |
| 77 |
return "BlueShift"; |
| 78 |
case op_BlueFuzz: |
| 79 |
return "BlueFuzz"; |
| 80 |
case op_StemSnapH: |
| 81 |
return "StemSnapH"; |
| 82 |
case op_StemSnapV: |
| 83 |
return "StemSnapV"; |
| 84 |
case op_ForceBold: |
| 85 |
return "ForceBold"; |
| 86 |
case op_LanguageGroup: |
| 87 |
return "LanguageGroup"; |
| 88 |
case op_ExpansionFactor: |
| 89 |
return "ExpansionFactor"; |
| 90 |
case op_initialRandomSeed: |
| 91 |
return "initialRandomSeed"; |
| 92 |
case op_SyntheicBase: |
| 93 |
return "SyntheicBase"; |
| 94 |
case op_PostScript: |
| 95 |
return "PostScript"; |
| 96 |
case op_BaseFontName: |
| 97 |
return "BaseFontName"; |
| 98 |
case op_BaseFontBlend: |
| 99 |
return "BaseFontBlend"; |
| 100 |
case op_ROS: |
| 101 |
return "ROS"; |
| 102 |
case op_CIDFontVersion: |
| 103 |
return "CIDFontVersion"; |
| 104 |
case op_CIDFontRevision: |
| 105 |
return "CIDFontReversion"; |
| 106 |
case op_CIDFontType: |
| 107 |
return "CIDFontType"; |
| 108 |
case op_CIDCount: |
| 109 |
return "CIDCount"; |
| 110 |
case op_UIDBase: |
| 111 |
return "UIDBase"; |
| 112 |
case op_FDArray: |
| 113 |
return "FDArray"; |
| 114 |
case op_FDSelect: |
| 115 |
return "FDSelect"; |
| 116 |
case op_FontName: |
| 117 |
return "FontName"; |
| 118 |
default: |
| 119 |
return "Unkown"; |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
const char *op_cs2_name(uint32_t op) { |
| 124 |
switch (op) { |
| 125 |
case op_hstem: |
| 126 |
return "hstem"; |
| 127 |
case op_vstem: |
| 128 |
return "vstem"; |
| 129 |
case op_vmoveto: |
| 130 |
return "vmoveto"; |
| 131 |
case op_rlineto: |
| 132 |
return "rlineto"; |
| 133 |
case op_hlineto: |
| 134 |
return "hlineto"; |
| 135 |
case op_vlineto: |
| 136 |
return "vlineto"; |
| 137 |
case op_rrcurveto: |
| 138 |
return "rrcurveto"; |
| 139 |
case op_callsubr: |
| 140 |
return "callsubr"; |
| 141 |
case op_return: |
| 142 |
return "return"; |
| 143 |
case op_endchar: |
| 144 |
return "endchar"; |
| 145 |
case op_hstemhm: |
| 146 |
return "hstemhm"; |
| 147 |
case op_hintmask: |
| 148 |
return "hintmask"; |
| 149 |
case op_cntrmask: |
| 150 |
return "cntrmask"; |
| 151 |
case op_rmoveto: |
| 152 |
return "rmoveto"; |
| 153 |
case op_hmoveto: |
| 154 |
return "hmoveto"; |
| 155 |
case op_vstemhm: |
| 156 |
return "vstemhm"; |
| 157 |
case op_rcurveline: |
| 158 |
return "rcurveline"; |
| 159 |
case op_rlinecurve: |
| 160 |
return "rlinecurve"; |
| 161 |
case op_vvcurveto: |
| 162 |
return "vvcurveto"; |
| 163 |
case op_hhcurveto: |
| 164 |
return "hhcurveto"; |
| 165 |
case op_callgsubr: |
| 166 |
return "callgsubr"; |
| 167 |
case op_vhcurveto: |
| 168 |
return "vhcurveto"; |
| 169 |
case op_hvcurveto: |
| 170 |
return "hvcurveto"; |
| 171 |
case op_and: |
| 172 |
return "and"; |
| 173 |
case op_or: |
| 174 |
return "or"; |
| 175 |
case op_not: |
| 176 |
return "not"; |
| 177 |
case op_abs: |
| 178 |
return "abs"; |
| 179 |
case op_add: |
| 180 |
return "add"; |
| 181 |
case op_sub: |
| 182 |
return "sub"; |
| 183 |
case op_div: |
| 184 |
return "div"; |
| 185 |
case op_neg: |
| 186 |
return "neg"; |
| 187 |
case op_eq: |
| 188 |
return "eq"; |
| 189 |
case op_drop: |
| 190 |
return "drop"; |
| 191 |
case op_put: |
| 192 |
return "put"; |
| 193 |
case op_get: |
| 194 |
return "get"; |
| 195 |
case op_ifelse: |
| 196 |
return "ifelse"; |
| 197 |
case op_random: |
| 198 |
return "random"; |
| 199 |
case op_mul: |
| 200 |
return "mul"; |
| 201 |
case op_sqrt: |
| 202 |
return "sqrt"; |
| 203 |
case op_dup: |
| 204 |
return "dup"; |
| 205 |
case op_exch: |
| 206 |
return "exch"; |
| 207 |
case op_index: |
| 208 |
return "index"; |
| 209 |
case op_roll: |
| 210 |
return "roll"; |
| 211 |
case op_hflex: |
| 212 |
return "hflex"; |
| 213 |
case op_flex: |
| 214 |
return "fles"; |
| 215 |
case op_hflex1: |
| 216 |
return "hflex1"; |
| 217 |
case op_flex1: |
| 218 |
return "flex1"; |
| 219 |
default: |
| 220 |
return "Unknown"; |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
uint8_t cff_getStandardArity(uint32_t op) { |
| 225 |
switch (op) { |
| 226 |
case op_rlineto: |
| 227 |
case op_rmoveto: |
| 228 |
return 2; |
| 229 |
case op_hlineto: |
| 230 |
case op_vlineto: |
| 231 |
return 1; |
| 232 |
case op_hhcurveto: |
| 233 |
case op_vvcurveto: |
| 234 |
case op_hvcurveto: |
| 235 |
case op_vhcurveto: |
| 236 |
return 4; |
| 237 |
case op_rrcurveto: |
| 238 |
return 6; |
| 239 |
case op_hintmask: |
| 240 |
case op_cntrmask: |
| 241 |
return 0; |
| 242 |
default: |
| 243 |
return 2; |
| 244 |
} |
| 245 |
} |