Class Font
java.lang.Object
com.github.darksoulq.abyssallib.server.resource.asset.Font
- All Implemented Interfaces:
Asset
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents a font glyph.static final recordA spacing glyph that adjusts character advance.static final recordA glyph from a bitmap texture.static final recordTTF font provider.static final recordUnihex font provider with size overrides. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty Font.Constructs a new Font from pre-compiled byte data.Loads a font definition from plugin resources, supports only single-char bitmap providers. -
Method Summary
Modifier and TypeMethodDescriptionvoidEmits this font to a JSON file format.static @Nullable net.kyori.adventure.text.ComponentRetrieves a mapped glyph component globally by its registered namespace and name.@NotNull Font.TextureGlyphCreates a texture glyph (bitmap glyph) without registering a global tag resolver.@NotNull Font.TextureGlyphCreates a named texture glyph (bitmap glyph) and registers it globally for tag resolution.@NotNull List<LinkedList<Font.Glyph>> Converts a texture atlas into glyphs split into rows.@NotNull Font.OffsetGlyphoffset(int pixelOffset, char unicode) Creates an offset glyph that affects spacing only.voidRegisters a TrueType font provider.voidunihex(@NotNull File zipFile, @NotNull List<Font.UnihexFont.Override> overrides) Registers a Unihex ZIP provider.
-
Constructor Details
-
Font
-
Font
Constructs a new Font from pre-compiled byte data.- Parameters:
namespace- The font's namespace.id- The font's identifier (usually filename without extension).data- The raw byte data representing the font JSON.
-
Font
public Font(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String namespace, @NotNull @NotNull String id) Loads a font definition from plugin resources, supports only single-char bitmap providers.- Parameters:
plugin- The plugin providing the resource.namespace- Namespace for this font.id- Font identifier (without .json).- Throws:
IllegalStateException- If the requested resource path cannot be located.RuntimeException- If an I/O error occurs during file reading or parsing.
-
-
Method Details
-
getGlyph
@Nullable public static @Nullable net.kyori.adventure.text.Component getGlyph(@NotNull @NotNull String namespace, @NotNull @NotNull String name) Retrieves a mapped glyph component globally by its registered namespace and name.- Parameters:
namespace- The namespace the glyph was registered under.name- The unique identifier name of the glyph.- Returns:
- The text component representation of the glyph, or null if absent.
-
offset
Creates an offset glyph that affects spacing only.- Parameters:
pixelOffset- The horizontal offset in pixels.unicode- The specific unicode character to map the offset to.- Returns:
- The created
Font.OffsetGlyph.
-
ttf
public void ttf(@NotNull @NotNull File ttfFile, int shiftX, int shiftY, int size, int oversample) throws IOException Registers a TrueType font provider.- Parameters:
ttfFile- The TTF file.shiftX- X offset for rendering.shiftY- Y offset for rendering.size- Size of font in pixels.oversample- Oversample factor.- Throws:
IOException- If the file fails to load or parse.IllegalStateException- If a detected unicode character is already occupied.
-
unihex
public void unihex(@NotNull @NotNull File zipFile, @NotNull @NotNull List<Font.UnihexFont.Override> overrides) throws IOException Registers a Unihex ZIP provider.- Parameters:
zipFile- ZIP file containing .hex glyphs.overrides- List of overrides for character sizing.- Throws:
IOException- If loading the ZIP fails.IllegalStateException- If a detected unicode character is already occupied.
-
glyph
@NotNull public @NotNull Font.TextureGlyph glyph(@NotNull @NotNull String name, @NotNull @NotNull Texture texture, int height, int ascent) Creates a named texture glyph (bitmap glyph) and registers it globally for tag resolution.- Parameters:
name- The name of the glyph used for the tag resolver.texture- The texture used by the glyph.height- The height of the image.ascent- The ascent of the glyph.- Returns:
- The glyph that has been created.
-
glyph
@NotNull public @NotNull Font.TextureGlyph glyph(@NotNull @NotNull Texture texture, int height, int ascent) Creates a texture glyph (bitmap glyph) without registering a global tag resolver.- Parameters:
texture- The texture used by the glyph.height- The height of the image.ascent- The ascent of the glyph.- Returns:
- The glyph that has been created.
-
glyphs
@NotNull public @NotNull List<LinkedList<Font.Glyph>> glyphs(@NotNull @NotNull Texture texture, int spriteW, int spriteH, int height, int ascent) Converts a texture atlas into glyphs split into rows.- Parameters:
texture- Texture data.spriteW- Width of a single glyph.spriteH- Height of a single glyph.height- Glyph visual height.ascent- Glyph ascent.- Returns:
- Glyphs grouped by texture rows.
-
emit
-