(file) Return to deffont.c CVS log (file) (dir) Up to [RizwankCVS] / testProject / afmlib

  1 rizwank 1.1 /*
  2              * The default font.
  3              * Copyright (c) 1995, 1996, 1997 Markku Rossi.
  4              *
  5              * Author: Markku Rossi <mtr@iki.fi>
  6              */
  7             
  8             /*
  9              * This program is free software; you can redistribute it and/or modify
 10              * it under the terms of the GNU General Public License as published by
 11              * the Free Software Foundation; either version 2, or (at your option)
 12              * any later version.
 13              *
 14              * This program is distributed in the hope that it will be useful,
 15              * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17              * GNU General Public License for more details.
 18              *
 19              * You should have received a copy of the GNU General Public License
 20              * along with this program; see the file COPYING.  If not, write to
 21              * the Free Software Foundation, 59 Temple Place - Suite 330,
 22 rizwank 1.1  * Boston, MA 02111-1307, USA.
 23              */
 24             
 25             #include "afmint.h"
 26             #include "afm.h"
 27             
 28             
 29             /*
 30              * Static variables.
 31              */
 32             
 33             static AFMEncodingTable builtin_courier[] =
 34             {
 35               {32, 	"space"},
 36               {33, 	"exclam"},
 37               {34, 	"quotedbl"},
 38               {35, 	"numbersign"},
 39               {36, 	"dollar"},
 40               {37, 	"percent"},
 41               {38, 	"ampersand"},
 42               {39, 	"quoteright"},
 43 rizwank 1.1   {40, 	"parenleft"},
 44               {41, 	"parenright"},
 45               {42, 	"asterisk"},
 46               {43, 	"plus"},
 47               {44, 	"comma"},
 48               {45, 	"hyphen"},
 49               {46, 	"period"},
 50               {47, 	"slash"},
 51               {48, 	"zero"},
 52               {49, 	"one"},
 53               {50, 	"two"},
 54               {51, 	"three"},
 55               {52, 	"four"},
 56               {53, 	"five"},
 57               {54, 	"six"},
 58               {55, 	"seven"},
 59               {56, 	"eight"},
 60               {57, 	"nine"},
 61               {58, 	"colon"},
 62               {59, 	"semicolon"},
 63               {60, 	"less"},
 64 rizwank 1.1   {61, 	"equal"},
 65               {62, 	"greater"},
 66               {63, 	"question"},
 67               {64, 	"at"},
 68               {65, 	"A"},
 69               {66, 	"B"},
 70               {67, 	"C"},
 71               {68, 	"D"},
 72               {69, 	"E"},
 73               {70, 	"F"},
 74               {71, 	"G"},
 75               {72, 	"H"},
 76               {73, 	"I"},
 77               {74, 	"J"},
 78               {75, 	"K"},
 79               {76, 	"L"},
 80               {77, 	"M"},
 81               {78, 	"N"},
 82               {79, 	"O"},
 83               {80, 	"P"},
 84               {81, 	"Q"},
 85 rizwank 1.1   {82, 	"R"},
 86               {83, 	"S"},
 87               {84, 	"T"},
 88               {85, 	"U"},
 89               {86, 	"V"},
 90               {87, 	"W"},
 91               {88, 	"X"},
 92               {89, 	"Y"},
 93               {90, 	"Z"},
 94               {91, 	"bracketleft"},
 95               {92, 	"backslash"},
 96               {93, 	"bracketright"},
 97               {94, 	"asciicircum"},
 98               {95, 	"underscore"},
 99               {96, 	"quoteleft"},
100               {97, 	"a"},
101               {98, 	"b"},
102               {99, 	"c"},
103               {100,	"d"},
104               {101, "e"},
105               {102, "f"},
106 rizwank 1.1   {103, "g"},
107               {104, "h"},
108               {105, "i"},
109               {106, "j"},
110               {107, "k"},
111               {108, "l"},
112               {109, "m"},
113               {110, "n"},
114               {111, "o"},
115               {112, "p"},
116               {113, "q"},
117               {114, "r"},
118               {115, "s"},
119               {116, "t"},
120               {117, "u"},
121               {118, "v"},
122               {119, "w"},
123               {120, "x"},
124               {121, "y"},
125               {122, "z"},
126               {123, "braceleft"},
127 rizwank 1.1   {124, "bar"},
128               {125, "braceright"},
129               {126, "asciitilde"},
130               {161, "exclamdown"},
131               {162, "cent"},
132               {163, "sterling"},
133               {164, "fraction"},
134               {165, "yen"},
135               {166, "florin"},
136               {167, "section"},
137               {168, "currency"},
138               {169, "quotesingle"},
139               {170, "quotedblleft"},
140               {171, "guillemotleft"},
141               {172, "guilsinglleft"},
142               {173, "guilsinglright"},
143               {174, "fi"},
144               {175, "fl"},
145               {177, "endash"},
146               {178, "dagger"},
147               {179, "daggerdbl"},
148 rizwank 1.1   {180, "periodcentered"},
149               {182, "paragraph"},
150               {183, "bullet"},
151               {184, "quotesinglbase"},
152               {185, "quotedblbase"},
153               {186, "quotedblright"},
154               {187, "guillemotright"},
155               {188, "ellipsis"},
156               {189, "perthousand"},
157               {191, "questiondown"},
158               {193, "grave"},
159               {194, "acute"},
160               {195, "circumflex"},
161               {196, "tilde"},
162               {197, "macron"},
163               {198, "breve"},
164               {199, "dotaccent"},
165               {200, "dieresis"},
166               {202, "ring"},
167               {203, "cedilla"},
168               {205, "hungarumlaut"},
169 rizwank 1.1   {206, "ogonek"},
170               {207, "caron"},
171               {208, "emdash"},
172               {225, "AE"},
173               {227, "ordfeminine"},
174               {232, "Lslash"},
175               {233, "Oslash"},
176               {234, "OE"},
177               {235, "ordmasculine"},
178               {241, "ae"},
179               {245, "dotlessi"},
180               {248, "lslash"},
181               {249, "oslash"},
182               {250, "oe"},
183               {251, "germandbls"},
184               {-1, 	"Aacute"},
185               {-1, 	"Acircumflex"},
186               {-1, 	"Adieresis"},
187               {-1, 	"Agrave"},
188               {-1, 	"Aring"},
189               {-1, 	"Atilde"},
190 rizwank 1.1   {-1, 	"Ccedilla"},
191               {-1, 	"Eacute"},
192               {-1, 	"Ecircumflex"},
193               {-1, 	"Edieresis"},
194               {-1, 	"Egrave"},
195               {-1, 	"Eth"},
196               {-1, 	"Gcaron"},
197               {-1, 	"IJ"},
198               {-1, 	"Iacute"},
199               {-1, 	"Icircumflex"},
200               {-1, 	"Idieresis"},
201               {-1, 	"Idot"},
202               {-1, 	"Igrave"},
203               {-1, 	"LL"},
204               {-1, 	"Ntilde"},
205               {-1, 	"Oacute"},
206               {-1, 	"Ocircumflex"},
207               {-1, 	"Odieresis"},
208               {-1, 	"Ograve"},
209               {-1, 	"Otilde"},
210               {-1, 	"Scaron"},
211 rizwank 1.1   {-1, 	"Scedilla"},
212               {-1, 	"Thorn"},
213               {-1, 	"Uacute"},
214               {-1, 	"Ucircumflex"},
215               {-1, 	"Udieresis"},
216               {-1, 	"Ugrave"},
217               {-1, 	"Yacute"},
218               {-1, 	"Ydieresis"},
219               {-1, 	"Zcaron"},
220               {-1, 	"aacute"},
221               {-1, 	"acircumflex"},
222               {-1, 	"adieresis"},
223               {-1, 	"agrave"},
224               {-1, 	"aring"},
225               {-1, 	"arrowboth"},
226               {-1, 	"arrowdown"},
227               {-1, 	"arrowleft"},
228               {-1, 	"arrowright"},
229               {-1, 	"arrowup"},
230               {-1, 	"atilde"},
231               {-1, 	"brokenbar"},
232 rizwank 1.1   {-1, 	"ccedilla"},
233               {-1, 	"center"},
234               {-1, 	"copyright"},
235               {-1, 	"dectab"},
236               {-1, 	"degree"},
237               {-1, 	"divide"},
238               {-1, 	"down"},
239               {-1, 	"eacute"},
240               {-1, 	"ecircumflex"},
241               {-1, 	"edieresis"},
242               {-1, 	"egrave"},
243               {-1, 	"eth"},
244               {-1, 	"format"},
245               {-1, 	"gcaron"},
246               {-1, 	"graybox"},
247               {-1, 	"iacute"},
248               {-1, 	"icircumflex"},
249               {-1, 	"idieresis"},
250               {-1, 	"igrave"},
251               {-1, 	"ij"},
252               {-1, 	"indent"},
253 rizwank 1.1   {-1, 	"largebullet"},
254               {-1, 	"left"},
255               {-1, 	"lira"},
256               {-1, 	"ll"},
257               {-1, 	"logicalnot"},
258               {-1, 	"merge"},
259               {-1, 	"minus"},
260               {-1, 	"mu"},
261               {-1, 	"multiply"},
262               {-1, 	"notegraphic"},
263               {-1, 	"ntilde"},
264               {-1, 	"oacute"},
265               {-1, 	"ocircumflex"},
266               {-1, 	"odieresis"},
267               {-1, 	"ograve"},
268               {-1, 	"onehalf"},
269               {-1, 	"onequarter"},
270               {-1, 	"onesuperior"},
271               {-1, 	"otilde"},
272               {-1, 	"overscore"},
273               {-1, 	"plusminus"},
274 rizwank 1.1   {-1, 	"prescription"},
275               {-1, 	"registered"},
276               {-1, 	"return"},
277               {-1, 	"scaron"},
278               {-1, 	"scedilla"},
279               {-1, 	"square"},
280               {-1, 	"stop"},
281               {-1, 	"tab"},
282               {-1, 	"thorn"},
283               {-1, 	"threequarters"},
284               {-1, 	"threesuperior"},
285               {-1, 	"trademark"},
286               {-1, 	"twosuperior"},
287               {-1, 	"uacute"},
288               {-1, 	"ucircumflex"},
289               {-1, 	"udieresis"},
290               {-1, 	"ugrave"},
291               {-1, 	"up"},
292               {-1, 	"yacute"},
293               {-1, 	"ydieresis"},
294               {-1, 	"zcaron"},
295 rizwank 1.1   {0, NULL},
296             };
297             
298             #define NUM_CHARACTER_METRICS \
299               (sizeof (builtin_courier) / sizeof (AFMEncodingTable) - 1)
300             
301             /*
302              * Public functions.
303              */
304             
305             AFMError
306             afm_open_default_font (AFMHandle handle, AFMFont *font_return)
307             {
308               AFMFont font;
309               AFMIndividualCharacterMetrics *cm;
310               int i;
311             
312               /* Alloc memory. */
313             
314               font = (AFMFont) calloc (1, sizeof (*font));
315               if (font == NULL)
316 rizwank 1.1     goto error_out;
317               font->private
318                 = (struct afm_font_private_data_st *) calloc (1, sizeof (*font->private));
319               if (font->private == NULL)
320                 goto error_out;
321               font->private->fontnames = strhash_init ();
322               if (font->private->fontnames == NULL)
323                 goto error_out;
324             
325               /* Version. */
326               font->version = 4.0;
327             
328               /* Global Font Info. */
329             
330               font->global_info.FontName = (char *) malloc (strlen ("Courier") + 1);
331               if (font->global_info.FontName == NULL)
332                 goto error_out;
333               strcpy (font->global_info.FontName, "Courier");
334             
335               font->global_info.FontBBox_llx = -40.0;
336               font->global_info.FontBBox_lly = -290.0;
337 rizwank 1.1   font->global_info.FontBBox_urx = 640.0;
338               font->global_info.FontBBox_ury = 795.0;
339             
340               /* Writing directions. */
341               font->writing_direction_metrics[0].is_valid = AFMTrue;
342               font->writing_direction_metrics[0].IsFixedPitch = AFMTrue;
343               font->writing_direction_metrics[0].CharWidth_x = 600.0;
344               font->writing_direction_metrics[0].CharWidth_y = 0.0;
345             
346               /* Character Metrics. */
347             
348               font->num_character_metrics = NUM_CHARACTER_METRICS;
349               font->character_metrics
350                 = (AFMIndividualCharacterMetrics *)
351                   calloc (NUM_CHARACTER_METRICS, sizeof (AFMIndividualCharacterMetrics));
352               if (font->character_metrics == NULL)
353                 goto error_out;
354             
355               for (i = 0; builtin_courier[i].character; i++)
356                 {
357                   cm = &font->character_metrics[i];
358 rizwank 1.1       cm->name = (char *) malloc (strlen (builtin_courier[i].character) + 1);
359                   if (cm->name == NULL)
360             	goto error_out;
361                   strcpy (cm->name, builtin_courier[i].character);
362             
363                   if (!strhash_put (font->private->fontnames, cm->name,
364             			strlen (cm->name), cm, NULL))
365             	goto error_out;
366             
367                   cm->character_code = builtin_courier[i].code;
368                   cm->w0x = 600.0;
369                   cm->w0y = 0.0;
370                 }
371             
372               *font_return = font;
373             
374               return AFM_SUCCESS;
375             
376             
377              error_out:
378               (void) afm_close_font (font);
379 rizwank 1.1 
380               return AFM_ERROR_MEMORY;
381             }

Rizwan Kassim
Powered by
ViewCVS 0.9.2