How to replace a font?

Does anyone have any tips about modding a font? I've been trying to change this DescriptionText font, but so far unsuccessful. I'm only interested in changing it for Signs, if that's a simpler task.
No description
14 Replies
SerGreen
SerGreenOP2w ago
I don't understand. I'm trying to replace the font style in CDO of 1x1 sign's layout class (BPW_Sign1x1_2), but it doesn't change anything, even when i log font name right after i change it, it prints None. I assign it a non-empty struct and it doesn't change. What's happening? It shouldn't be None even before me setting a new value, but it is None even then. I tried to log font's name directly from my variable and it can read it fine, so the issue is not in that. Why sign's CDO always reports empty style? Do i need some kind of access transformer?
No description
Robb
Robb4d ago
I'm not sure I understand the situation, but it could be that the font is not actually set on the CDO and is set by something else? since you are working with a widget, I suggest trying to use widget hooking to change the font instead. because you know that will run every time the widget gets spawned if you hook Construct for example Bind on BP Function node, pass the class of the BPW_Sign1x1_2, and function name Construct. you will get the widget instance that got constructed
SerGreen
SerGreenOP4d ago
Yeah, i figured that it's something not possible to do via CDOs (directly). So far i've managed to replace font in signs by making my versions of sign layouts and swapping them in CDOs, and for text boxes in UI menu - by making my inherited copy of InteractWidget and swapping it too. It works, but it would be nicer not to replace layouts, because then new font only works on newly built signs, and signs go black when you remove the mod. I'd like to explore your suggestion of using hooks. I tried to figure them out, but don't quite understand how it's done. Is widget hooking has to be done in C++ or can it be done in blueprints? I can see Widget Blueprint Hooks mentioned in example mod's RootInstance module. Is that the thing that i need or should i look into something else for hooking Construct event of a widget?
Robb
Robb4d ago
depending on what you are hooking it may have to be done in c++, but this can probably be done in blueprint. one way is using the widget blueprint hooks system, but that is more useful when you want to add something. you want to change something, so bind on bpfunction is sufficient. look at Mam Enhancer source code for examples of both
SerGreen
SerGreenOP4d ago
Awesome, thank you for the links, will study them and try to do that.
SirDigby
SirDigby2d ago
I managed this once, but it's been a while and I don't remember how I did it. Going to look through some of my old modding projects and see if I still have it somewhere https://discord.com/channels/555424930502541343/623891487683510323/928807704649158696 Good news and bad news. Found the mod where I would have tested it but the actual code to replace it is gone
Robb
Robb2d ago
git commit history?
SirDigby
SirDigby2d ago
Doesn't go back quite far enough
SirDigby
SirDigby2d ago
:alpacool:
No description
SirDigby
SirDigby2d ago
It's not perfect, but I can at least give you a starting point @SerGreen . I had to use Bind on BPFunction on the BPW_SignLayout class
No description
SirDigby
SirDigby2d ago
Let me know if you want more info or if you'd rather figure it out yourself
SerGreen
SerGreenOP2d ago
Oooh, nice! Thank you. This bit of info is the last missing piece that i needed. At Construction time text boxes were still missing and i didn't have time yet to play around with it more, but now it should be easy. Well, shit. Binding SetupText works and affects even signs built before the mod, but the font changes only after you edit a sign, so after save reload all signs use old font again and you have to modify sign for it to re-render its screen with a new font. Which means that i have to find a way to mod a layout when a sign is loading from a save. It probably doesn't use a layout manager for that, because i think signs save their layout directly. I think i should bind on something of every layout instead? I'll try that next time. Btw, BPW_SignLayout class is actually BPW_SignLayoutManager, it has mTexts map of String - RichTextBlock and font is a property of a text block.
SerGreen
SerGreenOP2d ago
No description
SirDigby
SirDigby2d ago
Yeah, there just be another function or event being called when they first load up

Did you find this page helpful?