Replacing EN Font (/FONT0003.FNT)

Discuss modding questions and implementation details.
User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

Hello there!
Currently looking to make a font replacer.
I've managed to easily replace the font in the Unity Editor for Play Mode but I'm completely stuck at making the .dfmod file do its job.
I'm also curious about what the .FNT files exactly are and if they're actually being modified during startup or if they're just original font files that are simply needed OR if the Font SDF files are turned into .FNT files?
Quite confused about this system.

Eitherway, I'll attach a screenshot of what I've got (using the Alkhemikal font for testing). But as I've said, mainly, the issue is getting it to work in the actual build and just making the font replacer a .dfmod file.
I've checked out several guides but I must have missed either one step or something else went wrong.

Thanks for reading and I hope to bring some font replacers to nexusmods for us to enjoy, seen as there are none uploaded yet.
Attachments
unknown.png
unknown.png (174.88 KiB) Viewed 2768 times

User avatar
Interkarma
Posts: 7242
Joined: Sun Mar 22, 2015 1:51 am

Re: Replacing EN Font (/FONT0003.FNT)

Post by Interkarma »

Hey there, welcome to the forums. :)

The legacy 8-bit pixel FNT files aren't used for anything other than to render non-SDF text. Anytime a custom font is provided or the localisation system is being leveraged, SDF fonts with glyphs matching character codes for the target language(s) must be used.

For SDF text, DFU renders Unity's TMP font assets. All the detail you should need for generating and registering these fonts is in the below blog article.

https://www.dfworkshop.net/localizing-s ... ty-part-6/

The example in article generates from a Korean character range. If you want to use the same character range as the default fonts, select "custom range" and choose one of the default TMP assets to load their character range like so:

example-settings.JPG
example-settings.JPG (56.59 KiB) Viewed 2746 times

When packaging up your mod, include your custom TMP font assets in the mod builder along with your startup script. In mod startup script, load and register the font asset using the code example in above article. Because you're registering the default font, you don't need to provide any custom language packs. Use "RegisterLocalizedFont()" to register your replacement to the built-in EN language code.

From your screenshot, you look to be most of the way there and it's just building the mod where things are coming unstuck. Can you please screenshot your mod builder assets window and paste your startup script here for me in a code block? I'll see if I can work out where things are going wrong based on where you're up to so far.

User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Re: Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

*keep reading* lol
Last edited by AngryKarakuri on Mon Jun 13, 2022 9:08 am, edited 1 time in total.

User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Re: Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

Hello again. Came back to report. Currently, this is what I have and it's unfortunately still at the default font.
Moved the .dfmod file built to the desktop into the right folder but didn't budge. Perhaps just the script is off?
I did write it from scratch of course, but I don't see anything that's off. I guess I don't need to handle the table collections. Probably got the wrong name for the English font. I've tried "en" and "English" but didn't budge yet, still.
Meaning .GetLocale("en"); and GetLocale("English");

Thanks again!

Edit for the codeblock. Didn't see how to do it:

Code: Select all

using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop.Game.UserInterface;

public class StartupScript : MonoBehaviour
{
    public static Mod mod;

    [Invoke(StateManager.StateTypes.Start, 0)]
    public static void Init(InitParams initParams)
    {
        mod = initParams.Mod;
        var go = new GameObject(mod.Title);
        go.AddComponent<StartupScript>();
    }

        void Awake()
    {
        // Load
        DaggerfallFont font_Alkhemikal= new DaggerfallFont(DaggerfallFont.FontName.FONT0003);
        NewFont.LoadSDFFontAsset("Alkhemikal SDF");

        // Assign
        Locale en = LocalizationSettings.AvailableLocales.GetLocale("en");
        if (en)
        {
            TextManager.Instance.RegisterLocalizedFont(en, DaggerfallFont.FontName.FONT0003, font_Alkhemikal);
        }
    }
}
Attachments
mod builder.png
mod builder.png (84.3 KiB) Viewed 2709 times
written script.png
written script.png (144.11 KiB) Viewed 2709 times
files.png
files.png (7.26 KiB) Viewed 2709 times

User avatar
Interkarma
Posts: 7242
Joined: Sun Mar 22, 2015 1:51 am

Re: Replacing EN Font (/FONT0003.FNT)

Post by Interkarma »

LoadSDFFontAsset uses Resources.Load, so your font asset must be homed inside a Resources folder inside your mod folder. It's not obvious this is important because tutorial 6 is building on previous steps and doesn't establish this very well by itself. Here's the relevant bit.

resources-path-step.JPG
resources-path-step.JPG (45.39 KiB) Viewed 2636 times

Please try creating a Resources subfolder and moving your font asset into it. Then it should be able to load properly when Resources.Load is invoked.

Let me know how you go. I'll loop back later when I can.

User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Re: Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

Hello again!
First, let me tell you thank you very much for trying to assist with this.
Right now, after following these steps, it does indeed work. However, it works only partially.
Currently, in the Unity Editor, the font does show properly in-game but in the build, not in-game.
Dunno what's up with that, but I'll attach some screenshots. I feel like we're very, very close to solving this.
Perhaps there's something off in the script or the mod is still built the wrong way.

I'll attach the entire current state in the images here.
Also, updated the script, seen as the last one I showed had a typo that was actually fixed during testing. Maybe we see something looking at it again. Haha

Code:

Code: Select all

using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop.Game.UserInterface;

public class StartupScript : MonoBehaviour
{
    public static Mod mod;

    [Invoke(StateManager.StateTypes.Start, 0)]
    public static void Init(InitParams initParams)
    {
        mod = initParams.Mod;
        var go = new GameObject(mod.Title);
        go.AddComponent<StartupScript>();
    }

    void Awake()
    {
        // Load
        DaggerfallFont font_Alkhemikal = new DaggerfallFont(DaggerfallFont.FontName.FONT0003);
        font_Alkhemikal.LoadSDFFontAsset("Alkhemikal SDF");

        // Assign
        Locale en = LocalizationSettings.AvailableLocales.GetLocale("en");
        if (en)
        {
            TextManager.Instance.RegisterLocalizedFont(en, DaggerfallFont.FontName.FONT0003, font_Alkhemikal);
        }
    }
}
Attachments
3.png
3.png (99.62 KiB) Viewed 2615 times
2.png
2.png (194.15 KiB) Viewed 2615 times
1.png
1.png (56.18 KiB) Viewed 2615 times

User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Re: Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

And another reply to the post because there's a 3 image limit(?)
Sorry about that!
But as you can see, in the build, in-game, it doesn't show up, still. At a total loss now because the Editor shows everything properly 100% and much better than before but I suppose something's still missing.

Mod System and Loose Files are checked, btw. Also tried deleting the mods .json file in AppData just in case something got stuck, for it to create a new file, restarted and changed settings here and there to no avail though. R.I.P.

Also, (maybe) IMPORTANT note: I've put the .dfmod built with the mod builder into F:\TESII Daggerfall\_Daggerfall Unity\DaggerfallUnity_Data\StreamingAssets\Mods. Right where it belongs. I hope there's not an issue loading mods when you've got the game installed on a drive that's not C.
The Unity Project is under D:\Unity3D\project files\daggerfall-unity-master because I do Unity myself, so I shoved the Daggerfall stuff in its own thing in there.

Update: Turns out that extracting the mod from the launcher to AppData extracts everything, minus the font assets. *Interesting.*
Attachments
4.png
4.png (886.61 KiB) Viewed 2613 times

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Replacing EN Font (/FONT0003.FNT)

Post by BadLuckBurt »

This is just a guess but try removing the spaces in the filename, just replace them with underscores or something to make it a 'solid' filename. If that doesn't work, hopefully IK knows what's up.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
AngryKarakuri
Posts: 14
Joined: Sun Jun 12, 2022 7:47 pm
Location: Europe

Re: Replacing EN Font (/FONT0003.FNT)

Post by AngryKarakuri »

BadLuckBurt wrote: Tue Jun 14, 2022 3:53 am This is just a guess but try removing the spaces in the filename, just replace them with underscores or something to make it a 'solid' filename. If that doesn't work, hopefully IK knows what's up.
Hello!
Thanks for the suggestion. I've tried this before, and currently it's all the same "AlkhemikalFontReplacer."
I've had issues like that in other tools with naming before but it didnt fix it this time.
There has to be something else really minor missing for this to work. lol

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Replacing EN Font (/FONT0003.FNT)

Post by BadLuckBurt »

AngryKarakuri wrote: Tue Jun 14, 2022 3:57 am
BadLuckBurt wrote: Tue Jun 14, 2022 3:53 am This is just a guess but try removing the spaces in the filename, just replace them with underscores or something to make it a 'solid' filename. If that doesn't work, hopefully IK knows what's up.
Hello!
Thanks for the suggestion. I've tried this before, and currently it's all the same "AlkhemikalFontReplacer."
I've had issues like that in other tools with naming before but it didnt fix it this time.
There has to be something else really minor missing for this to work. lol
Sorry, I was talking about the Alkhemikal SDF.asset in the Resources folder. That one has a space in it unless there's an underscore being cut off.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

Post Reply