Skip to content

Custom Fonts

Maximilian Dorn edited this page Sep 5, 2022 · 1 revision

Custom Fonts

maps supports custom fonts since 3.4.0.

Usage

// Built-in Minecraft font
MapFont font = MapFont.MINECRAFT_FONT;

// Convert Bukkit font
font = MapFont.fromBukkit(MinecraftFont.Font);

// Load Java font
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, new File("MyFont.ttf")).deriveFont(32f);
// Convert Java font into maps font
font = FontConverter.convertAllUnicode(javaFont);

// Draw text
MapGraphics<?, ?> graphics = ...;
graphics.drawText(5, 5, "Hello World", font, ColorCache.rgbToMap(0, 0, 0), 1);

Non-ascii characters

Non-ascii characters, like the Cyrillic characters, are supported (but only if the provided font supports those characters).

Image showing Hello World text in Russian

Limitations

Non-standard fonts (cursive, italic, ...) will likely be cut off. I'm not sure why this happens and don't know how to fix it, but I hope this will be addressed in the future.

Image showing font with cut-off glyphs