ufont_internal.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Internal interfaces between the ufont cache/metrics layer and the
  2. * fixed-point TrueType parser/rasterizer. Not part of the app ABI. */
  3. #ifndef UFONT_INTERNAL_H
  4. #define UFONT_INTERNAL_H
  5. #define UFONT_MAX_FACES 16
  6. #define UFONT_MAX_POINTS 256
  7. #define UFONT_MAX_CONTOURS 16
  8. struct ufont_face {
  9. unsigned int id;
  10. const unsigned char *data;
  11. unsigned int len;
  12. int upem;
  13. int num_glyphs;
  14. int loca_short;
  15. int num_hmetrics;
  16. int ascent; /* font units, hhea */
  17. int descent; /* font units, negative */
  18. int line_gap; /* font units */
  19. const unsigned char *loca;
  20. const unsigned char *glyf;
  21. unsigned int glyf_len;
  22. const unsigned char *hmtx;
  23. const unsigned char *cmap4;
  24. unsigned int cmap4_len;
  25. const unsigned char *cmap12;
  26. unsigned int cmap12_len;
  27. unsigned int cmap12_groups;
  28. };
  29. /* Parse the sfnt directory and fill the face; 0 on success. */
  30. int ufont_ttf_load(struct ufont_face *f, const unsigned char *data,
  31. unsigned int len);
  32. int ufont_ttf_glyph_index(const struct ufont_face *f, unsigned int cp);
  33. /* Advance in 26.6 pixels. */
  34. int ufont_ttf_advance(const struct ufont_face *f, int glyph, int px);
  35. /* Bitmap box relative to the pen origin (x right, y down from baseline).
  36. * Returns 0 on success; w/h are 0 for an empty glyph. */
  37. int ufont_ttf_bbox(const struct ufont_face *f, int glyph, int px,
  38. int *xoff, int *yoff, int *w, int *h);
  39. /* Rasterize into mask[w*h] (zeroed by the caller); 0 on success. */
  40. int ufont_ttf_raster(const struct ufont_face *f, int glyph, int px,
  41. int xoff, int yoff, int w, int h, unsigned char *mask);
  42. /* Arena helpers shared with ufont.c. */
  43. void *ufont_arena_alloc(unsigned int bytes, unsigned int align);
  44. void ufont_arena_mark(unsigned int mark);
  45. unsigned int ufont_arena_used(void);
  46. #endif