1 #ifndef MUPDF_FITZ_GLYPH_H
2 #define MUPDF_FITZ_GLYPH_H
4 #include "mupdf/fitz/system.h"
5 #include "mupdf/fitz/context.h"
6 #include "mupdf/fitz/math.h"
7 #include "mupdf/fitz/store.h"
8 #include "mupdf/fitz/colorspace.h"
11 Glyphs represent a run length encoded set of pixels for a 2
12 dimensional region of a plane.
14 typedef struct fz_glyph_s fz_glyph;
17 fz_glyph_bbox: Return the bounding box for a glyph.
19 fz_irect *fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph, fz_irect *bbox);
22 fz_glyph_width: Return the width of the glyph in pixels.
24 int fz_glyph_width(fz_context *ctx, fz_glyph *glyph);
27 fz_glyph_height: Return the height of the glyph in pixels.
29 int fz_glyph_height(fz_context *ctx, fz_glyph *glyph);
32 fz_new_glyph_from_pixmap: Create a new glyph from a pixmap
34 Returns a pointer to the new glyph. Throws exception on failure to
37 fz_glyph *fz_new_glyph_from_pixmap(fz_context *ctx, fz_pixmap *pix);
40 fz_new_glyph_from_8bpp_data: Create a new glyph from 8bpp data
42 x, y: X and Y position for the glyph
44 w, h: Width and Height for the glyph
46 sp: Source Pointer to data
48 span: Increment from line to line of data
50 Returns a pointer to the new glyph. Throws exception on failure to
53 fz_glyph *fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
56 fz_new_glyph_from_1bpp_data: Create a new glyph from 1bpp data
58 x, y: X and Y position for the glyph
60 w, h: Width and Height for the glyph
62 sp: Source Pointer to data
64 span: Increment from line to line of data
66 Returns a pointer to the new glyph. Throws exception on failure to
68 */fz_glyph *fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
72 fz_keep_glyph: Take a reference to a glyph.
74 pix: The glyph to increment the reference for.
76 Returns pix. Does not throw exceptions.
78 fz_glyph *fz_keep_glyph(fz_context *ctx, fz_glyph *pix);
81 fz_drop_glyph: Drop a reference and free a glyph.
83 Decrement the reference count for the glyph. When no
84 references remain the glyph will be freed.
86 Does not throw exceptions.
88 void fz_drop_glyph(fz_context *ctx, fz_glyph *pix);
91 Glyphs represent a set of pixels for a 2 dimensional region of a
94 x, y: The minimum x and y coord of the region in pixels.
96 w, h: The width and height of the region in pixels.
98 samples: The sample data. The sample data is in a compressed format
99 designed to give reasonable compression, and to be fast to plot from.
101 The first sizeof(int) * h bytes of the table, when interpreted as
102 ints gives the offset within the data block of that lines data. An
103 offset of 0 indicates that that line is completely blank.
105 The data for individual lines is a sequence of bytes:
106 00000000 = end of lines data
107 LLLLLL00 = extend the length given in the next run by the 6 L bits
109 LLLLLL01 = A run of length L+1 transparent pixels.
110 LLLLLE10 = A run of length L+1 solid pixels. If E then this is the
111 last run on this line.
112 LLLLLE11 = A run of length L+1 intermediate pixels followed by L+1
113 bytes of literal pixel data. If E then this is the last run
118 fz_storable storable;
122 unsigned char data[1];
125 static unsigned int fz_glyph_size(fz_context *ctx, fz_glyph *glyph);
127 fz_irect *fz_glyph_bbox_no_ctx(fz_glyph *src, fz_irect *bbox);
129 static inline unsigned int
130 fz_glyph_size(fz_context *ctx, fz_glyph *glyph)
134 return sizeof(fz_glyph) + glyph->size + fz_pixmap_size(ctx, glyph->pixmap);