Help with 3DS font format

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by onepiecefreak, Jan 5, 2017.

  1. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    Hey there,
    I need help to further understand the bcfnt format of the 3DS.
    I'm working on the spanish translation of Ace Attorney Trilogy but I'm not fully satisfied with the way I had to replace existing characters. I would like to replace japanese characters to not replace any "normal" symbol or letter that could be used.
    But the peoblem is the socalled glyph width. For some reason I can't change it.

    The glyph width is the value that decides how many space the character uses in the dialogue box.

    If someone could help me figure out the problem I wiuld be glad.

    Here you can get the files and tools I use:
    https://mega.nz/#F!ZtJmXYzD!1XgA_iO4B6Tm2kef1kSUxQ
     
  2. Jayro

    Jayro MediCat DVD and Mini Windows 10 Developer

    Member
    GBAtemp Patron
    Jayro is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    4,714
    2,466
    Jul 23, 2012
    United States
    Octo Canyon
    Wouldn't the English version be easier to translate to Spanish?
     
  3. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    English and Japanese are in one game in the Trilogy. So the font contains both latin and japanese characters. But since we don't use japanese characters in english I though about replacing them with the needed accent characters.
    But the glyph width of these japanese characters are hindering me. Therefore the request.
     
  4. Jayro

    Jayro MediCat DVD and Mini Windows 10 Developer

    Member
    GBAtemp Patron
    Jayro is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    4,714
    2,466
    Jul 23, 2012
    United States
    Octo Canyon
    ah, that's a bit more clear. People were facing similar glyph-width issues in another rom translation, and I think they just ended up re-phrasing things to make the words fit the text field.
     
  5. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    Uh... that's ugly. I would like to solve this problem.
     
  6. Anton299

    Anton299 GBAtemp Regular

    Member
    119
    37
    Jan 18, 2012
    Kiev
    I guess the character's width table sits at 0x00102000 and starts with CWDH (Character WiDtH) header (in english font, here - font tools\english font\42.cfnt - just for example).
    The width table itself seems to start at 0x00102010. The first 3 bytes - 09 00 09 - space, next three - 03 03 09 - seems to be exclamation sign (!) and so on, in the same order like the symbols placed in font.
    The first byte in this three bytes means space before this glyph, second one means it's width, third one means space after that glyph, if I understand the things correct ).

    You should check how many pixels are in your new character's width and replace the second (middle) byte (in the group of three bytes of "your" symbol).

    In the example above exclamation sign takes 3 pixels of width.
    If you want to change it by... say... the letter "W" and the width of your "W" is, in example, 13 pixels - convert (in any hex calculator) this 13 to Hex value (will be 0D) and replace 03 03 09 by 03 0D 09 in any hex editor.
     
  7. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    Thx for that explanation.
    Unfortunately I already knew that. I was the one who recreated the bffnt.py in this font tool folder and also know which values exactly are for the glyph width.

    The problem is that after editing it and injecting it back to the game, it doesn't affect the character at all. Changing the other 2 values does have an effect.

    Sry, if this was too unclear until now.

    P.S: But this explanation can help other people to understand a bit more. Thx
     
    Last edited by onepiecefreak, Jan 5, 2017
    Anton299 likes this.
  8. Anton299

    Anton299 GBAtemp Regular

    Member
    119
    37
    Jan 18, 2012
    Kiev
    Strange.
    Well, sorry, I can't help you more... /

    PS. (not completely sure, but...)
    Maybe there is some "protection" (or something) of editing in game engine itself, so it doesn't allow you to edit the font or something else. For example, if you change dialogue text in Zelda:MM 3D and recalculate text pointers - all dialogues become corrupted (instead of edited text you will see just an empty text field with "ERROR" text (v1.0 of the game) (or just empty text field in v1.1), where this edited text should appear).
     
    Last edited by Anton299, Jan 5, 2017
  9. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    Beside the glyph widthin the font, the font and dialogues are completely editable without problems. Do you think they would add a protection just for the glyph width?
     
  10. Anton299

    Anton299 GBAtemp Regular

    Member
    119
    37
    Jan 18, 2012
    Kiev
    Hmm... I don't think so, OK. )
     
  11. onepiecefreak
    OP

    onepiecefreak The Special One

    Member
    381
    129
    Aug 12, 2015
    Germany
    I have to apologize @Anton299. There really is a protection just for glyph width in the game. There is a width table inside the decompressed code.bin of AATri.

    For everyone who wants to know:
    At the offset 0x0015b630 there is the width table. For every character there is a 2 byte value for the width. The list is 0x22e long as far as I could find out.
     
    Anton299 likes this.