Scintilla printer

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Scintilla printer

Post 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
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Scintilla printer

Post 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)
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla printer

Post by rndrei »

Thanks, I didn't notice! Everything worked!
Post Reply