Page 1 of 1

Scintilla printer

Posted: Tue Jul 09, 2024 3:02 pm
by rndrei
For some reason, my printer prints in Chinese characters?

Code: Select all

...

ScintillaSendMessage(#SC, #SCI_STYLESETFONT,#STYLE_DEFAULT, @"Peddana") 
ScintillaSendMessage(#SC, #SCI_STYLESETSIZE,#STYLE_DEFAULT, 16) 

...

Procedure _Printer()
 Define *bufline
 LoadFont(#FONT, "Peddana", 16, 0)
 If PrintRequester()       
  If StartPrinting(gadgetString)
    If StartDrawing(PrinterOutput())   
      BackColor(RGB(255, 255, 255)) 
      FrontColor(RGB(0, 0, 0)) 
      DrawingFont(FontID(#FONT))
      *bufline = AllocateMemory(1000)
      For i=0 To ScintillaSendMessage(#SC, #SCI_GETLINECOUNT)-1 
        ScintillaSendMessage(#SC,#SCI_GETLINE,i,*bufline)
        DrawText(50,10, PeekS(*bufline), #PB_UTF8 )
      Next i
      StopDrawing()
    EndIf 
    StopPrinting()
  EndIf
EndIf 
FreeMemory(*bufline)
EndProcedure

Re: Scintilla printer

Posted: Tue Jul 09, 2024 5:41 pm
by spikey
There's a problem with this line, you're sending the #PB_UTF8 value to DrawText as the FrontColor parameter, not PeekS:

Code: Select all

DrawText(50,10, PeekS(*bufline), #PB_UTF8 )
It should say:

Code: Select all

DrawText(50,10, PeekS(*bufline, #PB_UTF8) )
I also needed to convert the font name to UTF8 too, something like:

Code: Select all

*FontName = UTF8("Peddana")
ScintillaSendMessage(#SC, #SCI_STYLESETFONT,#STYLE_DEFAULT, *FontName) 
FreeMemory(*FontName)

Re: Scintilla printer

Posted: Thu Jul 11, 2024 7:01 pm
by rndrei
Thanks, I didn't notice! Everything worked!