Package io.github.nacvark.hudengine.api
Interface HudMetrics
public interface HudMetrics
Pixel measurement against a HUD's real fonts.
Element keys come from build/manifest.json, which the engine writes on every compile.
They read as <layout>_text_<n>, numbered in the order the layout declares its texts.
Useful because a HUD's text is rasterised at a specific size from specific glyphs, so its width has nothing to do with character count. Wrapping a quest description by counting characters gives ragged lines; wrapping it with these gives the lines the player will actually see.
-
Method Summary
-
Method Details
-
width
Width of a string in HUD pixels.- Throws:
IllegalArgumentException- if the element does not exist or is not a text element
-
wrap
Wraps text to a pixel width. Existing newlines are honoured, and a word too long for a whole line is broken by character rather than left to overflow.- Throws:
IllegalArgumentException- if the element does not exist or is not a text element
-