1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/*
* Internal header for the AFM library.
* Copyright (c) 1995-1999 Markku Rossi.
*
* Author: Markku Rossi <mtr@iki.fi>
*/
/*
* Enscript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Enscript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Enscript. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AFMINT_H
#define AFMINT_H
/*
* Config stuffs.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#ifndef ___P
#if PROTOTYPES
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
#endif /* no PROTOTYPES */
#endif
#if STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#else /* no STDC_HEADERS */
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
#ifndef HAVE_STRCHR
#define strchr index
#define strrchr rindex
#endif
char *strchr ();
char *strrchr ();
#ifndef HAVE_MEMCPY
#define memcpy(d, s, n) bcopy((s), (d), (n))
#endif
#ifndef HAVE_STRERROR
extern char *strerror ___P ((int));
#endif
#endif /* no STDC_HEADERS */
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <setjmp.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "afm.h"
#include "strhash.h"
/*
* Types and definitions.
*/
/* Error codes. */
#define AFM_ERROR 1
#define AFM_ERROR_MEMORY 2
#define AFM_ERROR_ARGUMENT 3
#define AFM_ERROR_UNKNOWN_FONT 4
#define AFM_ERROR_SYNTAX 5
#define AFM_ERROR_UNSUPPORTED_FORMAT 6
#define AFM_ERROR_FILE_IO 7
#define AFM_ERROR_NOT_AFM_FILE 8
#define NUM_ERRORS 9
/* Pack error and global errno. */
#define SYSERROR(code) (errno << 16 | (code))
/* Keys. */
typedef enum
{
kComment,
/* File structure. */
kStartFontMetrics,
kEndFontMetrics,
kStartCompFontMetrics,
kEndCompFontMetrics,
kStartDescendent,
kEndDescendent,
kStartMasterFontMetrics,
kEndMasterFontMetrics,
/* Control information. */
kMetricsSets,
kDescendents,
kMasters,
kAxes,
/* Global font information. */
kFontName,
kFullName,
kFamilyName,
kWeight,
kFontBBox,
kVersion,
kNotice,
kEncodingScheme,
kMappingScheme,
kEscChar,
kCharacterSet,
kCharacters,
kIsBaseFont,
kVVector,
kIsFixedV,
kCapHeight,
kXHeight,
kAscender,
kDescender,
kWeightVector,
kBlendDesignPositions,
kBlendDesignMap,
kBlendAxisTypes,
/* Writing direction information. */
kStartDirection,
kEndDirection,
kUnderlinePosition,
kUnderlineThickness,
kItalicAngle,
kCharWidth,
kIsFixedPitch,
/* Individual character metrics. */
kStartCharMetrics,
kEndCharMetrics,
kC,
kCH,
kWX,
kW0X,
kW1X,
kWY,
kW0Y,
kW1Y,
kW,
kW0,
kW1,
kVV,
kN,
kB,
kL,
/* Kerning data. */
kStartKernData,
kEndKernData,
kStartTrackKern,
kEndTrackKern,
kTrackKern,
kStartKernPairs,
kEndKernPairs,
kKP,
kKPH,
kKPX,
kKPY,
/* Composite character data. */
kStartComposites,
kEndComposites,
kCC,
kPCC,
/* Axis information. */
kStartAxis,
kEndAxis,
kAxisType,
kAxisLabel,
/* Master Design Information */
kStartMaster,
kEndMaster
} AFMKey;
struct afm_handle_st
{
unsigned int verbose; /* verbose level */
StringHashPtr font_map; /* fontname -> AFM filename mapping */
/* Parse support. */
jmp_buf jmpbuf;
AFMError parse_error; /* Error that caused longjmp(). */
};
/* Store library's private font data to this structure. */
struct afm_font_private_data_st
{
/* Character that is used for undefined codes (' '). */
AFMIndividualCharacterMetrics *undef;
StringHashPtr fontnames; /* fontname -> character info mapping */
StringHashPtr compositenames; /* composite -> AFMComposite mapping */
};
/*
* Encoding tables.
*/
struct encoding_table_st
{
int code;
char *character;
};
typedef struct encoding_table_st AFMEncodingTable;
extern AFMEncodingTable afm_88591_encoding[];
extern AFMEncodingTable afm_88592_encoding[];
extern AFMEncodingTable afm_88593_encoding[];
extern AFMEncodingTable afm_88594_encoding[];
extern AFMEncodingTable afm_88595_encoding[];
extern AFMEncodingTable afm_88597_encoding[];
extern AFMEncodingTable afm_88599_encoding[];
extern AFMEncodingTable afm_885910_encoding[];
extern AFMEncodingTable afm_ibmpc_encoding[];
extern AFMEncodingTable afm_mac_encoding[];
extern AFMEncodingTable afm_vms_encoding[];
extern AFMEncodingTable afm_hp8_encoding[];
extern AFMEncodingTable afm_koi8_encoding[];
/*
* Global help functions.
*/
/* Print message if <level> is larger than library's verbose level. */
void afm_message ___P ((AFMHandle handle, unsigned int level, char *message));
/* Print error message to stderr. */
void afm_error ___P ((AFMHandle handle, char *message));
/*
* AFM file parsing
*/
/* Parse AFM file <filename> and fill up font <font>. */
void afm_parse_file ___P ((AFMHandle handle, const char *filename,
AFMFont font));
#endif /* not AFMINT_H */
|