Changeset 8e7c9fe in mainline for uspace/lib/draw/font.h
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/draw/font.h
r3eb0c85 r8e7c9fe 1 1 /* 2 2 * Copyright (c) 2012 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 45 46 typedef struct drawctx drawctx_t; 46 47 47 typedef enum { 48 FONT_DECODER_EMBEDDED 49 } font_decoder_type_t; 48 typedef int metric_t; 50 49 51 50 typedef struct { 52 void (*init)(char *, uint16_t *, void **); 53 uint16_t (*resolve)(const wchar_t, void *); 54 surface_t *(*render)(uint16_t, uint16_t); 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; 68 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); 55 98 void (*release)(void *); 56 } font_ decoder_t;99 } font_backend_t; 57 100 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; 101 typedef struct { 102 font_backend_t *backend; 103 void *backend_data; 64 104 } font_t; 65 105 66 extern void font_init(font_t *, font_decoder_type_t, char *, uint16_t); 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); 67 112 extern void font_release(font_t *); 68 113 69 extern voidfont_get_box(font_t *, char *, sysarg_t *, sysarg_t *);70 extern voidfont_draw_text(font_t *, drawctx_t *, source_t *, const char *,114 extern int font_get_box(font_t *, char *, sysarg_t *, sysarg_t *); 115 extern int font_draw_text(font_t *, drawctx_t *, source_t *, const char *, 71 116 sysarg_t, sysarg_t); 72 117
Note:
See TracChangeset
for help on using the changeset viewer.