#ifndef MUPDF_FITZ_GLYPH_H1#define MUPDF_FITZ_GLYPH_H23#include "mupdf/fitz/system.h"4#include "mupdf/fitz/context.h"5#include "mupdf/fitz/math.h"6#include "mupdf/fitz/store.h"7#include "mupdf/fitz/colorspace.h"89/*10Glyphs represent a run length encoded set of pixels for a 211dimensional region of a plane.12*/13typedef struct fz_glyph_s fz_glyph;1415/*16fz_glyph_bbox: Return the bounding box for a glyph.17*/18fz_irect *fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph, fz_irect *bbox);1920/*21fz_glyph_width: Return the width of the glyph in pixels.22*/23int fz_glyph_width(fz_context *ctx, fz_glyph *glyph);2425/*26fz_glyph_height: Return the height of the glyph in pixels.27*/28int fz_glyph_height(fz_context *ctx, fz_glyph *glyph);2930/*31fz_new_glyph_from_pixmap: Create a new glyph from a pixmap3233Returns a pointer to the new glyph. Throws exception on failure to34allocate.35*/36fz_glyph *fz_new_glyph_from_pixmap(fz_context *ctx, fz_pixmap *pix);3738/*39fz_new_glyph_from_8bpp_data: Create a new glyph from 8bpp data4041x, y: X and Y position for the glyph4243w, h: Width and Height for the glyph4445sp: Source Pointer to data4647span: Increment from line to line of data4849Returns a pointer to the new glyph. Throws exception on failure to50allocate.51*/52fz_glyph *fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);5354/*55fz_new_glyph_from_1bpp_data: Create a new glyph from 1bpp data5657x, y: X and Y position for the glyph5859w, h: Width and Height for the glyph6061sp: Source Pointer to data6263span: Increment from line to line of data6465Returns a pointer to the new glyph. Throws exception on failure to66allocate.67*/68fz_glyph *fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);6970/*71fz_keep_glyph: Take a reference to a glyph.7273pix: The glyph to increment the reference for.7475Returns pix. Does not throw exceptions.76*/77fz_glyph *fz_keep_glyph(fz_context *ctx, fz_glyph *pix);7879/*80fz_drop_glyph: Drop a reference and free a glyph.8182Decrement the reference count for the glyph. When no83references remain the glyph will be freed.8485Does not throw exceptions.86*/87void fz_drop_glyph(fz_context *ctx, fz_glyph *pix);8889/*90Glyphs represent a set of pixels for a 2 dimensional region of a91plane.9293x, y: The minimum x and y coord of the region in pixels.9495w, h: The width and height of the region in pixels.9697samples: The sample data. The sample data is in a compressed format98designed to give reasonable compression, and to be fast to plot from.99100The first sizeof(int) * h bytes of the table, when interpreted as101ints gives the offset within the data block of that lines data. An102offset of 0 indicates that that line is completely blank.103104The data for individual lines is a sequence of bytes:10500000000 = end of lines data106LLLLLL00 = extend the length given in the next run by the 6 L bits107given here.108LLLLLL01 = A run of length L+1 transparent pixels.109LLLLLE10 = A run of length L+1 solid pixels. If E then this is the110last run on this line.111LLLLLE11 = A run of length L+1 intermediate pixels followed by L+1112bytes of literal pixel data. If E then this is the last run113on this line.114*/115struct fz_glyph_s116{117fz_storable storable;118int x, y, w, h;119fz_pixmap *pixmap;120int size;121unsigned char data[1];122};123124static unsigned int fz_glyph_size(fz_context *ctx, fz_glyph *glyph);125126fz_irect *fz_glyph_bbox_no_ctx(fz_glyph *src, fz_irect *bbox);127128static inline unsigned int129fz_glyph_size(fz_context *ctx, fz_glyph *glyph)130{131if (glyph == NULL)132return 0;133return sizeof(fz_glyph) + glyph->size + fz_pixmap_size(ctx, glyph->pixmap);134}135136#endif137138139