Announcement

Collapse
No announcement yet.

How to Print text in custom fonts?

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

  • How to Print text in custom fonts?

    I try to print text in custom fonts based on the example AN-P3001 and have some difficulities.

    The program below prints as I expect but if I remove the line with PrintDisk(.. nothing is printed at all.
    Do I have to always first use PrintDisk??

    \Mikael
    ------------------------------

    #platform "uLCD-43PT"

    // Program Skeleton 1.1 generated 2013-12-26 22:31:45
    #inherit "4DGL_16bitColours.fnc"
    #inherit "VisualConst.inc"
    #inherit "TestConst.inc"
    #inherit "PrintDisk.inc"

    func main()
    var hstrings ; // Handle to access uSD strings, uncomment if required
    var hFont1 ; // Handle to access uSD fonts, uncomment if required and change n to font number
    var hFont2 ; // Handle to access uSD fonts, uncomment if required and change n to font number
    // Uncomment the following if uSD images, fonts or strings used.

    putstr("Mounting...\n");
    if (!(disk:=file_Mount()))
    while(!(disk :=file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif
    gfx_TransparentColour(0x0020); // uncomment if transparency required
    gfx_Transparency(ON); // uncomment if transparency required

    hFont1 := file_LoadImageControl("Test.da1", "Test.gc1", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
    hstrings := file_Open("Test.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
    hndl := file_LoadImageControl("Test.dat", "Test.gci", 1);

    gfx_Set(SCREEN_MODE,LANDSCAPE) ;

    // Strings1 1.0 generated 2013-12-26 22:34:28
    txt_FontID(hFont1) ; // Font index correct at time of code generation
    txt_FGcolour(WHITE) ;
    txt_BGcolour(BLACK) ;
    gfx_MoveTo(10, 10) ;
    PrintDisk(hstrings, Strings1StartH, Strings1StartL, Strings1Size, 0) ; // where i is Message 0 - Strings1Count-1

    print("testing");
    gfx_MoveTo(50, 150) ;
    putstr("bbbbbbbb\n");
    putnum(HEX,34);
    print("\n");


    repeat
    forever
    endfunc


  • #2


    The problems seems to be caused by the line:
    hndl := file_LoadImageControl("Test.dat", "Test.gci", 1);

    It is not needed and it tries to load non existent files.

    Comment


    • #3


      So is everything OK now?

      What PmmC version are you using?
      Mark

      Comment


      • #4


        "Everything" works for me now
        Though, I still dont understand why it went wrong that way...

        I use PmmC 38 with uLCD-43PT

        By the way,
        is it possible to modify font bitmaps in Workshop4 or shall I use the "FOONT Tool" for this?

        Comment


        • #5


          Though, I still dont understand why it went wrong that way...
          There's a bug in R38 that means images are not attempted to be written if there is any sort of file error present. Opening the non-existent file causes the error, in this case.

          It will be fixed in R39

          is it possible to modify font bitmaps in Workshop4 or shall I use the "FOONT Tool" for this?
          The idea behind the Unicode fonts support was that you wouldn't need to modify fonts anymore, I mean who modifies Windows fonts..... Anyway, yes, you will need to use Font Tool if you want to do this
          Mark

          Comment

          Working...
          X