glyph-imp.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright (C) 2004-2025 Artifex Software, Inc.
  2. //
  3. // This file is part of MuPDF.
  4. //
  5. // MuPDF is free software: you can redistribute it and/or modify it under the
  6. // terms of the GNU Affero General Public License as published by the Free
  7. // Software Foundation, either version 3 of the License, or (at your option)
  8. // any later version.
  9. //
  10. // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
  11. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. // details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
  17. //
  18. // Alternative licensing terms are available from the licensor.
  19. // For commercial licensing, see <https://www.artifex.com/> or contact
  20. // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  21. // CA 94129, USA, for further information.
  22. #ifndef FITZ_GLYPH_IMP_H
  23. #define FITZ_GLYPH_IMP_H
  24. /*
  25. Glyphs represent a run length encoded set of pixels for a 2
  26. dimensional region of a plane.
  27. x, y: The minimum x and y coord of the region in pixels.
  28. w, h: The width and height of the region in pixels.
  29. samples: The sample data. The sample data is in a compressed
  30. format designed to give reasonable compression, and to be fast
  31. to plot from.
  32. The first sizeof(int) * h bytes of the table, when interpreted
  33. as ints gives the offset within the data block of that lines
  34. data. An offset of 0 indicates that that line is completely
  35. blank.
  36. The data for individual lines is a sequence of bytes:
  37. 00000000 = end of lines data
  38. LLLLLL00 = extend the length given in the next run by the 6 L
  39. bits given here.
  40. LLLLLL01 = A run of length L+1 transparent pixels.
  41. LLLLLE10 = A run of length L+1 solid pixels. If E then this is
  42. the last run on this line.
  43. LLLLLE11 = A run of length L+1 intermediate pixels followed by
  44. L+1 bytes of literal pixel data. If E then this is the
  45. last run on this line.
  46. */
  47. struct fz_glyph
  48. {
  49. fz_storable storable;
  50. int x, y, w, h;
  51. fz_pixmap *pixmap;
  52. size_t size;
  53. unsigned char data[FZ_FLEXIBLE_ARRAY];
  54. };
  55. /*
  56. Create a new glyph from a pixmap
  57. Returns a pointer to the new glyph. Throws exception on failure
  58. to allocate.
  59. */
  60. fz_glyph *fz_new_glyph_from_pixmap(fz_context *ctx, fz_pixmap *pix);
  61. /*
  62. Create a new glyph from 8bpp data
  63. x, y: X and Y position for the glyph
  64. w, h: Width and Height for the glyph
  65. sp: Source Pointer to data
  66. span: Increment from line to line of data
  67. Returns a pointer to the new glyph. Throws exception on failure
  68. to allocate.
  69. */
  70. fz_glyph *fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
  71. /*
  72. Create a new glyph from 1bpp data
  73. x, y: X and Y position for the glyph
  74. w, h: Width and Height for the glyph
  75. sp: Source Pointer to data
  76. span: Increment from line to line of data
  77. Returns a pointer to the new glyph. Throws exception on failure
  78. to allocate.
  79. */
  80. fz_glyph *fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
  81. fz_path *fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm);
  82. fz_glyph *fz_render_ft_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, int aa);
  83. fz_pixmap *fz_render_ft_glyph_pixmap(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, int aa);
  84. fz_glyph *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, const fz_irect *scissor, int aa);
  85. fz_pixmap *fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, const fz_irect *scissor, int aa);
  86. fz_glyph *fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, const fz_stroke_state *state, int aa);
  87. fz_glyph *fz_render_glyph(fz_context *ctx, fz_font*, int gid, fz_matrix *, fz_colorspace *model, const fz_irect *scissor, int alpha, int aa);
  88. fz_glyph *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix *, fz_matrix, fz_colorspace *model, const fz_stroke_state *stroke, const fz_irect *scissor, int aa);
  89. #endif