author | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
commit | 98a1e3f36567639344f12932b629e526a8783aa8 (patch) (unidiff) | |
tree | 0433d296857faceeafc54f7deabddb621f45a933 /noncore/unsupported/qpdf/xpdf/BuiltinFont.cc | |
parent | 7e31b1fba119f69929d6744d7295555ff1727f4f (diff) | |
download | opie-98a1e3f36567639344f12932b629e526a8783aa8.zip opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.gz opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.bz2 |
CVS import of QPdf
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/BuiltinFont.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/BuiltinFont.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/BuiltinFont.cc b/noncore/unsupported/qpdf/xpdf/BuiltinFont.cc new file mode 100644 index 0000000..a8cef7b --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/BuiltinFont.cc | |||
@@ -0,0 +1,64 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // BuiltinFont.cc | ||
4 | // | ||
5 | // Copyright 2001 Derek B. Noonburg | ||
6 | // | ||
7 | //======================================================================== | ||
8 | |||
9 | #ifdef __GNUC__ | ||
10 | #pragma implementation | ||
11 | #endif | ||
12 | |||
13 | #include <aconf.h> | ||
14 | #include <stdlib.h> | ||
15 | #include <string.h> | ||
16 | #include "gmem.h" | ||
17 | #include "FontEncodingTables.h" | ||
18 | #include "BuiltinFont.h" | ||
19 | |||
20 | //------------------------------------------------------------------------ | ||
21 | |||
22 | BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) { | ||
23 | int i, h; | ||
24 | |||
25 | size = sizeA; | ||
26 | tab = (BuiltinFontWidth **)gmalloc(size * sizeof(BuiltinFontWidth *)); | ||
27 | for (i = 0; i < size; ++i) { | ||
28 | tab[i] = NULL; | ||
29 | } | ||
30 | for (i = 0; i < sizeA; ++i) { | ||
31 | h = hash(widths[i].name); | ||
32 | widths[i].next = tab[h]; | ||
33 | tab[h] = &widths[i]; | ||
34 | } | ||
35 | } | ||
36 | |||
37 | BuiltinFontWidths::~BuiltinFontWidths() { | ||
38 | gfree(tab); | ||
39 | } | ||
40 | |||
41 | GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) { | ||
42 | int h; | ||
43 | BuiltinFontWidth *p; | ||
44 | |||
45 | h = hash(name); | ||
46 | for (p = tab[h]; p; p = p->next) { | ||
47 | if (!strcmp(p->name, name)) { | ||
48 | *width = p->width; | ||
49 | return gTrue; | ||
50 | } | ||
51 | } | ||
52 | return gFalse; | ||
53 | } | ||
54 | |||
55 | int BuiltinFontWidths::hash(char *name) { | ||
56 | char *p; | ||
57 | unsigned int h; | ||
58 | |||
59 | h = 0; | ||
60 | for (p = name; *p; ++p) { | ||
61 | h = 17 * h + (int)(*p & 0xff); | ||
62 | } | ||
63 | return (int)(h % size); | ||
64 | } | ||