Font_bold.xnb recreate?

Discussion in 'Mods' started by abuali, Jan 22, 2018.

  1. abuali

    abuali Intergalactic Tourist

    Is it possible to create Font_bold.xnb from a scratch, or just editing the current one to add more characters? Not latin characters...
    Because the .yaml created by xnbnode in unusable in this font unlike spritefont
     
    • Pathoschild

      Pathoschild Tiy's Beard

    • abuali

      abuali Intergalactic Tourist

      Same...
      To be clear, i can edit the .png, but .yaml doesn't have glyph info to edit or add new ones as the spritefont
       
      • Pathoschild

        Pathoschild Tiy's Beard

        Unlike the files under Content\Fonts, that one isn't actually a sprite font. The game has special logic to calculate the position of an given character. In theory you can add support for new characters by extending the bottom (without changing the width), but I haven't tried it. Here's the logic if you want to try adding new characters:
        Code:
        let index = ASCII_CODE_OF_CHARACTER - 32
        let pixelPosition = (
           x: index * 8 % spritesheetWidth,
           y: index * 8 / spritesheetWidth * 16 + (if is_junimo_text: 224, else: 0)
        )
        
         
        • abuali

          abuali Intergalactic Tourist

          So, only ANSI letters could be read on this one?
           
          • Pathoschild

            Pathoschild Tiy's Beard

            Nope, the index is based on the UTF-16 code point. I don't think anyone has tried doing this though, so I don't know how well it will work.
             
            • abuali

              abuali Intergalactic Tourist

              But I didn't understand that logic well, maybe a short example would help
               
              • Pathoschild

                Pathoschild Tiy's Beard

                Here's a combined formula for the pixel position of a character in that spritesheet. The spritesheet width is 128px, so I'll put that in now:
                Code:
                (x: (charCode - 32) * 8 % 128, y: (charCode - 32) * 8 / 128 * 16 + (if is_junimo_text: 224, else: 0))
                
                Let's say you want to add the A character. The UTF-16 (and ASCII) code for A is 65, so let's plug that into the formula:
                Code:
                  (x: (charCode - 32) * 8 % 128, y: (charCode - 32) * 8 / 128 * 16 + (if is_junimo_text: 224, else: 0))
                = (x: (65 - 32) * 8 % 128, y: (65 - 32) * 8 / 128 * 16 + (if is_junimo_text: 224, else: 0))
                = (x: 8, y: 33 + (if is_junimo_text: 224, else: 0))
                
                In other words:
                • if you can read Junimo text, A is at position (8, 33):
                  upload_2018-1-22_15-13-43.png
                • Otherwise it's at position (x: 8, y: 257):
                  upload_2018-1-22_15-15-23.png
                 
                • abuali

                  abuali Intergalactic Tourist

                  Still didn't know how to deal with this part of the equation
                  Code:
                  (x: (charCode - 32) * 8 % 128
                  how to deal with the number 128 ? in the last?
                  no matter what I do I get wrong answer
                   
                  • Pathoschild

                    Pathoschild Tiy's Beard

                    128 is the spritesheet width, and % is modulo.
                     
                    • abuali

                      abuali Intergalactic Tourist

                      So in this
                      How the answer came 8?
                      I got 264 as an answer!
                       
                      • Pathoschild

                        Pathoschild Tiy's Beard

                        That's due to order of operations. This should be a bit clearer:
                        Code:
                        x: ((65 - 32) * 8) % 128
                        
                         
                        • abuali

                          abuali Intergalactic Tourist

                          Now I get 337.92 !
                          I never been so dump at maths than this time lol :p
                           
                          • Pathoschild

                            Pathoschild Tiy's Beard

                            Code:
                            ((65 - 32) * 8) % 128
                            = (33 * 8) % 128
                            = 264 % 128
                            = 8
                            
                            You can also enter the whole thing in the Google search box, and it'll give you the answer.
                             
                              abuali likes this.
                            • abuali

                              abuali Intergalactic Tourist

                              Thanks, also I get it done by Excel using MOD function
                              Code:
                              =MOD(((65- 32) * 8),128)
                               
                              • abuali

                                abuali Intergalactic Tourist

                                It seems impossible to do, because the image file would be too big and cannot be read by the game..
                                So I moved to another option,
                                Modding language other than English, luckily the other languages doesn't have "font_bold.xnb" kind of file, it have a native font created by BMfont application that can be recreated easily.
                                The problem is that there is one file that cannot be extracted by xnb_node
                                which is these files
                                Code:
                                Chinese.xnb
                                Japanese.xnb
                                Russian.xnb
                                
                                all of them have the same format

                                and when I try to show its content by GXView, it shows this error

                                Code:
                                Can't find type reader 'BmFont.XmlSourceReader'.
                                 
                                • Pathoschild

                                  Pathoschild Tiy's Beard

                                  I haven't used GXView, but you can unpack the file to get the actual XML data.
                                   
                                  • abuali

                                    abuali Intergalactic Tourist

                                    The rest of the files can be unpacked, but these
                                    Code:
                                    Chinese.xnb
                                    Japanese.xnb
                                    Russian.xnb
                                    Cannot be unpacked
                                     
                                    • Pathoschild

                                      Pathoschild Tiy's Beard

                                      Those unpack fine for me (using xnbcli):
                                      upload_2018-3-2_1-52-6.png
                                      upload_2018-3-2_1-52-32.png
                                       
                                      • abuali

                                        abuali Intergalactic Tourist

                                        xnbcli did it, thanks!
                                         

                                        Share This Page