Changes in uspace/lib/draw/font.h [2cc1ec0:6d5e378] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/draw/font.h
r2cc1ec0 r6d5e378 1 1 /* 2 2 * Copyright (c) 2012 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha4 3 * All rights reserved. 5 4 * … … 46 45 typedef struct drawctx drawctx_t; 47 46 48 typedef int metric_t; 47 typedef enum { 48 FONT_DECODER_EMBEDDED 49 } font_decoder_type_t; 49 50 50 51 typedef struct { 51 /* Horizontal distance between origin and left side of the glyph */ 52 metric_t left_side_bearing; 53 54 /* Width of the actual glyph drawn */ 55 metric_t width; 56 57 /* Horizontal distance between right side of the glyph and origin 58 of the next glyph */ 59 metric_t right_side_bearing; 60 61 /* Vertical distance between baseline and top of the glyph 62 (positive to top) */ 63 metric_t ascender; 64 65 /* Height of the actual glyph drawn */ 66 metric_t height; 67 } glyph_metrics_t; 52 void (*init)(char *, uint16_t *, void **); 53 uint16_t (*resolve)(const wchar_t, void *); 54 surface_t *(*render)(uint16_t, uint16_t); 55 void (*release)(void *); 56 } font_decoder_t; 68 57 69 static inline metric_t glyph_metrics_get_descender(glyph_metrics_t *gm) 70 { 71 return gm->height - gm->ascender; 72 } 73 74 static inline metric_t glyph_metrics_get_advancement(glyph_metrics_t *gm) 75 { 76 return gm->left_side_bearing + gm->width + gm->right_side_bearing; 77 } 78 79 typedef struct { 80 /* Distance between top of the line and baseline */ 81 metric_t ascender; 82 83 /* Distance between baseline and bottom of the line */ 84 metric_t descender; 85 86 /* Distance between bottom of the line and top of the next line */ 87 metric_t leading; 88 } font_metrics_t; 89 90 typedef uint32_t glyph_id_t; 91 92 typedef struct { 93 int (*get_font_metrics)(void *, font_metrics_t *); 94 int (*resolve_glyph)(void *, wchar_t, glyph_id_t *); 95 int (*get_glyph_metrics)(void *, glyph_id_t, glyph_metrics_t *); 96 int (*render_glyph)(void *, drawctx_t *, source_t *, sysarg_t, 97 sysarg_t, glyph_id_t); 98 void (*release)(void *); 99 } font_backend_t; 100 101 typedef struct { 102 font_backend_t *backend; 103 void *backend_data; 58 typedef struct font { 59 uint16_t points; 60 uint16_t glyph_count; 61 surface_t **glyphs; 62 font_decoder_t *decoder; 63 void *decoder_data; 104 64 } font_t; 105 65 106 extern font_t *font_create(font_backend_t *, void *); 107 extern int font_get_metrics(font_t *, font_metrics_t *); 108 extern int font_resolve_glyph(font_t *, wchar_t, glyph_id_t *); 109 extern int font_get_glyph_metrics(font_t *, glyph_id_t, glyph_metrics_t *); 110 extern int font_render_glyph(font_t *, drawctx_t *, source_t *, 111 sysarg_t, sysarg_t, glyph_id_t); 66 extern void font_init(font_t *, font_decoder_type_t, char *, uint16_t); 112 67 extern void font_release(font_t *); 113 68 114 extern intfont_get_box(font_t *, char *, sysarg_t *, sysarg_t *);115 extern intfont_draw_text(font_t *, drawctx_t *, source_t *, const char *,69 extern void font_get_box(font_t *, char *, sysarg_t *, sysarg_t *); 70 extern void font_draw_text(font_t *, drawctx_t *, source_t *, const char *, 116 71 sysarg_t, sysarg_t); 117 72
Note:
See TracChangeset
for help on using the changeset viewer.