zfcid.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: zfcid.c,v 1.11 2000/11/02 07:58:05 lpd Exp $ */
  16. /* CID-keyed font utilities */
  17. #include "ghost.h"
  18. #include "oper.h"
  19. #include "gsmatrix.h"
  20. #include "gxfcid.h"
  21. #include "bfont.h"
  22. #include "icid.h"
  23. #include "idict.h"
  24. #include "idparam.h"
  25. #include "ifcid.h"
  26. #include "store.h"
  27. /* Get the CIDSystemInfo of a CIDFont. */
  28. int
  29. cid_font_system_info_param(gs_cid_system_info_t *pcidsi, const ref *prfont)
  30. {
  31. ref *prcidsi;
  32. if (dict_find_string(prfont, "CIDSystemInfo", &prcidsi) <= 0)
  33. return_error(e_rangecheck);
  34. return cid_system_info_param(pcidsi, prcidsi);
  35. }
  36. /* Get the additional information for a CIDFontType 0 or 2 CIDFont. */
  37. int
  38. cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory)
  39. {
  40. int code;
  41. ref *pgdir;
  42. check_type(*op, t_dictionary);
  43. if ((code = cid_font_system_info_param(&pdata->CIDSystemInfo, op)) < 0 ||
  44. (code = dict_int_param(op, "CIDCount", 0, max_int, -1,
  45. &pdata->CIDCount)) < 0
  46. )
  47. return code;
  48. /*
  49. * If the font doesn't have a GlyphDirectory, GDBytes is required.
  50. * If it does have a GlyphDirectory, GDBytes may still be needed for
  51. * CIDMap: it's up to the client to check this.
  52. */
  53. if (dict_find_string(op, "GlyphDirectory", &pgdir) <= 0) {
  54. /* Standard CIDFont, require GDBytes. */
  55. make_null(pGlyphDirectory);
  56. return dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 0,
  57. &pdata->GDBytes);
  58. }
  59. if (r_has_type(pgdir, t_dictionary) || r_is_array(pgdir)) {
  60. /* GlyphDirectory, GDBytes is optional. */
  61. *pGlyphDirectory = *pgdir;
  62. code = dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 1,
  63. &pdata->GDBytes);
  64. if (code == 1) {
  65. pdata->GDBytes = 0;
  66. code = 0;
  67. }
  68. return code;
  69. } else {
  70. return_error(e_typecheck);
  71. }
  72. }