1 | //======================================================================== |
2 | // |
3 | // BuiltinFont.h |
4 | // |
5 | // Copyright 2001-2003 Glyph & Cog, LLC |
6 | // |
7 | //======================================================================== |
8 | |
9 | //======================================================================== |
10 | // |
11 | // Modified under the Poppler project - http://poppler.freedesktop.org |
12 | // |
13 | // All changes made under the Poppler project to this file are licensed |
14 | // under GPL version 2 or later |
15 | // |
16 | // Copyright (C) 2018, 2020 Albert Astals Cid <aacid@kde.org> |
17 | // |
18 | // To see a description of the changes please see the Changelog file that |
19 | // came with your tarball or type make ChangeLog if you are building from git |
20 | // |
21 | //======================================================================== |
22 | |
23 | #ifndef BUILTINFONT_H |
24 | #define BUILTINFONT_H |
25 | |
26 | #include "BuiltinFontWidth.h" |
27 | |
28 | //------------------------------------------------------------------------ |
29 | |
30 | using GetWidthFunction = const BuiltinFontWidth *(*)(const char *str, size_t len); |
31 | |
32 | struct BuiltinFont |
33 | { |
34 | const char *name; |
35 | const char **defaultBaseEnc; |
36 | short ascent; |
37 | short descent; |
38 | short bbox[4]; |
39 | GetWidthFunction f; |
40 | |
41 | bool getWidth(const char *n, unsigned short *w) const |
42 | { |
43 | const struct BuiltinFontWidth *bfw = f(n, strlen(s: n)); |
44 | if (!bfw) { |
45 | return false; |
46 | } |
47 | |
48 | *w = bfw->width; |
49 | return true; |
50 | } |
51 | }; |
52 | |
53 | //------------------------------------------------------------------------ |
54 | |
55 | extern "C" { |
56 | // define the gperf generated Lookup functions |
57 | const struct BuiltinFontWidth *CourierWidthsLookup(const char *str, size_t len); |
58 | const struct BuiltinFontWidth *CourierBoldWidthsLookup(const char *str, size_t len); |
59 | const struct BuiltinFontWidth *CourierBoldObliqueWidthsLookup(const char *str, size_t len); |
60 | const struct BuiltinFontWidth *CourierObliqueWidthsLookup(const char *str, size_t len); |
61 | const struct BuiltinFontWidth *HelveticaWidthsLookup(const char *str, size_t len); |
62 | const struct BuiltinFontWidth *HelveticaBoldWidthsLookup(const char *str, size_t len); |
63 | const struct BuiltinFontWidth *HelveticaBoldObliqueWidthsLookup(const char *str, size_t len); |
64 | const struct BuiltinFontWidth *HelveticaObliqueWidthsLookup(const char *str, size_t len); |
65 | const struct BuiltinFontWidth *SymbolWidthsLookup(const char *str, size_t len); |
66 | const struct BuiltinFontWidth *TimesBoldWidthsLookup(const char *str, size_t len); |
67 | const struct BuiltinFontWidth *TimesBoldItalicWidthsLookup(const char *str, size_t len); |
68 | const struct BuiltinFontWidth *TimesItalicWidthsLookup(const char *str, size_t len); |
69 | const struct BuiltinFontWidth *TimesRomanWidthsLookup(const char *str, size_t len); |
70 | const struct BuiltinFontWidth *ZapfDingbatsWidthsLookup(const char *str, size_t len); |
71 | } |
72 | |
73 | static const BuiltinFont builtinFonts[] = { { .name: "Courier" , .defaultBaseEnc: standardEncoding, .ascent: 629, .descent: -157, .bbox: { -23, -250, 715, 805 }, .f: &CourierWidthsLookup }, |
74 | { .name: "Courier-Bold" , .defaultBaseEnc: standardEncoding, .ascent: 629, .descent: -157, .bbox: { -113, -250, 749, 801 }, .f: &CourierBoldWidthsLookup }, |
75 | { .name: "Courier-BoldOblique" , .defaultBaseEnc: standardEncoding, .ascent: 629, .descent: -157, .bbox: { -57, -250, 869, 801 }, .f: &CourierBoldObliqueWidthsLookup }, |
76 | { .name: "Courier-Oblique" , .defaultBaseEnc: standardEncoding, .ascent: 629, .descent: -157, .bbox: { -27, -250, 849, 805 }, .f: &CourierObliqueWidthsLookup }, |
77 | { .name: "Helvetica" , .defaultBaseEnc: standardEncoding, .ascent: 718, .descent: -207, .bbox: { -166, -225, 1000, 931 }, .f: &HelveticaWidthsLookup }, |
78 | { .name: "Helvetica-Bold" , .defaultBaseEnc: standardEncoding, .ascent: 718, .descent: -207, .bbox: { -170, -228, 1003, 962 }, .f: &HelveticaBoldWidthsLookup }, |
79 | { .name: "Helvetica-BoldOblique" , .defaultBaseEnc: standardEncoding, .ascent: 718, .descent: -207, .bbox: { -174, -228, 1114, 962 }, .f: &HelveticaBoldObliqueWidthsLookup }, |
80 | { .name: "Helvetica-Oblique" , .defaultBaseEnc: standardEncoding, .ascent: 718, .descent: -207, .bbox: { -170, -225, 1116, 931 }, .f: &HelveticaObliqueWidthsLookup }, |
81 | { .name: "Symbol" , .defaultBaseEnc: symbolEncoding, .ascent: 1010, .descent: -293, .bbox: { -180, -293, 1090, 1010 }, .f: &SymbolWidthsLookup }, |
82 | { .name: "Times-Bold" , .defaultBaseEnc: standardEncoding, .ascent: 683, .descent: -217, .bbox: { -168, -218, 1000, 935 }, .f: &TimesBoldWidthsLookup }, |
83 | { .name: "Times-BoldItalic" , .defaultBaseEnc: standardEncoding, .ascent: 683, .descent: -217, .bbox: { -200, -218, 996, 921 }, .f: &TimesBoldItalicWidthsLookup }, |
84 | { .name: "Times-Italic" , .defaultBaseEnc: standardEncoding, .ascent: 683, .descent: -217, .bbox: { -169, -217, 1010, 883 }, .f: &TimesItalicWidthsLookup }, |
85 | { .name: "Times-Roman" , .defaultBaseEnc: standardEncoding, .ascent: 683, .descent: -217, .bbox: { -168, -218, 1000, 898 }, .f: &TimesRomanWidthsLookup }, |
86 | { .name: "ZapfDingbats" , .defaultBaseEnc: zapfDingbatsEncoding, .ascent: 820, .descent: -143, .bbox: { -1, -143, 981, 820 }, .f: &ZapfDingbatsWidthsLookup } }; |
87 | |
88 | static const BuiltinFont *builtinFontSubst[] = { &builtinFonts[0], &builtinFonts[3], &builtinFonts[1], &builtinFonts[2], &builtinFonts[4], &builtinFonts[7], |
89 | &builtinFonts[5], &builtinFonts[6], &builtinFonts[12], &builtinFonts[11], &builtinFonts[9], &builtinFonts[10] }; |
90 | |
91 | //------------------------------------------------------------------------ |
92 | |
93 | #endif |
94 | |