Changes in uspace/lib/draw/font.h [2cc1ec0:6d5e378] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/draw/font.h

    r2cc1ec0 r6d5e378  
    11/*
    22 * Copyright (c) 2012 Petr Koupy
    3  * Copyright (c) 2014 Martin Sucha
    43 * All rights reserved.
    54 *
     
    4645typedef struct drawctx drawctx_t;
    4746
    48 typedef int metric_t;
     47typedef enum {
     48        FONT_DECODER_EMBEDDED
     49} font_decoder_type_t;
    4950
    5051typedef 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;
    6857
    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;
     58typedef struct font {
     59        uint16_t points;
     60        uint16_t glyph_count;
     61        surface_t **glyphs;
     62        font_decoder_t *decoder;
     63        void *decoder_data;
    10464} font_t;
    10565
    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);
     66extern void font_init(font_t *, font_decoder_type_t, char *, uint16_t);
    11267extern void font_release(font_t *);
    11368
    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 *,
     69extern void font_get_box(font_t *, char *, sysarg_t *, sysarg_t *);
     70extern void font_draw_text(font_t *, drawctx_t *, source_t *, const char *,
    11671    sysarg_t, sysarg_t);
    11772
Note: See TracChangeset for help on using the changeset viewer.