Fix RelativeSizeSpan handling in SpannedToHtmlConverter

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

PiperOrigin-RevId: 309946004
This commit is contained in:
ibaker 2020-05-05 15:59:50 +01:00 committed by Oliver Woodman
parent 635886449a
commit 5117138481
2 changed files with 2 additions and 2 deletions

View file

@ -148,7 +148,7 @@ import java.util.regex.Pattern;
return Util.formatInvariant("<span style='font-size:%.2fpx;'>", sizeCssPx);
} else if (span instanceof RelativeSizeSpan) {
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) {
@Nullable String fontFamily = ((TypefaceSpan) span).getFamily();
return fontFamily != null

View file

@ -135,7 +135,7 @@ public class SpannedToHtmlConverterTest {
public void convert_supportsRelativeSizeSpan() {
SpannableString spanned = new SpannableString("String with 10% section");
spanned.setSpan(
new RelativeSizeSpan(/* proportion= */ 10),
new RelativeSizeSpan(/* proportion= */ 0.1f),
"String with ".length(),
"String with 10%".length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);