hpdf_font.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * << Haru Free PDF Library >> -- hpdf_font.h
  3. *
  4. * URL: http://libharu.org
  5. *
  6. * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
  7. * Copyright (c) 2007-2009 Antony Dovgal <[email protected]>
  8. *
  9. * Permission to use, copy, modify, distribute and sell this software
  10. * and its documentation for any purpose is hereby granted without fee,
  11. * provided that the above copyright notice appear in all copies and
  12. * that both that copyright notice and this permission notice appear
  13. * in supporting documentation.
  14. * It is provided "as is" without express or implied warranty.
  15. *
  16. */
  17. #ifndef _HPDF_FONT_H
  18. #define _HPDF_FONT_H
  19. #include "hpdf_fontdef.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*----------------------------------------------------------------------------*/
  24. /*----- Writing Mode ---------------------------------------------------------*/
  25. typedef enum _HPDF_FontType {
  26. HPDF_FONT_TYPE1 = 0,
  27. HPDF_FONT_TRUETYPE,
  28. HPDF_FONT_TYPE3,
  29. HPDF_FONT_TYPE0_CID,
  30. HPDF_FONT_TYPE0_TT,
  31. HPDF_FONT_CID_TYPE0,
  32. HPDF_FONT_CID_TYPE2,
  33. HPDF_FONT_MMTYPE1
  34. } HPDF_FontType;
  35. typedef HPDF_Dict HPDF_Font;
  36. typedef HPDF_TextWidth
  37. (*HPDF_Font_TextWidths_Func) (HPDF_Font font,
  38. const HPDF_BYTE *text,
  39. HPDF_UINT len);
  40. typedef HPDF_UINT
  41. (*HPDF_Font_MeasureText_Func) (HPDF_Font font,
  42. const HPDF_BYTE *text,
  43. HPDF_UINT len,
  44. HPDF_REAL width,
  45. HPDF_REAL fontsize,
  46. HPDF_REAL charspace,
  47. HPDF_REAL wordspace,
  48. HPDF_BOOL wordwrap,
  49. HPDF_REAL *real_width);
  50. typedef struct _HPDF_FontAttr_Rec *HPDF_FontAttr;
  51. typedef struct _HPDF_FontAttr_Rec {
  52. HPDF_FontType type;
  53. HPDF_WritingMode writing_mode;
  54. HPDF_Font_TextWidths_Func text_width_fn;
  55. HPDF_Font_MeasureText_Func measure_text_fn;
  56. HPDF_FontDef fontdef;
  57. HPDF_Encoder encoder;
  58. /* if the encoding-type is HPDF_ENCODER_TYPE_SINGLE_BYTE, the width of
  59. * each charactors are cashed in 'widths'.
  60. * when HPDF_ENCODER_TYPE_DOUBLE_BYTE the width is calculate each time.
  61. */
  62. HPDF_INT16* widths;
  63. HPDF_BYTE* used;
  64. HPDF_Xref xref;
  65. HPDF_Font descendant_font;
  66. HPDF_Dict map_stream;
  67. HPDF_Dict cmap_stream;
  68. } HPDF_FontAttr_Rec;
  69. HPDF_Font
  70. HPDF_Type1Font_New (HPDF_MMgr mmgr,
  71. HPDF_FontDef fontdef,
  72. HPDF_Encoder encoder,
  73. HPDF_Xref xref);
  74. HPDF_Font
  75. HPDF_TTFont_New (HPDF_MMgr mmgr,
  76. HPDF_FontDef fontdef,
  77. HPDF_Encoder encoder,
  78. HPDF_Xref xref);
  79. HPDF_Font
  80. HPDF_Type0Font_New (HPDF_MMgr mmgr,
  81. HPDF_FontDef fontdef,
  82. HPDF_Encoder encoder,
  83. HPDF_Xref xref);
  84. HPDF_BOOL
  85. HPDF_Font_Validate (HPDF_Font font);
  86. #ifdef __cplusplus
  87. }
  88. #endif /* __cplusplus */
  89. #endif /* _HPDF_FONT_H */