1
/* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */
3
Copyright (c) 1998 Go Watanabe, All rights reserved.
4
Copyright (c) 1998 Takuya SHIOZAKI, All rights reserved.
5
Copyright (c) 1998 X-TrueType Server Project, All rights reserved.
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions
11
1. Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright
14
notice, this list of conditions and the following disclaimer in the
15
documentation and/or other materials provided with the distribution.
17
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29
Major Release ID: X-TrueType Server Version 1.3 [Aoi MATSUBARA Release 3]
34
#include "xttversion.h"
36
static char const * const releaseID =
39
/* THIS FILE IS BASED ON Speedo Font lib spinfo.c */
41
/*------------------------- original copyright ------------------------*/
43
* Copyright 1990, 1991 Network Computing Devices;
44
* Portions Copyright 1987 by Digital Equipment Corporation
46
* Permission to use, copy, modify, distribute, and sell this software and
47
* its documentation for any purpose is hereby granted without fee, provided
48
* that the above copyright notice appear in all copies and that both that
49
* copyright notice and this permission notice appear in supporting
50
* documentation, and that the names of Network Computing Devices or Digital
51
* not be used in advertising or publicity pertaining to distribution of
52
* the software without specific, written prior permission.
54
* NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
55
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
56
* AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
57
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
58
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
59
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
60
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
62
* Author: Dave Lemke, Network Computing Devices, Inc
66
Copyright (c) 1987 X Consortium
68
Permission is hereby granted, free of charge, to any person obtaining
69
a copy of this software and associated documentation files (the
70
"Software"), to deal in the Software without restriction, including
71
without limitation the rights to use, copy, modify, merge, publish,
72
distribute, sublicense, and/or sell copies of the Software, and to
73
permit persons to whom the Software is furnished to do so, subject to
74
the following conditions:
76
The above copyright notice and this permission notice shall be included
77
in all copies or substantial portions of the Software.
79
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
80
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
82
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
83
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
84
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
85
OTHER DEALINGS IN THE SOFTWARE.
87
Except as contained in this notice, the name of the X Consortium shall
88
not be used in advertising or otherwise to promote the sale, use or
89
other dealings in this Software without prior written authorization
90
from the X Consortium.
99
#include "xttcommon.h"
101
/* percentage of pointsize used to specify ascent & descent */
102
#define STRETCH_FACTOR 120
105
atom, truncate_atom, pixel_size, point_size, resolution_x,
106
resolution_y, average_width
109
typedef struct _fontProp {
115
static fontProp fontNamePropTable[] = {
116
{ "FOUNDRY", 0, atom },
117
{ "FAMILY_NAME", 0, atom },
118
{ "WEIGHT_NAME", 0, atom },
119
{ "SLANT", 0, atom },
120
{ "SETWIDTH_NAME", 0, atom },
121
{ "ADD_STYLE_NAME", 0, atom },
122
{ "PIXEL_SIZE", 0, pixel_size },
123
{ "POINT_SIZE", 0, point_size },
124
{ "RESOLUTION_X", 0, resolution_x },
125
{ "RESOLUTION_Y", 0, resolution_y },
126
{ "SPACING", 0, atom },
127
{ "AVERAGE_WIDTH", 0, average_width },
128
{ "CHARSET_REGISTRY", 0, atom },
129
{ "CHARSET_ENCODING", 0, truncate_atom },
132
/* Warning: following array is closely related to the sequence of
135
static fontProp extraProps[] = {
137
{ "COPYRIGHT", 0, 0 },
138
{ "RAW_PIXEL_SIZE", 0, 0 },
139
{ "RAW_POINT_SIZE", 0, 0 },
140
{ "RAW_ASCENT", 0, 0 },
141
{ "RAW_DESCENT", 0, 0 },
142
{ "RAW_AVERAGE_WIDTH", 0, 0 },
145
/* this is a bit kludgy */
147
#define COPYRIGHTPROP 1
148
#define RAWPIXELPROP 2
149
#define RAWPOINTPROP 3
150
#define RAWASCENTPROP 4
151
#define RAWDESCENTPROP 5
152
#define RAWWIDTHPROP 6
154
#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
155
#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
157
#define NPROPS (NNAMEPROPS + NEXTRAPROPS)
159
extern Atom MakeAtom(char *string, unsigned len, Bool makeit);
162
freetype_make_standard_props(void)
166
i = sizeof(fontNamePropTable) / sizeof(fontProp);
167
for (t = fontNamePropTable; i; i--, t++)
168
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), True);
169
i = sizeof(extraProps) / sizeof(fontProp);
170
for (t = extraProps; i; i--, t++)
171
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), True);
175
freetype_compute_props(FontInfoPtr pinfo,
176
FontScalablePtr vals,
187
char *ptr1 = NULL, *ptr2, *ptr3;
188
/* FontScalableRec tmpvals;*/
190
nprops = pinfo->nprops = NPROPS;
191
pinfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
192
pinfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
193
if (!pinfo->isStringProp || !pinfo->props) {
194
xfree(pinfo->isStringProp);
195
pinfo->isStringProp = (char *) 0;
197
pinfo->props = (FontPropPtr) 0;
200
memset(pinfo->isStringProp, 0, (sizeof(char) * nprops));
203
for (i = NNAMEPROPS, pp = pinfo->props, fpt = fontNamePropTable,
204
is_str = pinfo->isStringProp; i;
205
i--, pp++, fpt++, is_str++) {
209
if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
212
pp->name = fpt->atom;
216
pp->value = MakeAtom(ptr1, ptr2 - ptr1, True);
220
for (ptr3 = ptr1; *ptr3; ptr3++)
223
pp->value = MakeAtom(ptr1, ptr3 - ptr1, True);
226
pp->value = (int)(vals->pixel_matrix[3] +
227
(vals->pixel_matrix[3] > 0 ? .5 : -.5));
230
pp->value = (int)(vals->point_matrix[3] * 10.0 +
231
(vals->point_matrix[3] > 0 ? .5 : -.5));
240
pp->value = vals->width;
245
for (i=0, fpt = extraProps; i < NEXTRAPROPS; i++, is_str++, pp++, fpt++){
246
pp->name = fpt->atom;
250
pp->value = MakeAtom(fontname, strlen(fontname), True);
254
pp->value = MakeAtom(copyright,
255
strlen(copyright), True);
263
pp->value = (long)(72270.0 / (double)vals->y + .5);
267
pp->value = raw_ascent;
271
pp->value = raw_descent;
275
pp->value = raw_width;