Page 1 of 1

How to draw text in "bold" style in a CanvasGadget ?

Posted: Wed Jan 09, 2019 3:32 pm
by Niffo
Since parameter "Flag" in LoadFont() is ignored, how to draw text in "bold" style in a CanvasGadget ?

Re: How to draw text in "bold" style in a CanvasGadget ?

Posted: Wed Jan 09, 2019 7:52 pm
by Peter
you can use a workaround by setting the font directly:

Code: Select all

spider.drawing.context.canvas.getContext("2d").font = "italic bold 24px Arial";

Code: Select all

If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 200, 200)
  If StartDrawing(CanvasOutput(0))
    DrawingMode(#PB_2DDrawing_Transparent)
    Box(0, 0, 200, 200, RGB(255, 255, 255))
    
    ! spider.drawing.context.canvas.getContext("2d").font = "italic bold 24px Arial";
    
    For i = 1 To 10
      DrawText(Random(200), Random(200), "Hello World!", RGB(Random(255), Random(255), Random(255)))
    Next i
    
    StopDrawing() 
    
  EndIf
EndIf

Re: How to draw text in "bold" style in a CanvasGadget ?

Posted: Mon Jan 14, 2019 8:25 pm
by Niffo
Thank you very much Peter for this workaround !

Re: How to draw text in "bold" style in a CanvasGadget ?

Posted: Thu Sep 19, 2019 7:33 am
by Dirk Geppert
Thank you Peter! It works also with StartDrawing(ImageOutput()) :D