Skip to content

[Feature Request] Asset Manager loader for Distance Field fonts #377

Open
@rubybrowncoat

Description

@rubybrowncoat

A loader for asset manager in the vein of what was done with ktx-freetype but for distance field fonts: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts

A loader for this type of fonts might be desirable, I couldn't figure out how to integrate the loading method specified in the wiki with my asset manager setup.


Alternatively to that, I have used https://github.com/maltaisn/msdf-gdx to load msdf fonts seamlessly like this, because the library includes a loader and I just needed to load it onto the Asset Manager:

val assetManager = AssetManager()
assetManager.setLoader(MsdfFontLoader(InternalFileHandleResolver()))

enum class DistanceFieldFontAssets(val path: String) {
    DankMono32("skin/dank-mono-48-msdf.fnt"),
}

fun AssetManager.load(asset: DistanceFieldFontAssets) = load<MsdfFont>(asset.path)
operator fun AssetManager.get(asset: DistanceFieldFontAssets) = getAsset<MsdfFont>(asset.path)

DistanceFieldFontAssets.values().forEach { assetManager.load(it).finishLoading() }

I'm not sure about all the differences between the distance field fonts described on the libgdx wiki and the ones used by the msdf library, so I can't really say if using that library is sufficient to cover the use cases set forth by the libgdx wiki.

Metadata

Metadata

Assignees

No one assigned

    Labels

    assetsIssues of the ktx-assets modulehelp wantedMore advanced tasks that might require advanced knowledge of Kotlin, KTX or LibGDX

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions