diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-10-15 14:43:15 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-12-03 12:25:51 +0100 |
commit | 1ce69ac127c823463204ad522bb7c71ac7fad27a (patch) | |
tree | 7814d15bc5f50a714c22eb33d70de63a6773ab28 | |
parent | 5cb1a29be4993d72cf6ab2af128135e2b7e40dd2 (diff) | |
download | mupdf-1ce69ac127c823463204ad522bb7c71ac7fad27a.tar.xz |
html: Use float for dimensions.
-rw-r--r-- | include/mupdf/html.h | 14 | ||||
-rw-r--r-- | source/html/css-apply.c | 22 | ||||
-rw-r--r-- | source/html/layout.c | 2 |
3 files changed, 19 insertions, 19 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h index 8a1eaa3c..2b46fc9a 100644 --- a/include/mupdf/html.h +++ b/include/mupdf/html.h @@ -103,21 +103,21 @@ struct computed_style { int display; int position; - int top, right, bottom, left; - int margin[4]; - int padding[4]; - int border_width[4]; + float top, right, bottom, left; + float margin[4]; + float padding[4]; + float border_width[4]; int border_style; struct color border_color; struct color color; struct color background_color; const char *font_family; int bold, italic, smallcaps; - int font_size; - int line_height; + float font_size; + float line_height; int vertical_align; int text_align; - int text_indent; + float text_indent; }; void apply_styles(struct style *style, struct rule *rule, fz_xml *node); diff --git a/source/html/css-apply.c b/source/html/css-apply.c index 550ade85..d38d999e 100644 --- a/source/html/css-apply.c +++ b/source/html/css-apply.c @@ -696,8 +696,8 @@ get_style_property_string(struct style *node, const char *name, const char *init return value->data; } -static int -compute_number(struct value *value, int em, int hundred, int scale, int initial) +static float +compute_number(struct value *value, float em, float hundred, float scale, float initial) { char *p; @@ -722,9 +722,9 @@ compute_number(struct value *value, int em, int hundred, int scale, int initial) if (p[0] == 'i' && p[1] == 'n') return x * 72; if (p[0] == 'c' && p[1] == 'm') - return x * 72 / 2.54; + return x * 7200 / 254; if (p[0] == 'm' && p[1] == 'm') - return x * 72 / 25.4; + return x * 720 / 254; if (p[0] == 'p' && p[1] == 'c') return x * 12; @@ -743,8 +743,8 @@ void compute_style(struct computed_style *style, struct style *node) { struct value *value; - int em = 12; - int hundred = 100; + float em = 12; + float hundred = 100; memset(style, 0, sizeof *style); @@ -875,13 +875,13 @@ print_style(struct computed_style *style) printf("\tfont-weight = %s;\n", style->bold ? "bold" : "normal"); printf("\tfont-style = %s;\n", style->italic ? "italic" : "normal"); printf("\tfont-variant = %s;\n", style->smallcaps ? "small-caps" : "normal"); - printf("\tfont-size = %d;\n", style->font_size); - printf("\tline-height = %d;\n", style->line_height); - printf("\ttext-indent = %d;\n", style->text_indent); + printf("\tfont-size = %g;\n", style->font_size); + printf("\tline-height = %g;\n", style->line_height); + printf("\ttext-indent = %g;\n", style->text_indent); printf("\tvertical-align = %d;\n", style->vertical_align); - printf("\tmargin = %d %d %d %d;\n", + printf("\tmargin = %g %g %g %g;\n", style->margin[0], style->margin[1], style->margin[2], style->margin[3]); - printf("\tpadding = %d %d %d %d;\n", + printf("\tpadding = %g %g %g %g;\n", style->padding[0], style->padding[1], style->padding[2], style->padding[3]); printf("}\n"); } diff --git a/source/html/layout.c b/source/html/layout.c index 14edc5ef..372a495d 100644 --- a/source/html/layout.c +++ b/source/html/layout.c @@ -22,7 +22,7 @@ static const char *default_css = "sub{vertical-align:sub}" "sup{vertical-align:super}" "s,strike,del{text-decoration:line-through}" -"hr{border:1pxinset}" +"hr{border:1px inset}" "ol,ul,dir,menu,dd{margin-left:40px}" "ol{list-style-type:decimal}" "ol ul,ul ol,ul ul,ol ol{margin-top:0;margin-bottom:0}" |