Commit 51171384 by ibaker Committed by Oliver Woodman

Fix RelativeSizeSpan handling in SpannedToHtmlConverter

A silly mistake of confusing a fractional float with a percentage.

PiperOrigin-RevId: 309946004
parent 63588644
...@@ -148,7 +148,7 @@ import java.util.regex.Pattern; ...@@ -148,7 +148,7 @@ import java.util.regex.Pattern;
return Util.formatInvariant("<span style='font-size:%.2fpx;'>", sizeCssPx); return Util.formatInvariant("<span style='font-size:%.2fpx;'>", sizeCssPx);
} else if (span instanceof RelativeSizeSpan) { } else if (span instanceof RelativeSizeSpan) {
return Util.formatInvariant( return Util.formatInvariant(
"<span style='font-size:%.2f%%;'>", ((RelativeSizeSpan) span).getSizeChange()); "<span style='font-size:%.2f%%;'>", ((RelativeSizeSpan) span).getSizeChange() * 100);
} else if (span instanceof TypefaceSpan) { } else if (span instanceof TypefaceSpan) {
@Nullable String fontFamily = ((TypefaceSpan) span).getFamily(); @Nullable String fontFamily = ((TypefaceSpan) span).getFamily();
return fontFamily != null return fontFamily != null
......
...@@ -135,7 +135,7 @@ public class SpannedToHtmlConverterTest { ...@@ -135,7 +135,7 @@ public class SpannedToHtmlConverterTest {
public void convert_supportsRelativeSizeSpan() { public void convert_supportsRelativeSizeSpan() {
SpannableString spanned = new SpannableString("String with 10% section"); SpannableString spanned = new SpannableString("String with 10% section");
spanned.setSpan( spanned.setSpan(
new RelativeSizeSpan(/* proportion= */ 10), new RelativeSizeSpan(/* proportion= */ 0.1f),
"String with ".length(), "String with ".length(),
"String with 10%".length(), "String with 10%".length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment