Announcement

Collapse
No announcement yet.

Saving multiple fonts to the raw partition

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving multiple fonts to the raw partition

    Hello,

    I am trying to save more than one font to the raw partition. Each time I try to write to the partition I manage to corrupt the other font. What I do is write the first font beginning at the address listed as the first sector. Then I look at the size of the file and divide the bytes by 512 to get the number of sectors that were written, then I round up and add that number to the first sector address to get the address of where the other font could be written.

    So for example, the first sector of the non-fat partition according to RMPET was 4194241,the size of the file was 32KB so 32000/512 = 62.5, so I would say that the next sector could be 4194241 + 63 = 4194304. But when I try this somehow the first font is corrupted. What am I doing wrong?

    One thing I haven't tried is writing both fonts at the same time by adding 2 lines to the script. I'll try that and see if it makes a difference. I guess I could always use the method 1 for the other font, but I was trying to save space in the fat partition.

    Thanks,

    Mark

  • #2


    That all sounds right. How much of the first font is getting corrupted?

    Have you verified that it is not corrupted if you only write the first font?

    What about how you are attempting to access the fonts, can you give a code snippet?

    Can you give some information about the fonts and what options you used to create them, so we can try and generate them ourselves (hmm if the second one is similarly small, maybe zip them up and attach)
    Mark

    Comment


    • #3


      Hello, and thanks for the fast reply,

      Well I went back and reformatted the disk and wrote 2 fonts one after the other using the method I described above and when I used your example program "DemoUnicodefromFat" I was able to print everything from both fonts just fine.

      What the problem I was having must have been related to accessing the fonts and printing from the KBHandler using a keyboard. When I use the keyboard, I get letters when I press the numbers and lower case letters when I use the shift key. On some of the fonts, nothing happens when I press the keyboard keys. Does this sound like an offset problem to you? I have played around with the unicode_page(0x0000, 0x00FF, 0x20); line but that doesn't change anything.
      Also if I try to use method 1 with the keyboard it doesn't work either, same result. The only way I can print from the keyboard is if I use an internal font. I can also use the #inherit on some of the fonts, but that adds a large overhead to the program, sometimes doubling the compiled size.
      Is there something that I am overlooking, any help would be appreciated.

      Thank you,

      Mark

      Comment


      • #4


        Yes, it will be related to / fixable by unicode_page(0x0000, 0x00FF, 0x20); (or changing the font export settings)

        When you use the ViSi Strings object all fonts are created in such a way that Unicode_page is not needed.

        Maybe use that technique and copy the fonts created into the RAW area?
        Mark

        Comment


        • #5


          Thanks, I like using the fonts stored in the raw area, but would like to keep this code form as it is for simplicity's sake . Given that, when I export the fonts I have been using .GCI as the file type, but as I said in my previous post, I have no trouble printing with the fonts using the print command and the unicode_page(0x0000, 0x00FF, 0x20); set as so. How come it doesn't work inside a KB Handler function the same way.

          Thanks for your help,

          Mark

          Comment


          • #6


            Not sure, I was thinking the font is being changed somewhere and hence the Unicode page needs resetting, but I think you've said you tried that.

            I'd need to see all the code (or preferably a cur down version) to take it much further than that.
            Mark

            Comment


            • #7


              Hello again,

              Still at this, I tried what you suggested and was able to use the strings example to save windows fonts to the sd card in the fat partition.
              And when used in my other programs they printed using the keyboard as expected. Except for one thing: the spacing between the letters is very wide. How can I control this? the letters are printed with the putch command and I advance the cursor to the next position, which results in.. E v e r y t h i n g i s n o w D o u b l e S p a c e d. It prints just fine using the print(" ") command. Its not proportional spacing anymore. I saved the fonts as ANSI as well as Unicode and got the same result. How can I make this look right? Is there something I can do when I save the fonts to make them appear closer together?


              Thanks for your help,

              Mark

              Comment


              • #8


                "and I advance the cursor to the next position"
                How are you doing that?
                Mark

                Comment


                • #9


                  The following is one of the Keyboard Handlers that controls where the Key presses are printed. The cursor position is selected in another part of the program, based on which area of the screen is touched.


                  func KbHandler2(var Key)
                  var tab, hFile;
                  txt_FGcolour(BLACK) ;

                  // Ihndl := file_LoadImageControl("FontA.dat", "", 2);

                  Comment


                  • #10


                    Hmm txt_MoveCursor(); can only work with fixed width characters (it can't possibly work any other way it has no concept of the 'current' character)

                    To use a proportion font you need to keep track of the width of each character entered using charwidth(). You will also need to do something 'special' to erase a single character as the proportional blank is quite narrow.
                    Mark

                    Comment


                    • #11


                      Hello:

                      Relating to the problem I was having printing characters of different widths is the issue you eluded to in your previous reply. That is, how do I erase variable width characters and then reposition the cursor to the correct starting point to type over the previous character. I think I have most of how I can do that using a buffer to hold all the character's widths and then a str pointer to get the correct width based on how many times I back up the cursor. My question is what do I print to cover up the space, how do I print a " " blank space of different widths? I can back the cursor up to the right spot and print over the key but what if I want to leave the spot blank. Do I just have to bring the cursor back to the very beginning of the line and start over, or is there a better way? Your help would be appreciated.

                      Thank you,

                      Mark

                      Comment


                      • #12


                        Draw a filled rectangle for the width of the character you are 'deleteing'
                        Mark

                        Comment


                        • #13


                          OK thanks that's a good idea. I'll try that.

                          Mark

                          Comment

                          Working...
                          X