1
//========================================================================
5
// Copyright 2001-2002 Glyph & Cog, LLC
7
//========================================================================
11
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
18
#include "fontencodingtables.h"
19
#include "builtinfont.h"
21
//------------------------------------------------------------------------
23
BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) {
27
tab = (BuiltinFontWidth **)gmalloc(size * sizeof(BuiltinFontWidth *));
28
for (i = 0; i < size; ++i) {
31
for (i = 0; i < sizeA; ++i) {
32
h = hash(widths[i].name);
33
widths[i].next = tab[h];
38
BuiltinFontWidths::~BuiltinFontWidths() {
42
GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) {
47
for (p = tab[h]; p; p = p->next) {
48
if (!strcmp(p->name, name)) {
56
int BuiltinFontWidths::hash(char *name) {
61
for (p = name; *p; ++p) {
62
h = 17 * h + (int)(*p & 0xff);
64
return (int)(h % size);