Replace   with thin non-breaking space   for byte sizes

The latter has more consistent/predictable width between fonts & point sizes.
This commit is contained in:
str4d
2017-03-06 03:46:56 +00:00
parent 10a021f5fc
commit d7e5aaf919
2 changed files with 18 additions and 14 deletions

View File

@ -2565,13 +2565,15 @@ public class I2PSnarkServlet extends BasicServlet {
// rounding makes us look faster :)
private static String formatSize(long bytes) {
if (bytes < 5000)
return bytes + "&nbsp;B";
// replace &nbsp; with narrow non-breaking space (&#8239;)
return bytes + "&#8239;B";
else if (bytes < 5*1024*1024)
return ((bytes + 512)/1024) + "&nbsp;KB";
return ((bytes + 512)/1024) + "&#8239;KB";
else if (bytes < 10*1024*1024*1024l)
return ((bytes + 512*1024)/(1024*1024)) + "&nbsp;MB";
return ((bytes + 512*1024)/(1024*1024)) + "&#8239;MB";
else
return ((bytes + 512*1024*1024)/(1024*1024*1024)) + "&nbsp;GB";
return ((bytes + 512*1024*1024)/(1024*1024*1024)) + "&#8239;GB";
}
/**
@ -2942,7 +2944,7 @@ public class I2PSnarkServlet extends BasicServlet {
if (uploaded > 0) {
double ratio = uploaded / ((double) snark.getTotalLength());
buf.append((new DecimalFormat("0.000")).format(ratio));
buf.append("&nbsp;x");
buf.append("&#8239;x");
} else {
buf.append('0');
}