github.com/pdfcpu/pdfcpu@v0.11.1/internal/corefont/metrics/metrics.go (about) 1 /* 2 Copyright 2018 The pdfcpu Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Package metrics provides font metrics for the PDF standard fonts. 18 package metrics 19 20 // The PostScript names of the 14 Type 1 fonts, aka the PDF core font set, are as follows: 21 // 22 // Times-Roman, 23 // Helvetica, 24 // Courier, 25 // Symbol, 26 // Times-Bold, 27 // Helvetica-Bold, 28 // Courier-Bold, 29 // ZapfDingbats, 30 // Times-Italic, 31 // Helvetica- Oblique, 32 // Courier-Oblique, 33 // Times-BoldItalic, 34 // Helvetica-BoldOblique, 35 // Courier-BoldOblique 36 37 // CoreFontCharWidth returns the character width for fontName and c in glyph space units. 38 func CoreFontCharWidth(fontName string, c int) int { 39 var m map[int]string 40 switch fontName { 41 case "Symbol": 42 m = SymbolGlyphMap 43 case "ZapfDingbats": 44 m = ZapfDingbatsGlyphMap 45 default: 46 m = WinAnsiGlyphMap 47 } 48 glyphName := m[c] 49 fm := CoreFontMetrics[fontName] 50 w, ok := fm.W[glyphName] 51 if !ok { 52 w = 1000 //m.W["bullet"] 53 } 54 return w 55 }