Jump to content

Recommended Posts

Posted (edited)

Hello, I am reaching out to you because I am unable to solve an update problem.
I had a system for adding fonts (ttf) to Minecraft that worked very well for versions prior to 1.18. However, when I migrated to 1.18.2 and added new fonts, I am no longer able to "display" the characters, it only shows black squares.
I hope someone can help me, you can see below all the code. I'm sure it's something simple but I really can't figure it out...

(The code is really big)

  Reveal hidden contents


Result of my BufferedImage (GlyphPage) (it works fine, but it seems like it can't load the texture or something...)

  Reveal hidden contents



And this the result in game:
image.png

 

Thanks for helping me...

Edited by Snyker
Fixed
Posted

I don't think you will get many people in a forum about forge modding volunteering to help you fix what is really just your own custom open gl font rendering code?

 

I know little about Fonts in minecraft.

But I do know you shouldn't be using AWT in minecraft. Or OpenGL directly.

 

In minecraft Fonts are loaded using a resource pack, e.g. vanilla's fonts:

https://github.com/misode/mcmeta/tree/assets/assets/minecraft/font

and then displayed using chat Components and Style.withFont() - see for example EnchantmentNames for the weird enchanting clue text.

 

Look at FontManager for the details of how fonts get loaded, and I guess TrueTypeGlyphProviderBuilder if you want ttf.

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)

I think this isn't possible cause to load a ttf font you need to use the json file and you need to replace the "default.json" file ... and i want to keep the default font.
I will try but i'm pretty sure this will not work

Thanks for you repost you give me a little hope haha

Edited by Snyker
Posted (edited)

default.json is the default font.

If you want to replace that, you need to make sure your mod has ordering="AFTER" for the forge mod dependency and include a minecraft/font/default.json in your mod.

https://forge.gemwire.uk/wiki/Mods.toml

Otherwise, the font manager iterates over all files in the form namespace/font/fontname.json - you then choose the font using ResourceLocation namespace:fontname

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

Ok so i try many things but no one worked...

TTF file are placed on the same path of the json.

All i try :
 1.a) I follow what you said and replacing the default.json (in my modid/font/ AND minecraft/font) with the forge order to AFTER and BEFORE (notworking) :

{
  "providers": [
    {
      "type": "ttf",
      "file": "pixorcore:font_bitcell.ttf", //or minecraft:font_bitcell.ttf
      "shift": [0.0, -1.0],
      "size": 15,
      "oversample": 2.0
    }
  ]
}

1.b) I setup the Style to conform like EnchantmentNames :

private static final ResourceLocation RHEAD = new ResourceLocation(Constants.MODID, "font/font_bitcell"); //ttf font
private static final ResourceLocation RHEAD = new ResourceLocation(Constants.MODID, "font/bitcell"); //json
public static final Style HEAD_STYLE = Style.EMPTY.withFont(RHEAD);

1.c) And applying it on my TextComponent#withStyle, the render is better but didn't work.  i draw with the default font a text to debug and he didn't change at all.
image.png

2.a) Creating new "bitcell.json" in my modid/font with the content : (See 1.a)
2.b) I testing both path files like 1.b
2.c) Result are the same 1.c, nothing work

 

Maybe i made some mistake with json files or other ? But i have trying everything i can, like changing path, name, path modid/minecraft i have always squares draw. i tested another font and its the same result.

  • Snyker changed the title to [1.18.2] Help to adding more Fonts
Posted (edited)

You don't include the font/ in the ResourceLocation.

 

Mojang put Fonts in resource packs so people can mod vanilla.

I suggest you search the internet for ttf font resource packs and compare your config with theirs.

 

You should also check the logs/debug.log for errors/warnings during resource pack loading.

 

Finally, if you just post snippets (or worse describe your code in English) you aren't going to get much help.

Put your code on github where we can see everything in context so we can confirm you did it correctly and maybe try it for ourselves if the problem isn't obvious from just reading the code.

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  Quote

with the forge order to AFTER and BEFORE (notworking) :

Expand  

The reason for putting AFTER in the mods.toml is so it puts your resource pack above forge one in the options/resource pack screen.

It might be you already configured the resource packs and so it has already saved the wrong order in the options.txt?

NOTE: This is only relevant if you want to override the vanilla fonts.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Snyker changed the title to [1.18.2] Help to adding more Fonts [Closed]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.