-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<text>
with font-size="0px"
containing empty <tspan>
followed by whitespaces is rendered in the wrong location
#739
Comments
<text>
with font-size="0px"
containing empty <tspan>
followed by whitespaces is rendered in a wrong location<text>
with font-size="0px"
containing empty <tspan>
followed by whitespaces is rendered in the wrong location
Changing // TODO: what to do when <= 0? UB?
let font_size = super::units::resolve_font_size(parent, state);
let font_size = match NonZeroPositiveF32::new(font_size) {
Some(n) => n,
None => {
// Skip this span.
+++ let pos = pos_list.get(iter_state.chars_count).copied();
iter_state.chars_count += child.text().chars().count();
+++ if iter_state.chars_count < pos_list.len() {
+++ if let Some(pos) = pos {
+++ pos_list[iter_state.chars_count] = pos;
+++ }
+++ }
// iter_state
continue;
}
}; |
Thanks, will take a look. |
Input SVG: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
<text x="40" y="140" font-size="0px">
<tspan></tspan>
<tspan font-size="48px">Text</tspan>
</text>
</svg> Out: <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs/>
<text xml:space="preserve"><tspan><tspan font-family="Times New Roman" font-size="48" fill="#000000" stroke="none">Text</tspan></tspan></text>
</svg> If you remove the first tspan: <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<defs/>
<text xml:space="preserve"><tspan x="40" y="140"><tspan font-family="Times New Roman" font-size="48" fill="#000000" stroke="none">Text</tspan></tspan></text>
</svg> So the underlying issue seems to be that |
@LaurenzV I don't think so. |
Yeah, the nesting of the |
Got it, will take a look. Zero-sized fonts are still UB, therefore we can do whatever we want, but it would be better if we could match Chrome. |
resvg version: 0.41.0
When a
<text>
withfont-size="0px"
starts with an empty<tspan>
followed by whitespace, the<text>
is rendered in the wrong place.Render result:
The text was updated successfully, but these errors were encountered: