3 * Copyright (c) 1995, 1996, 1997 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
9 * Enscript 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 3 of the License, or
12 * (at your option) any later version.
14 * Enscript 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 Enscript. If not, see <http://www.gnu.org/licenses/>.
31 static AFMEncodingTable builtin_courier[] =
136 {169, "quotesingle"},
137 {170, "quotedblleft"},
138 {171, "guillemotleft"},
139 {172, "guilsinglleft"},
140 {173, "guilsinglright"},
146 {180, "periodcentered"},
149 {184, "quotesinglbase"},
150 {185, "quotedblbase"},
151 {186, "quotedblright"},
152 {187, "guillemotright"},
154 {189, "perthousand"},
155 {191, "questiondown"},
166 {205, "hungarumlaut"},
171 {227, "ordfeminine"},
175 {235, "ordmasculine"},
272 {-1, "prescription"},
281 {-1, "threequarters"},
282 {-1, "threesuperior"},
296 #define NUM_CHARACTER_METRICS \
297 (sizeof (builtin_courier) / sizeof (AFMEncodingTable) - 1)
304 afm_open_default_font (AFMHandle handle, AFMFont *font_return)
307 AFMIndividualCharacterMetrics *cm;
312 font = (AFMFont) calloc (1, sizeof (*font));
316 = (struct afm_font_private_data_st *) calloc (1, sizeof (*font->private));
317 if (font->private == NULL)
319 font->private->fontnames = strhash_init ();
320 if (font->private->fontnames == NULL)
326 /* Global Font Info. */
328 font->global_info.FontName = (char *) malloc (strlen ("Courier") + 1);
329 if (font->global_info.FontName == NULL)
331 strcpy (font->global_info.FontName, "Courier");
333 font->global_info.FontBBox_llx = -40.0;
334 font->global_info.FontBBox_lly = -290.0;
335 font->global_info.FontBBox_urx = 640.0;
336 font->global_info.FontBBox_ury = 795.0;
338 /* Writing directions. */
339 font->writing_direction_metrics[0].is_valid = AFMTrue;
340 font->writing_direction_metrics[0].IsFixedPitch = AFMTrue;
341 font->writing_direction_metrics[0].CharWidth_x = 600.0;
342 font->writing_direction_metrics[0].CharWidth_y = 0.0;
344 /* Character Metrics. */
346 font->num_character_metrics = NUM_CHARACTER_METRICS;
347 font->character_metrics
348 = (AFMIndividualCharacterMetrics *)
349 calloc (NUM_CHARACTER_METRICS, sizeof (AFMIndividualCharacterMetrics));
350 if (font->character_metrics == NULL)
353 for (i = 0; builtin_courier[i].character; i++)
355 cm = &font->character_metrics[i];
356 cm->name = (char *) malloc (strlen (builtin_courier[i].character) + 1);
357 if (cm->name == NULL)
359 strcpy (cm->name, builtin_courier[i].character);
361 if (!strhash_put (font->private->fontnames, cm->name,
362 strlen (cm->name), cm, NULL))
365 cm->character_code = builtin_courier[i].code;
376 (void) afm_close_font (font);
378 return AFM_ERROR_MEMORY;