Using FontResolver

How to use the FontResolver to implement your custom fonts

Valid Fonts:

The following are all part of the enum MinecraftKeyFont

  • UNIFORM (Smaller, quirky font)

  • DEFAULT (Default chat text)

  • ALT (Enchanting Table)

Using Differing Fonts

Fonts can only be sent by using the chat component api thus, you will always get a BaseComponent or TextComponent returned.

Using Default Minecraft Fonts

Minecraft only comes with 3 fonts, as shown at the top of the page. When using the FontResolver, you must choose between these 3 to implement into your String. The first parameter is your string and the second parameter is the type of font defined in MinecraftKeyFont.

String text = "My Text in a new Font";
TextComponent component = FontResolver.parseFontString(text, MinecraftKeyFont.UNIFORM);

This can then be sent to the player via player.spigot().sendMessage(component);

Using Custom Fonts

You can also do a grab out of the client's resource pack language folder and use some custom fonts.

If the client does not have the font it can crash / kick the client. Only recommended if resource packs are enforced.

String text = "My Text in a new Font";
TextComponent component = FontResolver.parseFontString(text, "customfont");

These can also be passed a BaseComponent and its subclasses.

Last updated