Changeset d7e5aaf


Ignore:
Timestamp:
Mar 6, 2017 3:46:56 AM (4 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
4bf0147
Parents:
10a021f
Message:

Replace   with thin non-breaking space   for byte sizes

The latter has more consistent/predictable width between fonts & point sizes.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r10a021f rd7e5aaf  
    25662566    private static String formatSize(long bytes) {
    25672567        if (bytes < 5000)
    2568             return bytes + "&nbsp;B";
     2568
     2569            // replace &nbsp; with narrow non-breaking space (&#8239;)
     2570            return bytes + "&#8239;B";
    25692571        else if (bytes < 5*1024*1024)
    2570             return ((bytes + 512)/1024) + "&nbsp;KB";
     2572            return ((bytes + 512)/1024) + "&#8239;KB";
    25712573        else if (bytes < 10*1024*1024*1024l)
    2572             return ((bytes + 512*1024)/(1024*1024)) + "&nbsp;MB";
     2574            return ((bytes + 512*1024)/(1024*1024)) + "&#8239;MB";
    25732575        else
    2574             return ((bytes + 512*1024*1024)/(1024*1024*1024)) + "&nbsp;GB";
     2576            return ((bytes + 512*1024*1024)/(1024*1024*1024)) + "&#8239;GB";
    25752577    }
    25762578   
     
    29432945                double ratio = uploaded / ((double) snark.getTotalLength());
    29442946                buf.append((new DecimalFormat("0.000")).format(ratio));
    2945                 buf.append("&nbsp;x");
     2947                buf.append("&#8239;x");
    29462948            } else {
    29472949                buf.append('0');
  • core/java/src/net/i2p/data/DataHelper.java

    r10a021f rd7e5aaf  
    15611561        DecimalFormat fmt = new DecimalFormat("##0.00");
    15621562
     1563        // Replace &nbsp; with thin non-breaking space &#8239; (more consistent/predictable width between fonts & point sizes)
     1564
    15631565        String str = fmt.format(val);
    15641566        switch (scale) {
    1565             case 1: return str + "&nbsp;K";
    1566             case 2: return str + "&nbsp;M";
    1567             case 3: return str + "&nbsp;G";
    1568             case 4: return str + "&nbsp;T";
    1569             case 5: return str + "&nbsp;P";
    1570             case 6: return str + "&nbsp;E";
    1571             case 7: return str + "&nbsp;Z";
    1572             case 8: return str + "&nbsp;Y";
    1573             default: return bytes + "&nbsp;";
     1567            case 1: return str + "&#8239;K";
     1568            case 2: return str + "&#8239;M";
     1569            case 3: return str + "&#8239;G";
     1570            case 4: return str + "&#8239;T";
     1571            case 5: return str + "&#8239;P";
     1572            case 6: return str + "&#8239;E";
     1573            case 7: return str + "&#8239;Z";
     1574            case 8: return str + "&#8239;Y";
     1575            default: return bytes + "&#8239;";
    15741576        }
    15751577    }
Note: See TracChangeset for help on using the changeset viewer.