[Solved] Change a font used to display narration text, when game language is changed

  • #1, z YourichiganThursday, 25. May 2017, 14:27 hodinky 7 years ago
    Hi there!

    I am making a multilingual game, currently there were two languages English and Russian, and there were no issues whatsoever. I use a TrueType font for the text display.

    But when i added Chinese language, it seems i need to use a different font, for everything to display correctly. 

    I use a "Display narration text" action, to display character text. And there is a font selector in the action parts, but it does not seem to be connected to language select.

    So the question is - Is there a way to change the font used to display text if the game language is changed?

    I know that i can write some actions like:
     If (English) -> Display Narration text (with correct font#1 selected)
     If (Chnese) -> Display Narration text (with correct font#2 selected)

    But i have too much of text in the game already, and adding such action parts everywhere will be too cumbersome.

    I am looking for a more global solution maybe.  Or a lua script to change a font of displayed text?

    Bažant

    12 Posts


  • #2, z SimonSSunday, 28. May 2017, 10:15 hodinky 7 years ago
    Hi,

    Daedalic stepped into this also. They are changing the font of these action parts per lua.

    You can try using an invisible character for that, so the font can be changed globally.

    Kapitán

    1582 Posts

  • #3, z sebastianSunday, 28. May 2017, 11:34 hodinky 7 years ago
    function onTextStarted(text)
     if text:getLink(VTextOwner):isEmpty() and game.StandardLanguage == Languages["chinese"] then 
      text:setValue(VTextFont, Fonts["chinese"]) 
     elseif text:getLink(VTextOwner):isEmpty() and game.StandardLanguage == Languages["english"] then 
      text:setValue(VTextFont, Fonts["english"]) 
     end
    end
    
    registerEventHandler("textStarted", "onTextStarted")

    You could try the above script. Should only work for narration text (they dont have an owner). untested. 

    Kapitán

    2346 Posts

  • #4, z afrlmeSunday, 28. May 2017, 12:27 hodinky 7 years ago
    function onTextStarted(text)
     if text:getLink(VTextOwner):isEmpty() and game.StandardLanguage == Languages["chinese"] then 
      text:setValue(VTextFont, Fonts["chinese"]) 
     elseif text:getLink(VTextOwner):isEmpty() and game.StandardLanguage == Languages["english"] then 
      text:setValue(VTextFont, Fonts["english"]) 
     end
    end
    
    registerEventHandler("textStarted", "onTextStarted")

    You could try the above script. Should only work for narration text (they dont have an owner). untested. 
    I provided something similar via Skype the other day. Also untested. Didn't work apparently but I could have written something wrong. I used shorthand for the TextOwner part, which should have worked in 4.2.5 as far as I'm aware. * edit: ah I used the getId tableId nonsense which was probably a bit daft in hindsight. Oh well...

    @Simon: The dialog system they use is automated. I tried to make it as global as possible without making it too complicated for their dialog writer to create the Lua tables that contain the text, speech recordings & character animations. Ideally it would have been better if it could have been sorted with a single called by other action block for iterating through the dialog tables, but that would have also meant adding further complication to the Lua tables as they would have had to also add conditions/values they needed to edit into that & other called by action blocks to call if they needed to trigger other action parts for specific parts of conversations, so they went for a small looping action block consisting of around 10 action parts - or maybe it was less (I forget) instead of 100's of action parts per conversation as they are quite lengthy & each new dialog line updates the character animation (anime/visual novel type thing).

    Imperátor

    7285 Posts

  • #5, z YourichiganSunday, 04. June 2017, 15:35 hodinky 7 years ago
    Thanks for all the answers! I came up with one solution, with AFRLme help, and totally forgot to check the forum for other answers smile

    @sebastian Thanks for your version, as with it I modified first solution I had, to work in 4.2.5 Visionaire editor.

    function onTextStart(text)
     if text:getLink(VTextOwner):isEmpty() then
      if game.StandardLanguage:getName() == "English" then 
       text:setValue(VTextFont, Fonts["default_font"]) 
      elseif game.StandardLanguage:getName() == "Chinese" then
       text:setValue(VTextFont, Fonts["chinese_font"])
      end
     end
    end
    
    registerEventHandler("textStarted", "onTextStart")

    That is a version of lua that eventually worked.

    But still, a different problem appeared. How can i change Action text font text when i change game language?

    Because now, the dialogues display ok with language change (wrong font selected was crashing the game before), but when the cursor is over an object, the chinese text that is in the "Object name field" crashes the game (unable to display i suppose).

    Bažant

    12 Posts

  • #6, z sebastianSunday, 04. June 2017, 16:11 hodinky 7 years ago
    Im not sure if the action text ist an editable "active text". Regarding to the DataStructure i see no chance to change it... But for this i would consider the dev's advice

    Kapitán

    2346 Posts

  • #7, z afrlmeSunday, 04. June 2017, 16:11 hodinky 7 years ago
    According to the data structure action text font is not scriptable, but whether that literally means it's not scriptable or whether it just means the new value won't be saved to the save game data, is anyones guess. Maybe it would be best to create one big oldschool image font map for the action text instead that contains the characters/alphanumerics for all of the different languages you want to include?

    * edit: :shakeshark: @ Sebastian for posting faster. grin

    Imperátor

    7285 Posts

  • #8, z sebastianSunday, 04. June 2017, 16:32 hodinky 7 years ago
    * edit: :shakeshark: @ Sebastian for posting faster. grin
    https://cl.ly/kkmw/Image%202017-06-04%20at%204.32.30%20PM.png

    Kapitán

    2346 Posts

  • #9, z afrlmeSunday, 04. June 2017, 16:54 hodinky 7 years ago
    * edit: :shakeshark: @ Sebastian for posting faster. grin
    https://cl.ly/kkmw/Image%202017-06-04%20at%204.32.30%20PM.png

    But I have black hair mate, not gingery brown. razz

    Imperátor

    7285 Posts

  • #10, z YourichiganSunday, 04. June 2017, 18:44 hodinky 7 years ago
    Ok, it is bad we can't change it. Thanks for replies.

    With one big image font map I do not understand how can you make one for chinese characters. Isn't it like i would have to include a whole lot of chinese characters, as there is no alphabet?

    But I am still confused a bit on the supposed way the whole language switching works in Visionaire. I see that you can make language specific text for objects, dialogues, character names and so on. I can make different fonts. But why is not a font assosiated globaly with language selection? Isn't it that you will want for different languages (even not counting asian like Chinese)  have different fonts, because it will look better?

    I also think the crashing on text display issue is more of the OS problem (windows10 in my case), and not the application. But i have no idea why this happens yet.

    Bažant

    12 Posts

  • #11, z afrlmeSunday, 04. June 2017, 22:26 hodinky 7 years ago
    In regards to crashing display texts. Are you including line breaks in any of your display texts? In 4.2.5 or 4.2 (I forget which) it tends to freeze the game & crash for some reason when you display texts using ttf/otf fonts, but supposedly line breaks work fine with image fontmap versions.

    It was a bug I discovered when someone on Patreon contacted me for help in figuring out why it kept crashing when changing from the first main playable scene into the next playable scene.

    Imperátor

    7285 Posts