diff options
author | eueln <euelnd@gmail.com> | 2014-04-11 15:37:15 -0600 |
---|---|---|
committer | turt2live <travpc@gmail.com> | 2014-05-01 17:10:11 -0600 |
commit | 0bf83c077dc503950c9819446fb5d89ed720779e (patch) | |
tree | 80319cd06fa154ac99e82ecd1a137dfbe8d2eca1 /src | |
parent | 2bc71ced8a48ee7ba3663d1a3e7e43768b0e67d9 (diff) | |
download | bukkit-0bf83c077dc503950c9819446fb5d89ed720779e.tar bukkit-0bf83c077dc503950c9819446fb5d89ed720779e.tar.gz bukkit-0bf83c077dc503950c9819446fb5d89ed720779e.tar.lz bukkit-0bf83c077dc503950c9819446fb5d89ed720779e.tar.xz bukkit-0bf83c077dc503950c9819446fb5d89ed720779e.zip |
Account for spacing in MapFont#getWidth(). Fixes BUKKIT-4089
Prior to this commit MapFont#getWidth() did not account for the 1px
spacing inserted by CraftMapCanvas#drawText().
This commit adds the consideration of the 1px spacing per character
while taking care to not consider the last character as it will not
have a 1px space behind it. This commit also ensures the method will
not check a 0-length String.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/map/MapFont.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/map/MapFont.java b/src/main/java/org/bukkit/map/MapFont.java index 84c809f7..ea8f0ea8 100644 --- a/src/main/java/org/bukkit/map/MapFont.java +++ b/src/main/java/org/bukkit/map/MapFont.java @@ -52,10 +52,16 @@ public class MapFont { throw new IllegalArgumentException("text contains invalid characters"); } + if (text.length() == 0){ + return 0; + } + int result = 0; for (int i = 0; i < text.length(); ++i) { result += chars.get(text.charAt(i)).getWidth(); } + result += text.length() - 1; // Account for 1px spacing between characters + return result; } |