diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2021-05-08 18:03:21 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2021-05-19 14:40:26 +0100 |
commit | 57fa3608e13accc24a45e5d7801a381212c2ff22 (patch) | |
tree | 843795835aabdc39f16da3e9502c143b998b5ae6 /test/select.c | |
parent | f752713d07424217170c6fbf85789bd58d92f924 (diff) | |
download | libcss-57fa3608e13accc24a45e5d7801a381212c2ff22.tar.gz |
Add regression test for system font callback units.
Thanks to Ralf Junker.
Diffstat (limited to 'test/select.c')
-rw-r--r-- | test/select.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/select.c b/test/select.c index 664994e..33f31dd 100644 --- a/test/select.c +++ b/test/select.c @@ -509,6 +509,39 @@ void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len) } } +static css_error css_font_resolution_func(void *pw, lwc_string *name, + css_system_font *system_font) +{ + lwc_error err; + + if (system_font == NULL) { + return CSS_BADPARM; + } + + (void)(pw); + + if (strncmp(lwc_string_data(name), "special-system-font", + lwc_string_length(name)) != 0) { + return CSS_INVALID; + } + + system_font->style = CSS_FONT_STYLE_NORMAL; + system_font->variant = CSS_FONT_VARIANT_NORMAL; + system_font->weight = CSS_FONT_WEIGHT_NORMAL; + system_font->size.size = INTTOFIX(22); + system_font->size.unit = CSS_UNIT_PT; + system_font->line_height.size = INTTOFIX(33); + system_font->line_height.unit = CSS_UNIT_EM; + err = lwc_intern_string("special-system-font", + strlen("special-system-font"), + &system_font->family); + if (err != lwc_error_ok) { + return CSS_NOMEM; + } + + return CSS_OK; +} + void css__parse_sheet(line_ctx *ctx, const char *data, size_t len) { css_stylesheet_params params; @@ -559,7 +592,7 @@ void css__parse_sheet(line_ctx *ctx, const char *data, size_t len) params.import_pw = NULL; params.color = NULL; params.color_pw = NULL; - params.font = NULL; + params.font = css_font_resolution_func; params.font_pw = NULL; /** \todo How are we going to handle @import? */ |