1 //========================================================================
5 // Copyright 2001-2002 Glyph & Cog, LLC
7 //========================================================================
10 #pragma implementation
17 #include "FontEncodingTables.h"
18 #include "BuiltinFont.h"
20 //------------------------------------------------------------------------
22 BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) {
26 tab = (BuiltinFontWidth **)gmalloc(size * sizeof(BuiltinFontWidth *));
27 for (i = 0; i < size; ++i) {
30 for (i = 0; i < sizeA; ++i) {
31 h = hash(widths[i].name);
32 widths[i].next = tab[h];
37 BuiltinFontWidths::~BuiltinFontWidths() {
41 GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) {
46 for (p = tab[h]; p; p = p->next) {
47 if (!strcmp(p->name, name)) {
55 int BuiltinFontWidths::hash(char *name) {
60 for (p = name; *p; ++p) {
61 h = 17 * h + (int)(*p & 0xff);
63 return (int)(h % size);