FCS \ Game Fonts? [kind of SOLVED]

Post Reply
User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Thu Jul 28, 2016 10:48 am

The problem is that i can't see Cyrillic fonts ingame. FCS recognizes them pretty nice, but gui returns blank spaces, like that:

Image

WAIDW?
Last edited by Sol Lignum on Sun Jul 31, 2016 10:25 am, edited 2 times in total.
Bugs are love, bugs are life!

MB: Asus P8H61-V
CPU: i3-2105 @ 3.2 GHz, HT
RAM: 8 Gb DDR3 1333 MHz
GPU: HD 6950 2Gb 800\1250 MHz
OS : Win7 x64.
Kenshi: Latest experimental Steam build with integrity checked and game imported.

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sat Jul 30, 2016 12:21 pm

The fonts that come with Kenshi don't seem to support cyrillic characters. I assume you're working on a russian translation mod? I took a quick glance at how fonts are loaded, and while it does seem possible to use custom fonts, I don't think it will work with the steam workshop.
Maybe this works:

1. copy the data\gui\fonts folder to mods\yourmod\fonts
2. open resources.cfg in the main kenshi folder with notepad and change the line that says

Code: Select all

FileSystem=./data/gui/fonts
to

Code: Select all

FileSystem=./mods/yourmod/fonts
(you probably also want to make a backup first)
3. hunt down some free fonts that have cyrillic characters to replace the default kenshi fonts and edit kenshi_fonts.xml accordingly

If you get this working, take a screenshot of it and add it to a post kindly asking the devs if they can provide a way to load custom fonts that is compatible with the steam workshop.

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sat Jul 30, 2016 4:51 pm

Yes, you're absolutely correct: "Mailart Rubberstamp" and "Sentencia" fonts doesn't seem to have any cyrillic support.

However, "Exo 2" used in item naming and description is fully equipped with cyrillic characters, as stated here https://www.fontsquirrel.com/fonts/list ... /cyrillic/ and as can be seen here:

Image

I'll try your suggestion, though i dont quite understand what steps 1 and 2 for, but i'll complete the instruction and maybe then it'll become obvious :) I assume that i should also put these new fonts in a same directory mods\mymod\fonts ? And then in kenshi_fonts.xml just replace old fonts names with new fonts names?

Thank you very much for paying attention to this :) And yes, i'd really love to translate the game to Russian and to do it right, but kind of stuck in the beginning, since there's no point of doing something that'll go invisible.

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sat Jul 30, 2016 5:48 pm

Sol Lignum wrote:I assume that i should also put these new fonts in a same directory mods\mymod\fonts ? And then in kenshi_fonts.xml just replace old fonts names with new fonts names?
Yes, that's the idea.

Step 1 and 2 are optional I suppose. They're so you don't have to mess with the original game files. That way, people using your mod will have the option to easily switch back.

I completely overlooked the cyrillic glyphs in the Exo fonts, you're right, they're definitely there. This could also indicate that either a support library kenshi uses was compiled without unicode support, or kenshi doesn't handle unicode strings properly internally. If this is the case, you're probably not going to get it to work without some help from the devs.

Edit: Maybe the "Code range" property in the kenshi_fonts.xml files holds the key. I think cyrillic code range should be "1025 1105", you could try adding that as an extra range.

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sat Jul 30, 2016 9:04 pm

Ok, seems like i have to abandon all the manipulations for a while... I tried to mess with that xml data massive, and it didn't liked it, and messed me up instead: for some reason i can't save it properly after editing, and even renaming it in orger to backup shatters the data, specifically, that "range" column, and kesnhi's becoming fontless :)

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sun Jul 31, 2016 3:37 am

Hmm, I was pretty confident the code range thing might be it. Did you edit it correctly? The whole file should look something like this (I only edited the Exo fonts):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Resource" version="1.1">
	<Resource type="ResourceTrueTypeFont" name="Kenshi_StandardFont_Small">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="14"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_StandardFont_MediumSmall">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="16"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_StandardFont_Medium">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="20"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_StandardFont_Large">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="24"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_PaintedTextFont_Small">
		<Property key="Source" value="Sentencia_1.ttf"/>
		<Property key="Size" value="20"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_PaintedTextFont_Medium">
		<Property key="Source" value="Sentencia_1.ttf"/>
		<Property key="Size" value="25"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_PaintedTextFont_Large">
		<Property key="Source" value="Sentencia_1.ttf"/>
		<Property key="Size" value="28"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_BannerTextFont">
		<Property key="Source" value="MailartRubberstamp-Regular.ttf"/>
		<Property key="Size" value="150"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_FloaterFont_Small">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="20"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_FloaterFont_Medium">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="22"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_FloaterFont_Large">
		<Property key="Source" value="Exo2-SemiBold.ttf"/>
		<Property key="Size" value="24"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="32 126"/>
			<Code range="1025 1105"/>
		</Codes>
	</Resource>
	<Resource type="ResourceTrueTypeFont" name="Kenshi_UI_Messages">
		<Property key="Source" value="MailartRubberstamp-Regular.ttf"/>
		<Property key="Size" value="110"/>
		<Property key="Hinting" value="use_native"/>
		<Property key="Resolution" value="50"/>
		<Property key="Antialias" value="false"/>
		<Property key="TabWidth" value="4"/>
		<Property key="OffsetHeight" value="0"/>
		<Property key="SubstituteCode" value="0"/>
		<Property key="Distance" value="2"/>
		<Codes>
			<Code range="65 90"/>
			<Code range="46 46"/>
		</Codes>
	</Resource>
</MyGUI>

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sun Jul 31, 2016 6:50 am

I completely ignored the nature of .xml files, and treated them as some fancy excel table, more then that, default file won't open properly with notepad or wordpad or notepad++, so what i've finally done is copied your code into notepad and saved it as .xml, aaand...

Image ta-da.

Now, what do i do? Should i just include this custom .xml to my mod, or should i ask devs to tweak it? Exo is main font, i believe, and translation should cover inner UI, popup tips, items and description, npc\pc names etc etc.

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sun Jul 31, 2016 9:09 am

Awesome sauce, you got it to work!

Only just now I noticed there's a new "locale" directory in my kenshi folder. Did you read the Kenshi_translations.txt file in there? If you look at the example folder structure at the end, it seems you can just put your custom kenshi_fonts.xml file in your translation.

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sun Jul 31, 2016 10:04 am

Checked it out after your message. It's a whole new process which i don't quite understand yet. I managed to "create a translation mod" by creating a "ru" folder in /__translation directory. Then i opened the FCS and found a "Translations" button which i pushed, and it returned me this:

Image

...pressing a [build] button creates a "ru.translation" file, which, according to the manual, should be then placed into /locale folder, and [export] does starting some proccess, as i can judge by CPU fan spinning up, but crashes FCS shortly after with no notable result.

Seems like i've been walking the wrong way initially though, and translation should be made not by just editing things in FCS.

p.s. i've also downloaded the Poedit programm, and opened that only Gamedata.pot file that i have in /__translation/base folder.

So now it's becoming more clear. I have to extract all possible english strings from the game, then translate them with the Poedit, save of compile, and then put them in the game as a mod somehow :ugeek:

UPD1:
I get it: pressing the [export] button creates /dialogues subfolde and gamedata.pot file in a /__translation folder but process seems to be interrupted by FCS crash

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sun Jul 31, 2016 11:17 am

Yeah it does seem a bit complicated. Maybe in the next patch they'll include an example. It does look like a pretty neat solution though :).

I get the same crash when clicking export, seems to be some kind of bug. There are some details about the crash in the "forgotten construction set.log" file:

Code: Select all

2016-07-31 12:16:00.2153 | ERROR | FCS | Exception: De index ligt buiten de matrixgrenzen. (forgotten construction set). Stacktrace:    bij forgotten_construction_set.TranslationManager.DialogueMessage..ctor(DialogueGroup group, Item d, UInt32 lineIdx, DialogueMessage parent)
   bij forgotten_construction_set.TranslationManager.<>c__DisplayClass30_0.<DialogueTranslation>b__2(DialogueGroup group, DialogueMessage parent, Item data, UInt32 levelIdx)
   bij forgotten_construction_set.TranslationManager.<>c__DisplayClass30_0.<DialogueTranslation>b__2(DialogueGroup group, DialogueMessage parent, Item data, UInt32 levelIdx)
   bij forgotten_construction_set.TranslationManager.DialogueTranslation(GameData gameData, ConcurrentDictionary`2 wordSwaps)
   bij forgotten_construction_set.TranslationManager.Translate(navigation nav)
   bij forgotten_construction_set.TranslationDialog.<btnExport_Click>b__5_0()
   bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bij System.Threading.ThreadHelper.ThreadStart()

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sun Jul 31, 2016 11:53 am

Indeed, all that needed is one nice manual, with asking for which from guys i hope Koomatzu will succeed :)

I'm literally lost in all these "create folder here - open FCS - press button - find file - edit with 3rd party programm - save - copy there - rename - nothing works - WAAAAAGH!" xD

Poedit is a quite handy app though. It piles everything it has before you, then you can translate various bits, and also track progress, since original is always presented, so once tech things are done, translation process should be a walk in a park :)

pawnstorm
Posts: 23
Joined: Sat Jun 25, 2016 2:32 am

Sun Jul 31, 2016 3:21 pm

Here's a temporary fix for the Export crash. Just load it after the core game data and before your mod before you export.
It's just a little hack to get past the crash, so you shouldn't be using it for anything else.

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Sun Jul 31, 2016 6:38 pm

By Phoenix'-the-current-blessed be his name-Holly Glowing Balls, you're 1337 h4xx0r!

Alright, that's wonderfull, game data's all here, i might want to mod some wordswaps to fit gender addresses in Russian, and all good. I even managed to turn the partially translated file into a mod that can be published in a workshop. .txt in /locale seems to be a bit missleading about the .translation files and placing them into /locale, or i'm doing something wrong, but i managed to see some changes ingame, or load the translation at all only by changing expansion to .mod and placing it to the mods folder.

p.s. and we made a full circle. nothing work's without tweaking kenshi_fonts.xml ...

p.p.s. i think i might as well just ignore this whole thing completely, and get back to my initial translation plan, with little disclaimer on a mod page considering how the kenshi_fonts should be modified... but alas that's only a partial solution, and i'll wait for a good manual.

Zodd
Developer
Posts: 117
Joined: Thu Jul 28, 2016 11:33 am

Tue Aug 02, 2016 1:03 pm

Hi,
A couple of things.
First, the crash with the export in the FCS should be fixed by now; so there is no need a mod fix.

Second, about the fonts/assets issues: both the mods and translations (in locale folder) works as a "remapping" of the resource.cfg file where the assets are loaded. That's why they share the same internal folder structure.
The issue with the fonts and the missing characters is either because the font doesn't have the specific characters or that in the "kenshi_fonts.xml" the range of the fonts is wrong (or both).
That xml file contains info for each "resource font" used in game and it creates a texture file for each of those with the characters that are there.
If you open file, you'll see it has for each "resource font" a source that is the font file and a list of codes ranges. The codes are the character codes ranges to include in game. If a character is missing, the game will display it as a blank.
When selecting the ranges, try avoid adding all the characters in the font since some fonts files contain a lot of characters (and I mean a lot) that will not be used and make the loading slower and could affect the performance.
Also, missing characters in the font file won't add extra space so it's safe to put a large range if you know the font doesn't have those characters.
In your case, since you want the cyrillic alphabet, try using the range code: "32 64258" for the Exo font. For the other two fonts, sadly you'll need to get different fonts. You can check https://www.google.com/fonts for good fonts.

Regarding the confusion with the locale folder stuff, I know it's confusing but maybe I can help out a bit.
You could do the translation as a mod with the rename of the extension, however, to translate all the other texts that are in game (that come from the source code) you need to use this structure, at least for now. Note that the 'main.pot' file that contains the game texts will be probably uploaded in the next update.


If you need me to explain something in more detail or have any other question, feel free to ask.

siodog
Posts: 6
Joined: Sat Apr 02, 2016 3:06 am

Tue Aug 02, 2016 1:44 pm

Zodd wrote:Hi,
A couple of things.
First, the crash with the export in the FCS should be fixed by now; so there is no need a mod fix.

Second, about the fonts/assets issues: both the mods and translations (in locale folder) works as a "remapping" of the resource.cfg file where the assets are loaded. That's why they share the same internal folder structure.
The issue with the fonts and the missing characters is either because the font doesn't have the specific characters or that in the "kenshi_fonts.xml" the range of the fonts is wrong (or both).
That xml file contains info for each "resource font" used in game and it creates a texture file for each of those with the characters that are there.
If you open file, you'll see it has for each "resource font" a source that is the font file and a list of codes ranges. The codes are the character codes ranges to include in game. If a character is missing, the game will display it as a blank.
When selecting the ranges, try avoid adding all the characters in the font since some fonts files contain a lot of characters (and I mean a lot) that will not be used and make the loading slower and could affect the performance.
Also, missing characters in the font file won't add extra space so it's safe to put a large range if you know the font doesn't have those characters.
In your case, since you want the cyrillic alphabet, try using the range code: "32 64258" for the Exo font. For the other two fonts, sadly you'll need to get different fonts. You can check https://www.google.com/fonts for good fonts.

Regarding the confusion with the locale folder stuff, I know it's confusing but maybe I can help out a bit.
You could do the translation as a mod with the rename of the extension, however, to translate all the other texts that are in game (that come from the source code) you need to use this structure, at least for now. Note that the 'main.pot' file that contains the game texts will be probably uploaded in the next update.


If you need me to explain something in more detail or have any other question, feel free to ask.
well thats really helpful to know, about the main.pot file i followed the instructions yet im unable to get it to edit them hope u can help with this thanks in advance
ok edit: read it wrong i asked nothing THANK YOU :)

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Tue Aug 02, 2016 8:04 pm

Zodd wrote: (...) If you need me to explain something in more detail or have any other question, feel free to ask.
Hello!

As for now it's clear on how to extract the game data, and where the english main.pot will come from, thank you for confirming that. It's also clear on how to translate everything and build a .translation file, and where to put it.

What remains unclear is how to upload the finished translation into Workshop? Seems like it only accepts .mod files, and even French and German and Spanish translations has a .mod files to do the job, although i can understand that, maybe they can live without fancy characters, or fonts does support them.

So, my only question so far is: how to grab this locale folder with all its complex structure and stick it into workshop, if it's indeed possible?

Zodd
Developer
Posts: 117
Joined: Thu Jul 28, 2016 11:33 am

Tue Aug 02, 2016 8:44 pm

Sol Lignum wrote: As for now it's clear on how to extract the game data, and where the english main.pot will come from, thank you for confirming that. It's also clear on how to translate everything and build a .translation file, and where to put it.
The 'main.pot' should've been today's release; I guess Chris forgot to add it.
Sol Lignum wrote: What remains unclear is how to upload the finished translation into Workshop? Seems like it only accepts .mod files, and even French and German and Spanish translations has a .mod files to do the job, although i can understand that, maybe they can live without fancy characters, or fonts does support them.

So, my only question so far is: how to grab this locale folder with all its complex structure and stick it into workshop, if it's indeed possible?
For the moment, there is no direct workshop support for the translations; it's a thing we discussed but are still working on the best approach to do this.

As a hack, to upload it to the workshop, you can modify the extension of the '.translation' file to '.mod' file. The only issue with this is with the 'main.pot' file translations, since they are not loaded as a mod and need to be in under the locale folder structure.
Also, if the translation is in the locale folder, the selection of the language will be in the game launcher in a separate combo box rather than as a regular mod.

Regarding the special characters in those translation mods, they could've modified the character set ranges, replace them with some other or just ignore those characters. I really don't know.

User avatar
Sol Lignum
Posts: 1085
Joined: Sun Sep 06, 2015 5:56 pm
Location: Mother Russia!
Contact:

Tue Aug 02, 2016 9:11 pm

I see... well, that's an option of a kind, i suppose. I can just post a link to the external storage in a workshop page with explanation on how to use it. Going to check the Workshop EULA to make sure if it is allowed. Thank you kindly for the explanation :) Keep up the good work!


UPD:

I suggest us to continue the discussion here: http://www.lofigames.com/phpBB3/viewtop ... 11&t=10484 , since most of it is unrelated to OP question anymore. :)

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests