3 * Copyright (c) 1995, 1996, 1997 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
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)
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.
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 * Boston, MA 02111-1307, USA.
33 static AFMEncodingTable builtin_courier[] =
138 {169, "quotesingle"},
139 {170, "quotedblleft"},
140 {171, "guillemotleft"},
141 {172, "guilsinglleft"},
142 {173, "guilsinglright"},
148 {180, "periodcentered"},
151 {184, "quotesinglbase"},
152 {185, "quotedblbase"},
153 {186, "quotedblright"},
154 {187, "guillemotright"},
156 {189, "perthousand"},
157 {191, "questiondown"},
168 {205, "hungarumlaut"},
173 {227, "ordfeminine"},
177 {235, "ordmasculine"},
274 {-1, "prescription"},
283 {-1, "threequarters"},
284 {-1, "threesuperior"},
298 #define NUM_CHARACTER_METRICS \
299 (sizeof (builtin_courier) / sizeof (AFMEncodingTable) - 1)
306 afm_open_default_font (AFMHandle handle, AFMFont *font_return)
309 AFMIndividualCharacterMetrics *cm;
314 font = (AFMFont) calloc (1, sizeof (*font));
318 = (struct afm_font_private_data_st *) calloc (1, sizeof (*font->private));
319 if (font->private == NULL)
321 font->private->fontnames = strhash_init ();
322 if (font->private->fontnames == NULL)
328 /* Global Font Info. */
330 font->global_info.FontName = (char *) malloc (strlen ("Courier") + 1);
331 if (font->global_info.FontName == NULL)
333 strcpy (font->global_info.FontName, "Courier");
335 font->global_info.FontBBox_llx = -40.0;
336 font->global_info.FontBBox_lly = -290.0;
337 font->global_info.FontBBox_urx = 640.0;
338 font->global_info.FontBBox_ury = 795.0;
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;
346 /* Character Metrics. */
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)
355 for (i = 0; builtin_courier[i].character; i++)
357 cm = &font->character_metrics[i];
358 cm->name = (char *) malloc (strlen (builtin_courier[i].character) + 1);
359 if (cm->name == NULL)
361 strcpy (cm->name, builtin_courier[i].character);
363 if (!strhash_put (font->private->fontnames, cm->name,
364 strlen (cm->name), cm, NULL))
367 cm->character_code = builtin_courier[i].code;
378 (void) afm_close_font (font);
380 return AFM_ERROR_MEMORY;