github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/model/fonts/symbol.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 /* 6 * The embedded character metrics specified in this file are distributed under the terms listed in 7 * ./afms/MustRead.html. 8 */ 9 10 package fonts 11 12 import ( 13 "github.com/unidoc/unidoc/pdf/core" 14 "github.com/unidoc/unidoc/pdf/model/textencoding" 15 ) 16 17 // Font Symbol. Implements Font interface. 18 // This is a built-in font and it is assumed that every reader has access to it. 19 type fontSymbol struct { 20 // By default encoder is not set, which means that we use the font's built in encoding. 21 encoder textencoding.TextEncoder 22 } 23 24 func NewFontSymbol() fontSymbol { 25 font := fontSymbol{} 26 return font 27 } 28 29 func (font fontSymbol) SetEncoder(encoder textencoding.TextEncoder) { 30 font.encoder = encoder 31 } 32 33 func (font fontSymbol) GetGlyphCharMetrics(glyph string) (CharMetrics, bool) { 34 metrics, has := symbolCharMetrics[glyph] 35 if !has { 36 return metrics, false 37 } 38 39 return metrics, true 40 } 41 42 func (font fontSymbol) ToPdfObject() core.PdfObject { 43 obj := &core.PdfIndirectObject{} 44 45 fontDict := core.MakeDict() 46 fontDict.Set("Type", core.MakeName("Font")) 47 fontDict.Set("Subtype", core.MakeName("Type1")) 48 fontDict.Set("BaseFont", core.MakeName("Symbol")) 49 if font.encoder != nil { 50 fontDict.Set("Encoding", font.encoder.ToPdfObject()) 51 } 52 53 obj.PdfObject = fontDict 54 return obj 55 } 56 57 // Symbol font metics loaded from afms/Symbol.afm. See afms/MustRead.html for license information. 58 var symbolCharMetrics map[string]CharMetrics = map[string]CharMetrics{ 59 "Alpha": {GlyphName: "Alpha", Wx: 722.000000, Wy: 0.000000}, 60 "Beta": {GlyphName: "Beta", Wx: 667.000000, Wy: 0.000000}, 61 "Chi": {GlyphName: "Chi", Wx: 722.000000, Wy: 0.000000}, 62 "Delta": {GlyphName: "Delta", Wx: 612.000000, Wy: 0.000000}, 63 "Epsilon": {GlyphName: "Epsilon", Wx: 611.000000, Wy: 0.000000}, 64 "Eta": {GlyphName: "Eta", Wx: 722.000000, Wy: 0.000000}, 65 "Euro": {GlyphName: "Euro", Wx: 750.000000, Wy: 0.000000}, 66 "Gamma": {GlyphName: "Gamma", Wx: 603.000000, Wy: 0.000000}, 67 "Ifraktur": {GlyphName: "Ifraktur", Wx: 686.000000, Wy: 0.000000}, 68 "Iota": {GlyphName: "Iota", Wx: 333.000000, Wy: 0.000000}, 69 "Kappa": {GlyphName: "Kappa", Wx: 722.000000, Wy: 0.000000}, 70 "Lambda": {GlyphName: "Lambda", Wx: 686.000000, Wy: 0.000000}, 71 "Mu": {GlyphName: "Mu", Wx: 889.000000, Wy: 0.000000}, 72 "Nu": {GlyphName: "Nu", Wx: 722.000000, Wy: 0.000000}, 73 "Omega": {GlyphName: "Omega", Wx: 768.000000, Wy: 0.000000}, 74 "Omicron": {GlyphName: "Omicron", Wx: 722.000000, Wy: 0.000000}, 75 "Phi": {GlyphName: "Phi", Wx: 763.000000, Wy: 0.000000}, 76 "Pi": {GlyphName: "Pi", Wx: 768.000000, Wy: 0.000000}, 77 "Psi": {GlyphName: "Psi", Wx: 795.000000, Wy: 0.000000}, 78 "Rfraktur": {GlyphName: "Rfraktur", Wx: 795.000000, Wy: 0.000000}, 79 "Rho": {GlyphName: "Rho", Wx: 556.000000, Wy: 0.000000}, 80 "Sigma": {GlyphName: "Sigma", Wx: 592.000000, Wy: 0.000000}, 81 "Tau": {GlyphName: "Tau", Wx: 611.000000, Wy: 0.000000}, 82 "Theta": {GlyphName: "Theta", Wx: 741.000000, Wy: 0.000000}, 83 "Upsilon": {GlyphName: "Upsilon", Wx: 690.000000, Wy: 0.000000}, 84 "Upsilon1": {GlyphName: "Upsilon1", Wx: 620.000000, Wy: 0.000000}, 85 "Xi": {GlyphName: "Xi", Wx: 645.000000, Wy: 0.000000}, 86 "Zeta": {GlyphName: "Zeta", Wx: 611.000000, Wy: 0.000000}, 87 "aleph": {GlyphName: "aleph", Wx: 823.000000, Wy: 0.000000}, 88 "alpha": {GlyphName: "alpha", Wx: 631.000000, Wy: 0.000000}, 89 "ampersand": {GlyphName: "ampersand", Wx: 778.000000, Wy: 0.000000}, 90 "angle": {GlyphName: "angle", Wx: 768.000000, Wy: 0.000000}, 91 "angleleft": {GlyphName: "angleleft", Wx: 329.000000, Wy: 0.000000}, 92 "angleright": {GlyphName: "angleright", Wx: 329.000000, Wy: 0.000000}, 93 "apple": {GlyphName: "apple", Wx: 790.000000, Wy: 0.000000}, 94 "approxequal": {GlyphName: "approxequal", Wx: 549.000000, Wy: 0.000000}, 95 "arrowboth": {GlyphName: "arrowboth", Wx: 1042.000000, Wy: 0.000000}, 96 "arrowdblboth": {GlyphName: "arrowdblboth", Wx: 1042.000000, Wy: 0.000000}, 97 "arrowdbldown": {GlyphName: "arrowdbldown", Wx: 603.000000, Wy: 0.000000}, 98 "arrowdblleft": {GlyphName: "arrowdblleft", Wx: 987.000000, Wy: 0.000000}, 99 "arrowdblright": {GlyphName: "arrowdblright", Wx: 987.000000, Wy: 0.000000}, 100 "arrowdblup": {GlyphName: "arrowdblup", Wx: 603.000000, Wy: 0.000000}, 101 "arrowdown": {GlyphName: "arrowdown", Wx: 603.000000, Wy: 0.000000}, 102 "arrowhorizex": {GlyphName: "arrowhorizex", Wx: 1000.000000, Wy: 0.000000}, 103 "arrowleft": {GlyphName: "arrowleft", Wx: 987.000000, Wy: 0.000000}, 104 "arrowright": {GlyphName: "arrowright", Wx: 987.000000, Wy: 0.000000}, 105 "arrowup": {GlyphName: "arrowup", Wx: 603.000000, Wy: 0.000000}, 106 "arrowvertex": {GlyphName: "arrowvertex", Wx: 603.000000, Wy: 0.000000}, 107 "asteriskmath": {GlyphName: "asteriskmath", Wx: 500.000000, Wy: 0.000000}, 108 "bar": {GlyphName: "bar", Wx: 200.000000, Wy: 0.000000}, 109 "beta": {GlyphName: "beta", Wx: 549.000000, Wy: 0.000000}, 110 "braceex": {GlyphName: "braceex", Wx: 494.000000, Wy: 0.000000}, 111 "braceleft": {GlyphName: "braceleft", Wx: 480.000000, Wy: 0.000000}, 112 "braceleftbt": {GlyphName: "braceleftbt", Wx: 494.000000, Wy: 0.000000}, 113 "braceleftmid": {GlyphName: "braceleftmid", Wx: 494.000000, Wy: 0.000000}, 114 "bracelefttp": {GlyphName: "bracelefttp", Wx: 494.000000, Wy: 0.000000}, 115 "braceright": {GlyphName: "braceright", Wx: 480.000000, Wy: 0.000000}, 116 "bracerightbt": {GlyphName: "bracerightbt", Wx: 494.000000, Wy: 0.000000}, 117 "bracerightmid": {GlyphName: "bracerightmid", Wx: 494.000000, Wy: 0.000000}, 118 "bracerighttp": {GlyphName: "bracerighttp", Wx: 494.000000, Wy: 0.000000}, 119 "bracketleft": {GlyphName: "bracketleft", Wx: 333.000000, Wy: 0.000000}, 120 "bracketleftbt": {GlyphName: "bracketleftbt", Wx: 384.000000, Wy: 0.000000}, 121 "bracketleftex": {GlyphName: "bracketleftex", Wx: 384.000000, Wy: 0.000000}, 122 "bracketlefttp": {GlyphName: "bracketlefttp", Wx: 384.000000, Wy: 0.000000}, 123 "bracketright": {GlyphName: "bracketright", Wx: 333.000000, Wy: 0.000000}, 124 "bracketrightbt": {GlyphName: "bracketrightbt", Wx: 384.000000, Wy: 0.000000}, 125 "bracketrightex": {GlyphName: "bracketrightex", Wx: 384.000000, Wy: 0.000000}, 126 "bracketrighttp": {GlyphName: "bracketrighttp", Wx: 384.000000, Wy: 0.000000}, 127 "bullet": {GlyphName: "bullet", Wx: 460.000000, Wy: 0.000000}, 128 "carriagereturn": {GlyphName: "carriagereturn", Wx: 658.000000, Wy: 0.000000}, 129 "chi": {GlyphName: "chi", Wx: 549.000000, Wy: 0.000000}, 130 "circlemultiply": {GlyphName: "circlemultiply", Wx: 768.000000, Wy: 0.000000}, 131 "circleplus": {GlyphName: "circleplus", Wx: 768.000000, Wy: 0.000000}, 132 "club": {GlyphName: "club", Wx: 753.000000, Wy: 0.000000}, 133 "colon": {GlyphName: "colon", Wx: 278.000000, Wy: 0.000000}, 134 "comma": {GlyphName: "comma", Wx: 250.000000, Wy: 0.000000}, 135 "congruent": {GlyphName: "congruent", Wx: 549.000000, Wy: 0.000000}, 136 "copyrightsans": {GlyphName: "copyrightsans", Wx: 790.000000, Wy: 0.000000}, 137 "copyrightserif": {GlyphName: "copyrightserif", Wx: 790.000000, Wy: 0.000000}, 138 "degree": {GlyphName: "degree", Wx: 400.000000, Wy: 0.000000}, 139 "delta": {GlyphName: "delta", Wx: 494.000000, Wy: 0.000000}, 140 "diamond": {GlyphName: "diamond", Wx: 753.000000, Wy: 0.000000}, 141 "divide": {GlyphName: "divide", Wx: 549.000000, Wy: 0.000000}, 142 "dotmath": {GlyphName: "dotmath", Wx: 250.000000, Wy: 0.000000}, 143 "eight": {GlyphName: "eight", Wx: 500.000000, Wy: 0.000000}, 144 "element": {GlyphName: "element", Wx: 713.000000, Wy: 0.000000}, 145 "ellipsis": {GlyphName: "ellipsis", Wx: 1000.000000, Wy: 0.000000}, 146 "emptyset": {GlyphName: "emptyset", Wx: 823.000000, Wy: 0.000000}, 147 "epsilon": {GlyphName: "epsilon", Wx: 439.000000, Wy: 0.000000}, 148 "equal": {GlyphName: "equal", Wx: 549.000000, Wy: 0.000000}, 149 "equivalence": {GlyphName: "equivalence", Wx: 549.000000, Wy: 0.000000}, 150 "eta": {GlyphName: "eta", Wx: 603.000000, Wy: 0.000000}, 151 "exclam": {GlyphName: "exclam", Wx: 333.000000, Wy: 0.000000}, 152 "existential": {GlyphName: "existential", Wx: 549.000000, Wy: 0.000000}, 153 "five": {GlyphName: "five", Wx: 500.000000, Wy: 0.000000}, 154 "florin": {GlyphName: "florin", Wx: 500.000000, Wy: 0.000000}, 155 "four": {GlyphName: "four", Wx: 500.000000, Wy: 0.000000}, 156 "fraction": {GlyphName: "fraction", Wx: 167.000000, Wy: 0.000000}, 157 "gamma": {GlyphName: "gamma", Wx: 411.000000, Wy: 0.000000}, 158 "gradient": {GlyphName: "gradient", Wx: 713.000000, Wy: 0.000000}, 159 "greater": {GlyphName: "greater", Wx: 549.000000, Wy: 0.000000}, 160 "greaterequal": {GlyphName: "greaterequal", Wx: 549.000000, Wy: 0.000000}, 161 "heart": {GlyphName: "heart", Wx: 753.000000, Wy: 0.000000}, 162 "infinity": {GlyphName: "infinity", Wx: 713.000000, Wy: 0.000000}, 163 "integral": {GlyphName: "integral", Wx: 274.000000, Wy: 0.000000}, 164 "integralbt": {GlyphName: "integralbt", Wx: 686.000000, Wy: 0.000000}, 165 "integralex": {GlyphName: "integralex", Wx: 686.000000, Wy: 0.000000}, 166 "integraltp": {GlyphName: "integraltp", Wx: 686.000000, Wy: 0.000000}, 167 "intersection": {GlyphName: "intersection", Wx: 768.000000, Wy: 0.000000}, 168 "iota": {GlyphName: "iota", Wx: 329.000000, Wy: 0.000000}, 169 "kappa": {GlyphName: "kappa", Wx: 549.000000, Wy: 0.000000}, 170 "lambda": {GlyphName: "lambda", Wx: 549.000000, Wy: 0.000000}, 171 "less": {GlyphName: "less", Wx: 549.000000, Wy: 0.000000}, 172 "lessequal": {GlyphName: "lessequal", Wx: 549.000000, Wy: 0.000000}, 173 "logicaland": {GlyphName: "logicaland", Wx: 603.000000, Wy: 0.000000}, 174 "logicalnot": {GlyphName: "logicalnot", Wx: 713.000000, Wy: 0.000000}, 175 "logicalor": {GlyphName: "logicalor", Wx: 603.000000, Wy: 0.000000}, 176 "lozenge": {GlyphName: "lozenge", Wx: 494.000000, Wy: 0.000000}, 177 "minus": {GlyphName: "minus", Wx: 549.000000, Wy: 0.000000}, 178 "minute": {GlyphName: "minute", Wx: 247.000000, Wy: 0.000000}, 179 "mu": {GlyphName: "mu", Wx: 576.000000, Wy: 0.000000}, 180 "multiply": {GlyphName: "multiply", Wx: 549.000000, Wy: 0.000000}, 181 "nine": {GlyphName: "nine", Wx: 500.000000, Wy: 0.000000}, 182 "notelement": {GlyphName: "notelement", Wx: 713.000000, Wy: 0.000000}, 183 "notequal": {GlyphName: "notequal", Wx: 549.000000, Wy: 0.000000}, 184 "notsubset": {GlyphName: "notsubset", Wx: 713.000000, Wy: 0.000000}, 185 "nu": {GlyphName: "nu", Wx: 521.000000, Wy: 0.000000}, 186 "numbersign": {GlyphName: "numbersign", Wx: 500.000000, Wy: 0.000000}, 187 "omega": {GlyphName: "omega", Wx: 686.000000, Wy: 0.000000}, 188 "omega1": {GlyphName: "omega1", Wx: 713.000000, Wy: 0.000000}, 189 "omicron": {GlyphName: "omicron", Wx: 549.000000, Wy: 0.000000}, 190 "one": {GlyphName: "one", Wx: 500.000000, Wy: 0.000000}, 191 "parenleft": {GlyphName: "parenleft", Wx: 333.000000, Wy: 0.000000}, 192 "parenleftbt": {GlyphName: "parenleftbt", Wx: 384.000000, Wy: 0.000000}, 193 "parenleftex": {GlyphName: "parenleftex", Wx: 384.000000, Wy: 0.000000}, 194 "parenlefttp": {GlyphName: "parenlefttp", Wx: 384.000000, Wy: 0.000000}, 195 "parenright": {GlyphName: "parenright", Wx: 333.000000, Wy: 0.000000}, 196 "parenrightbt": {GlyphName: "parenrightbt", Wx: 384.000000, Wy: 0.000000}, 197 "parenrightex": {GlyphName: "parenrightex", Wx: 384.000000, Wy: 0.000000}, 198 "parenrighttp": {GlyphName: "parenrighttp", Wx: 384.000000, Wy: 0.000000}, 199 "partialdiff": {GlyphName: "partialdiff", Wx: 494.000000, Wy: 0.000000}, 200 "percent": {GlyphName: "percent", Wx: 833.000000, Wy: 0.000000}, 201 "period": {GlyphName: "period", Wx: 250.000000, Wy: 0.000000}, 202 "perpendicular": {GlyphName: "perpendicular", Wx: 658.000000, Wy: 0.000000}, 203 "phi": {GlyphName: "phi", Wx: 521.000000, Wy: 0.000000}, 204 "phi1": {GlyphName: "phi1", Wx: 603.000000, Wy: 0.000000}, 205 "pi": {GlyphName: "pi", Wx: 549.000000, Wy: 0.000000}, 206 "plus": {GlyphName: "plus", Wx: 549.000000, Wy: 0.000000}, 207 "plusminus": {GlyphName: "plusminus", Wx: 549.000000, Wy: 0.000000}, 208 "product": {GlyphName: "product", Wx: 823.000000, Wy: 0.000000}, 209 "propersubset": {GlyphName: "propersubset", Wx: 713.000000, Wy: 0.000000}, 210 "propersuperset": {GlyphName: "propersuperset", Wx: 713.000000, Wy: 0.000000}, 211 "proportional": {GlyphName: "proportional", Wx: 713.000000, Wy: 0.000000}, 212 "psi": {GlyphName: "psi", Wx: 686.000000, Wy: 0.000000}, 213 "question": {GlyphName: "question", Wx: 444.000000, Wy: 0.000000}, 214 "radical": {GlyphName: "radical", Wx: 549.000000, Wy: 0.000000}, 215 "radicalex": {GlyphName: "radicalex", Wx: 500.000000, Wy: 0.000000}, 216 "reflexsubset": {GlyphName: "reflexsubset", Wx: 713.000000, Wy: 0.000000}, 217 "reflexsuperset": {GlyphName: "reflexsuperset", Wx: 713.000000, Wy: 0.000000}, 218 "registersans": {GlyphName: "registersans", Wx: 790.000000, Wy: 0.000000}, 219 "registerserif": {GlyphName: "registerserif", Wx: 790.000000, Wy: 0.000000}, 220 "rho": {GlyphName: "rho", Wx: 549.000000, Wy: 0.000000}, 221 "second": {GlyphName: "second", Wx: 411.000000, Wy: 0.000000}, 222 "semicolon": {GlyphName: "semicolon", Wx: 278.000000, Wy: 0.000000}, 223 "seven": {GlyphName: "seven", Wx: 500.000000, Wy: 0.000000}, 224 "sigma": {GlyphName: "sigma", Wx: 603.000000, Wy: 0.000000}, 225 "sigma1": {GlyphName: "sigma1", Wx: 439.000000, Wy: 0.000000}, 226 "similar": {GlyphName: "similar", Wx: 549.000000, Wy: 0.000000}, 227 "six": {GlyphName: "six", Wx: 500.000000, Wy: 0.000000}, 228 "slash": {GlyphName: "slash", Wx: 278.000000, Wy: 0.000000}, 229 "space": {GlyphName: "space", Wx: 250.000000, Wy: 0.000000}, 230 "spade": {GlyphName: "spade", Wx: 753.000000, Wy: 0.000000}, 231 "suchthat": {GlyphName: "suchthat", Wx: 439.000000, Wy: 0.000000}, 232 "summation": {GlyphName: "summation", Wx: 713.000000, Wy: 0.000000}, 233 "tau": {GlyphName: "tau", Wx: 439.000000, Wy: 0.000000}, 234 "therefore": {GlyphName: "therefore", Wx: 863.000000, Wy: 0.000000}, 235 "theta": {GlyphName: "theta", Wx: 521.000000, Wy: 0.000000}, 236 "theta1": {GlyphName: "theta1", Wx: 631.000000, Wy: 0.000000}, 237 "three": {GlyphName: "three", Wx: 500.000000, Wy: 0.000000}, 238 "trademarksans": {GlyphName: "trademarksans", Wx: 786.000000, Wy: 0.000000}, 239 "trademarkserif": {GlyphName: "trademarkserif", Wx: 890.000000, Wy: 0.000000}, 240 "two": {GlyphName: "two", Wx: 500.000000, Wy: 0.000000}, 241 "underscore": {GlyphName: "underscore", Wx: 500.000000, Wy: 0.000000}, 242 "union": {GlyphName: "union", Wx: 768.000000, Wy: 0.000000}, 243 "universal": {GlyphName: "universal", Wx: 713.000000, Wy: 0.000000}, 244 "upsilon": {GlyphName: "upsilon", Wx: 576.000000, Wy: 0.000000}, 245 "weierstrass": {GlyphName: "weierstrass", Wx: 987.000000, Wy: 0.000000}, 246 "xi": {GlyphName: "xi", Wx: 493.000000, Wy: 0.000000}, 247 "zero": {GlyphName: "zero", Wx: 500.000000, Wy: 0.000000}, 248 "zeta": {GlyphName: "zeta", Wx: 494.000000, Wy: 0.000000}, 249 }