Page 1 of 1

PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Fri Jul 15, 2016 10:32 pm
by DoubleDutch
Vector fonts are not scaled properly when using pixel mode to printer.

Code: Select all

If PrintRequester()

  If StartPrinting("PureBasic Test")
  
    LoadFont(0, "Arial", 30)
    LoadFont(1, "Arial", 100)
  
    If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Pixel))  ; fonts are not scaled properly in unit_pixel mode.
      
      VectorFont(FontID(0))
      MovePathCursor(100, 100)
      DrawVectorText("PureBasic Printer Test")
      
      VectorFont(FontID(1))
      MovePathCursor(100, 400)
      DrawVectorText("PureBasic Printer Test 2")
      
      AddPathBox(200, 200, 100, 100)
      VectorSourceColor(RGBA(255, 0, 0, 255)) ; Draw a red box
      StrokePath(10)
        
      StopVectorDrawing()
    EndIf
    
    StopPrinting()
  EndIf
EndIf
If you use "StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Pixel))" then the fonts are not scaled properly.

See:
Image

compared to this if you use "StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Point))"...
Image

For images it works as you would expect:

Code: Select all

UsePNGImageEncoder()

CreateImage(0,1000,1000,32,RGB($ff,$ff,$ff))
	
LoadFont(0, "Arial", 30)
LoadFont(1, "Arial", 100)

If StartVectorDrawing(ImageVectorOutput(0,#PB_Unit_Pixel))  ; fonts are not scaled properly in unit_pixel mode.
  
  VectorFont(FontID(0))
  MovePathCursor(100, 100)
  DrawVectorText("PureBasic Printer Test")
  
  VectorFont(FontID(1))
  MovePathCursor(100, 400)
  DrawVectorText("PureBasic Printer Test 2")
  
  AddPathBox(200, 200, 100, 100)
  VectorSourceColor(RGBA(255, 0, 0, 255)) ; Draw a red box
  StrokePath(10)
    
  StopVectorDrawing()
EndIf

SaveImage(0,"pixelimage.png",#PB_ImagePlugin_PNG)
Here it is when drawn as pixels:
Image

Here it is when drawn as points:
Image

Re: PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Sat Jul 16, 2016 6:08 am
by davido
In the meantime you might like to look at this:
http://www.purebasic.fr/english/viewtop ... 81#p491081

Re: PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Sat Jul 16, 2016 6:51 am
by DoubleDutch
Thanks for the link. :)

I think this really is a bug though with the font scaling in pixel mode specifically to the printer. Does it happen for you too?

Re: PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Sat Jul 16, 2016 11:55 pm
by davido
@DoubleDutch ,

To be honest, I'm not really sure.
I spent a few 'happy hours' trying to get the same output on different printers connected to both PC's and Macs, without much success. I put it down to my lack of understanding.
I was hoping Freak might share his views on the subject.

Re: PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Sun Jul 17, 2016 8:21 am
by DoubleDutch
I understand the scaling, etc - for pixel mode though the fonts seem to get their scale incorrectly when using the Printer output.

Re: PB 5.50b2 - vector fonts not scaled properly to printer

Posted: Tue Sep 13, 2016 11:00 am
by DoubleDutch
I discovered that the VectorFont command is actually at fault. If you set the scale value manually then all is ok:

Code: Select all

If PrintRequester()

  If StartPrinting("PureBasic Test")
  
    LoadFont(0, "Arial", 30)
    LoadFont(1, "Arial", 100)
  
    If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Pixel))  ; fonts are not scaled properly in unit_pixel mode.
      
      VectorFont(FontID(0),30) ; bug appears to be in getting the original font size? setting it manually to the same value works!
      MovePathCursor(100, 100)
      DrawVectorText("PureBasic Printer Test")
      
      VectorFont(FontID(1),100) ; bug appears to be in getting the original font size? setting it manually to the same value works!
      MovePathCursor(100, 400)
      DrawVectorText("PureBasic Printer Test 2")
      
      AddPathBox(200, 200, 100, 100)
      VectorSourceColor(RGBA(255, 0, 0, 255)) ; Draw a red box
      StrokePath(10)
        
      StopVectorDrawing()
    EndIf
    
    StopPrinting()
  EndIf
EndIf
So it looks like in pixel mode the scaling isn't done from the original font size value when printing to a printer = the actual bug!