E-book viewer: Fix regression in 5.15 that caused incorrect display of font sizes that contain a period and use absolute units. Fixes #1929862 [Font size transformed incorrectly](https://bugs.launchpad.net/calibre/+bug/1929862)

This commit is contained in:
Kovid Goyal 2021-05-28 06:13:43 +05:30
parent eeb4e069ab
commit 1ddac886a4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 3 deletions

View File

@ -97,7 +97,7 @@ static const double base_font_size = 16.0, dpi = 96.0, pt_to_px = dpi / 72.0, pt
static double static double
convert_font_size(double val, double factor) { convert_font_size(double val, double factor) {
return (factor == 0.0) ? val / base_font_size : (val * factor * pt_to_rem); return (factor == 0.0) ? (val / base_font_size) : (val * factor * pt_to_rem);
} }
static integer_type static integer_type
@ -975,8 +975,7 @@ class Parser {
} }
void handle_number() { void handle_number() {
if (is_digit(ch)) { token_queue.add_char(ch); return; } if (is_digit(ch) || (ch == '.' && is_digit(peek()))) { token_queue.add_char(ch); return; }
if (ch == '.' && is_digit(peek())) { pop_state(); enter_digits_mode(); return; }
if (starting_comment()) { enter_comment_mode(); return; } if (starting_comment()) { enter_comment_mode(); return; }
if ((ch == 'e' || ch == 'E')) { if ((ch == 'e' || ch == 'E')) {
char32_t next = peek(); char32_t next = peek();

View File

@ -50,6 +50,10 @@ class TestTransform(SimpleTest):
u('a:url( "( )" /**/ )', 'a:url("( )")') u('a:url( "( )" /**/ )', 'a:url("( )")')
u('a:url( "(/*)" )', 'a:url( "(/*)" )', url_callback=lambda x: x) u('a:url( "(/*)" )', 'a:url( "(/*)" )', url_callback=lambda x: x)
d('font-size: 19.28px', 'font-size: 1.205rem')
d('font-size:+19.28px', 'font-size:1.205rem')
d('font-size: .28in', 'font-size: 1.68rem')
d('font-size: +.28in', 'font-size: 1.68rem')
d(r'f\ont-s\69z\65 : 16\px', 'font-size: 1rem') d(r'f\ont-s\69z\65 : 16\px', 'font-size: 1rem')
d('font -size: 16px', 'font -size: 16px') d('font -size: 16px', 'font -size: 16px')
d('font-/* */size: 1/*x*/6/**/p/**/x !important', 'font-size: 1rem !important') d('font-/* */size: 1/*x*/6/**/p/**/x !important', 'font-size: 1rem !important')