1 /* $XConsortium: spfuncs.c,v 1.13 94/06/06 17:42:26 gildea Exp $ */
2 /*
3  * Copyright 1990, 1991 Network Computing Devices;
4  * Portions Copyright 1987 by Digital Equipment Corporation
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and
7  * its documentation for any purpose is hereby granted without fee, provided
8  * that the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the names of Network Computing Devices or Digital
11  * not be used in advertising or publicity pertaining to distribution of
12  * the software without specific, written prior permission.
13  *
14  * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
15  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
17  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * Author: Dave Lemke, Network Computing Devices, Inc
23  */
24 
25 /*
26 
27 Copyright (c) 1987  X Consortium
28 
29 Permission is hereby granted, free of charge, to any person obtaining
30 a copy of this software and associated documentation files (the
31 "Software"), to deal in the Software without restriction, including
32 without limitation the rights to use, copy, modify, merge, publish,
33 distribute, sublicense, and/or sell copies of the Software, and to
34 permit persons to whom the Software is furnished to do so, subject to
35 the following conditions:
36 
37 The above copyright notice and this permission notice shall be included
38 in all copies or substantial portions of the Software.
39 
40 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
41 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
44 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
45 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
46 OTHER DEALINGS IN THE SOFTWARE.
47 
48 Except as contained in this notice, the name of the X Consortium shall
49 not be used in advertising or otherwise to promote the sale, use or
50 other dealings in this Software without prior written authorization
51 from the X Consortium.
52 
53 */
54 
55 #include <X11/Xos.h>
56 #include "fntfilst.h"
57 #include "spint.h"
58 
59 /* ARGSUSED */
SpeedoOpenScalable(fpe,pFont,flags,entry,fileName,vals,format,fmask,non_cachable_font)60 SpeedoOpenScalable (fpe, pFont, flags, entry, fileName, vals, format, fmask,
61 		    non_cachable_font)
62     FontPathElementPtr	fpe;
63     FontPtr		*pFont;
64     int			flags;
65     FontEntryPtr	entry;
66     char		*fileName;
67     FontScalablePtr	vals;
68     fsBitmapFormat	format;
69     fsBitmapFormatMask	fmask;
70     FontPtr		non_cachable_font;	/* We don't do licensing */
71 {
72     char	fullName[MAXFONTNAMELEN];
73 
74     strcpy (fullName, entry->name.name);
75     return SpeedoFontLoad (pFont, fullName, fileName, entry, vals,
76 			    format, fmask, flags);
77 }
78 
79 /*
80  * XXX
81  *
82  * this does a lot more then i'd like, but it has to get the bitmaps
83  * in order to get accurate metrics (which it *must* have).
84  *
85  * a possible optimization is to avoid allocating the glyph memory
86  * and to simply save the values without doing the work.
87  */
88 static int
get_font_info(pinfo,fontname,filename,entry,vals,spfont)89 get_font_info(pinfo, fontname, filename, entry, vals, spfont)
90     FontInfoPtr pinfo;
91     char       *fontname;
92     char       *filename;
93     FontEntryPtr	entry;
94     FontScalablePtr	vals;
95     SpeedoFontPtr *spfont;
96 {
97     SpeedoFontPtr spf;
98     int         err;
99     long	sWidth;
100 
101     err = sp_open_font(fontname, filename, entry, vals,
102 	       (fsBitmapFormat) 0, (fsBitmapFormatMask) 0, (unsigned long) 0,
103 		       &spf);
104 
105     if (err != Successful)
106 	return err;
107 
108     sp_fp_cur = spf;
109     sp_reset_master(spf->master);
110 
111     sp_make_header(spf, pinfo);
112 
113     sp_compute_bounds(spf, pinfo, (unsigned long) 0, &sWidth);
114 
115     sp_compute_props(spf, fontname, pinfo, sWidth);
116 
117     /* compute remaining accelerators */
118     FontComputeInfoAccelerators (pinfo);
119 
120     *spfont = spf;
121 
122     return Successful;
123 }
124 
125 /* ARGSUSED */
SpeedoGetInfoScaleable(fpe,pFontInfo,entry,fontName,fileName,vals)126 SpeedoGetInfoScaleable(fpe, pFontInfo, entry, fontName, fileName, vals)
127     FontPathElementPtr	fpe;
128     FontInfoPtr		pFontInfo;
129     FontEntryPtr	entry;
130     FontNamePtr		fontName;
131     char		*fileName;
132     FontScalablePtr	vals;
133 {
134     SpeedoFontPtr spf = NULL;
135     char        fullName[MAXFONTNAMELEN];
136     int         err;
137 
138     strcpy(fullName, entry->name.name);
139     FontParseXLFDName(fullName, vals, FONT_XLFD_REPLACE_VALUE);
140 
141     err = get_font_info(pFontInfo, fullName, fileName, entry, vals, &spf);
142 
143     if (spf)
144 	sp_close_font(spf);
145 
146     return err;
147 }
148 
149 static FontRendererRec renderer = {
150     ".spd", 4, (int (*)()) 0, SpeedoOpenScalable,
151 	(int (*)()) 0, SpeedoGetInfoScaleable, 0
152     , CAP_MATRIX | CAP_CHARSUBSETTING
153 };
154 
SpeedoRegisterFontFileFunctions()155 SpeedoRegisterFontFileFunctions()
156 {
157     sp_make_standard_props();
158     sp_reset();
159     FontFileRegisterRenderer(&renderer);
160 }
161