Bukkit/Bukkit — pull request #858 by eueln (2013-04-15 22:28:54+00:00)
Title: [B] Account for spacing in MapFont#getWidth(). Fixes BUKKIT-4089

(Note that [there was a PR for this before](https://github.com/Bukkit/Bukkit/pull/768), but that one doesn't follow the new PR conventions)

### The issue

The implementation of MapFont#getWidth(String) does not accurately reflect the width of the input, unless the input consists of 1 or less characters.

This is evident when looking at CraftBukkit's implementation of MapCanvas#drawText(), which contains [this line][0]:

x += sprite.getWidth() + 1;

This line defines a 1-px space added after each character, which is not reflected in [the current MapFont#getWidth()][1].

### PR Breakdown

This change first checks if the String contains 0 characters (as to not inaccurately report a width of -1) and returns `0` if this is the case.

After the character widths are added together, `text.length() - 1` is added to account for the 1-px spacing between characters

### Testing results and Materials

[The original PR submitter had a compelling test case](https://github.com/Bukkit/Bukkit/pull/768#issuecomment-13403025).

In addition, see [CraftMapCanvas#drawText()][0] to identify that there are no edge cases in regard to spacing the characters; *every character* has a 1-px spacer appended to the end.

### JIRA Ticket

BUKKIT-4089 - https://bukkit.atlassian.net/browse/BUKKIT-4089

[0]: https://github.com/Bukkit/CraftBukkit/blob/61e57e1196fc917d0e8f9c5f1ee48818a85fd5b9/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java#L106
[1]: https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java#L106