bdf_glyph.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _BDF_GLYPH_H
  2. #define _BDF_GLYPH_H
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. /* forward def */
  6. typedef struct _bdf_font_struct bf_t;
  7. struct _bbx_struct
  8. {
  9. long w;
  10. long h;
  11. long x;
  12. long y;
  13. };
  14. typedef struct _bbx_struct bbx_t;
  15. struct _bdf_glyph_struct
  16. {
  17. bf_t *bf;
  18. long encoding;
  19. long map_to;
  20. long dwidth_x;
  21. long dwidth_y;
  22. bbx_t bbx; /* x,y are delta x,y from glyph, w,h start wth bitmap dimension, but may be reduced */
  23. long shift_x; /* extra shift for BDF_BBX_MODE_HEIGHT alignment */
  24. int is_excluded_from_kerning;
  25. uint8_t *bitmap_data;
  26. int bitmap_width; /* the physical width within "bitmap_data", will be larger than or equal to bbx.w */
  27. int bitmap_height;
  28. //int actual_bitmap_width; /* identical to bbx.w, maybe replace actual_bitmap_width by bbx.w */
  29. //int actual_bitmap_height; /* identical to bbx.h, maybe replace actual_bitmap_height by bbx.h */
  30. uint8_t *target_data; /* if this is not NULL, then there is a valid glyph */
  31. int target_max; /* 32 bit value */
  32. int target_cnt; /* 32 bit value */
  33. int target_bit_pos;
  34. /* rle data */
  35. unsigned rle_bits_per_0;
  36. unsigned rle_bits_per_1;
  37. int rle_is_first;
  38. unsigned rle_bitcnt;
  39. unsigned rle_last_0;
  40. unsigned rle_last_1;
  41. long width_deviation; /* filled by bf_copy_bbx_and_update_shift for statistics */
  42. };
  43. typedef struct _bdf_glyph_struct bg_t;
  44. bg_t *bg_Open(void);
  45. void bg_Close(bg_t *bg);
  46. int bg_AddTargetData(bg_t *bg, uint8_t data);
  47. void bg_ClearTargetData(bg_t *bg);
  48. int bg_AddTargetBits(bg_t *bg, unsigned cnt, unsigned val);
  49. int bg_FlushTargetBits(bg_t *bg);
  50. int bg_SetBitmapSizeInBytes(bg_t *bg, size_t bytes);
  51. int bg_SetBitmapSize(bg_t *bg, int w, int h);
  52. void bg_SetBitmapPixel(bg_t *bg, int x, int y, int value);
  53. int bg_GetBitmapPixel(bg_t *bg, int x, int y);
  54. int bg_GetBBXPixel(bg_t *bg, int x, int y);
  55. void bg_ShowBitmap(bg_t *bg, bbx_t *bbx);
  56. void bg_ReduceGlyph(bg_t *bg);
  57. int bg_Max(bg_t *bg, bbx_t *max); /* returns idx which describes glyph expansion */
  58. /* bdf_rle.c */
  59. int bg_rle_compress(bg_t *bg, bbx_t *bbx, unsigned rle_bits_per_0, unsigned rle_bits_per_1, int is_output);
  60. #endif