Перейти к содержимому
Mineforgian

Polymer Font Utils

API for generating font files

Загрузки
2K
Подписчики
3
Обновлён
15 декабря 2024 г.
Лицензия
CC0-1.0

Опубликован 25 октября 2024 г.

Polymer Font Utils

API for generating font files. Uses polymer resource pack api.

Example

repositories {
    maven { url "https://api.modrinth.com/maven" }
}

dependencies {
    modImplementation include("maven.modrinth:pfu:0.2.3+1.21.4")
}
public class PolymerFontUtilsTest implements ModInitializer {
    public static FontResourceManager manager;
    public static FontResource resource;
    public static TextResource text;
    public static BitmapGlyph glyph;

    @Override
    public void onInitialize() {
        PolymerResourcePackUtils.addModAssets("pfut");

        manager = FontResourceManager.create("pfut");
        resource = manager.requestFont("test");
        text = manager.requestText(-20); // Font identifier: pfut:text/default_-20
        glyph = resource.requestGlyph("font/icon.png", 128, 32);

        FontSpaceUtils.requestAdvance(-256);
        FontSpaceUtils.requestAdvances(-128, 1, 3);
        FontSpaceUtils.requestRange(2, 19);
    }
}

You can get list of all bitmaps from manager using command /pfu pfut:test

Example

Ченджлог

0.2.3+1.21.4Бета1.21.4 · 15 декабря 2024 г.

TextBuilder

text no longer requires MutableText instead of Text

0.2.2+1.21.4Бета1.21.4 · 15 декабря 2024 г.

BitmapGlyph

  • Fixed image reading
  • glyphWidth and glyphHeight now bases on provider ascent
  • Added formatter() function which returns TextFormatter with glyph

TextResource

Can requested using FontResourceManager#requestText, requests text with vanilla font but custom ascent

text = manager.requestText(-20); // Font identifier: pfut:text/default_-20
0.2.1+1.21.4Бета1.21.4 · 7 декабря 2024 г.

Hotfix

0.2.0+1.21.4Бета1.21.4 · 7 декабря 2024 г.

FontResourceManager

Fully rewrited, for creation requires only mod id, use this class to create FontResource

FontResource

Works like previous version of FontResourceManager

FontSpaceUtils

For resource pack smaller size, all spaces from each mod will be in one file, pfu:spaces, by default it empty, to request space use requestAdvance, requestAdvances or requestRange, to get space MutableText use FontSpaceUtils.spaceMap

Examples

public class PolymerFontUtilsTest implements ModInitializer {
    public static FontResourceManager manager;
    public static FontResource resource;
    public static BitmapGlyph glyph;

    @Override
    public void onInitialize() {
        PolymerResourcePackUtils.addModAssets("pfut");

        manager = FontResourceManager.create("pfut");
        resource = manager.requestFont("test"); // Creates font file "assets/pfut/font/test.json"
        glyph = resource.requestGlyph("font/icon.png", 128, 32);

        FontSpaceUtils.requestAdvance(-256);
        FontSpaceUtils.requestAdvances(-128, 1, 3);
        FontSpaceUtils.requestRange(2, 19);
    }
}
0.1.5+1.21.2Бета1.21.2, 1.21.3, 1.21.4 · 5 ноября 2024 г.

TextBuilder

Like StringBuilder but for text, example:

Text text = new TextBuilder()
  .space(-8)
  .glyph(guiGlyph)
  .text(Text.literal("test text"))
  .build();
0.1.4+1.21.2Бета1.21.2, 1.21.3, 1.21.4 · 2 ноября 2024 г.

Changes

Formatter hotfix, use now TextFormatter#value instead TextFormatter#text

0.1.3+1.21.2Бета1.21.2, 1.21.3, 1.21.4 · 2 ноября 2024 г.

Changes

Moved space, spaceBefore, spaceAfter, offset to TextFormatter, see BitmapGlyph#formatter.

If requesting 0 space, returns empty MutableText.

TextFormatter

Instead of returning MutableText after calling each function, it sets text, example: formatter.spaceBefore(-128).spaceBefore(-64).offset(32).text.

0.1.2+1.21.2Бета1.21.2, 1.21.3, 1.21.4 · 1 ноября 2024 г.

Hotfix

Комментарии

Загружаем…