X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fsvgtiny.c;h=a70be0f50643530e86d9639204cc64b4569e3764;hb=7b8fc7bb381c266a4f1ecde5b10bb4c09e2f9bc0;hp=4c88f6b0d757cc9795a3d64674573e8e2ab1021a;hpb=856d554a5808870d1359fdc4e21ff4bba950e456;p=libsvgtiny.git diff --git a/src/svgtiny.c b/src/svgtiny.c index 4c88f6b..a70be0f 100644 --- a/src/svgtiny.c +++ b/src/svgtiny.c @@ -628,7 +628,22 @@ svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram, dom_element *svg; dom_string *svg_name; lwc_string *svg_name_lwc; - struct svgtiny_parse_state state; + struct svgtiny_parse_state state = { + /* Initialize the unit context here because it has a + * const member and doing it any other way subverts + * the type system. The magic numbers below were taken + * from the libcss example program without much + * thought, because at the moment we don't support any + * properties with units. */ + .unit_ctx = { + .font_size_default = FLTTOFIX(16.0), + .font_size_minimum = FLTTOFIX(6.0), + .device_dpi = FLTTOFIX(96.0), + .root_style = NULL, + .pw = NULL, + .measure = NULL, + } + }; float x, y, width, height; svgtiny_code code; @@ -716,6 +731,11 @@ svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram, return svgtiny_LIBCSS_ERROR; } + /* ...and the unit context, whose other fields were + * initialized along with the parser state itself */ + state.unit_ctx.viewport_width = FLTTOFIX(viewport_width); + state.unit_ctx.viewport_height = FLTTOFIX(viewport_height); + #define SVGTINY_STRING_ACTION2(s,n) \ if (dom_string_create_interned((const uint8_t *) #n, \ strlen(#n), &state.interned_##s) \