TTF FONT troubleshooting?

  • #1, by SCUD24Tuesday, 28. October 2014, 17:44 6 years ago
    I think the implementation of TTF fonts in VS4 is one of the main reasons I upgraded from version 3. As I'm converting over to the new font system I seem to be having some problems however. As illustrated in the images below, the base settings (top images) leave way too much space between lines. Adjusting the line spacing fixes this pretty well, but also lowers the entire text down to the point where its covering up the head of the NPC character who is speaking. Has anyone noticed this and found a better way? I posted this in the Bug Report thread, though I'm not sure if it is or not.

    Newbie

    28 Posts


  • #2, by SCUD24Tuesday, 28. October 2014, 17:58 6 years ago
    And... I cant seem to get the font Border to be any color other than black... I've tried this with multiple added fonts, and made sure to adjust the Player's Dialog Selection Font accordingly.

    Newbie

    28 Posts

  • #3, by afrlmeTuesday, 28. October 2014, 18:59 6 years ago
    You could probably use the hook event handler to offset the text position a little bit.

    http://wiki.visionaire-tracker.net/wiki/RegisterHookFunction

    function adaptedTextPosition(text, pos)
    if text:getLink(VTextOwner):getId().tableId == eCharacters then
    pos = text:getPoint(VTextPosition); pos.y = pos.y - 10
    text:setValue(VTextPosition, pos)
    return true
    end
    return false
    end

    registerHookFunction("setTextPosition", "adaptedTextPosition")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    ...not tested but in theory it should offset the text 10 pixels upwards.

    As for the border issue: I'm not sure. Does it do this for all TTF fonts you've tried & are you trying to apply this to a linked ttf font you've previously added or a ttf font that is directly linked? I noticed a few issues in previous build (or build before last, I forget which) in which certain settings were not being displayed correctly in the ttf's that were linked to existing ttf I added earlier.

    Imperator

    6812 Posts

  • #4, by SCUD24Tuesday, 28. October 2014, 19:23 6 years ago
    Forgive my scripting ignorance, but where would I put that above coding?

    Regarding the border color issue, it is not a linked font. Using the linked font does not allow the modification of size or addition of a border it seems.

    As always, I appreciate the help!

    Newbie

    28 Posts

  • #5, by SimonSTuesday, 28. October 2014, 21:06 6 years ago
    Create a definition script (script tab, add a script, set to definition (default)), put the code there.

    Does the preview in the editor show the correct font with colored borders ?

    Thread Captain

    1333 Posts

  • #6, by SCUD24Tuesday, 28. October 2014, 21:29 6 years ago
    The editor is supposed to show a preview? Where?

    Newbie

    28 Posts

  • #7, by SCUD24Tuesday, 28. October 2014, 21:39 6 years ago
    I cant tell what the code above did to the text, but it doesn't appear on the screen. I see a brief flicker of movement in the upper left corner of the monitor though. From your link AFRLme, the script there seemed to fix this issue with some minor adjustements:
    function adaptedTextPosition(text)
    -- show texts of character Hero 10 pixel below character position
    local owner = text:getLink(VTextOwner)
    if owner:getId().tableId == eCharacters and owner:getName() == 'Craigges' then
    local pos = owner:getPoint(VCharacterPosition)
    pos.y = pos.y - 380
    text:setValue(VTextPosition, pos)
    return true
    end
    return false
    end

    registerHookFunction("setTextPosition", "adaptedTextPosition")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

    Newbie

    28 Posts

  • #8, by afrlmeTuesday, 28. October 2014, 22:19 6 years ago
    The preview would be in the font tab - the only other tab besides properties. smile

    My script was untested. I wasn't sure if you could get the current text position or not. The only problem with basing it on the character position & offsetting it from that is that the offset will be incorrect if character scale changes as it will be even higher or lower based on character scale. What you could do is use a bit of math & query the characters current scale value to calculate the required offset to always keep it correct.

    local t = {} -- create blank table
    t["Tom"] = 380 -- offset for text at 100% scale
    t["Barry"] = 270 -- shorter character example (same as above)

    function adaptedTextPosition(text)
    -- show texts of character Hero 10 pixel below character position
    local owner = text:getLink(VTextOwner)
    if owner:getId().tableId == eCharacters then
    local pos = owner:getPoint(VCharacterPosition)
    pos.y = pos.y - math.float((Characters[owner:getName()].CharacterSize / 100) * t[owner:getName()])
    text:setValue(VTextPosition, pos)
    return true
    end
    return false
    end

    registerHookFunction("setTextPosition", "adaptedTextPosition")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

    ...in theory it should select offset from the table based on 100% character scale from owner name & the calculate offset based on current character scale value. Also untested code.

    Imperator

    6812 Posts

  • #9, by SCUD24Wednesday, 29. October 2014, 00:21 6 years ago
    Nothing was showing in the font section either, until I activated the little "Display Letter Areas" button. The preview shows a black border as well.

    Newbie

    28 Posts

  • #10, by afrlmeWednesday, 29. October 2014, 00:56 6 years ago
    It's working ok for me with arial black font. I'm using the current public build of 4.1, as I assume you are? Yes I forgot to mention that you have to click on the little letter symbol to get it to display preview of the text which in ttf font case is usually "The quick brown fox..."

    Imperator

    6812 Posts

Write post