Just starting out? Need help? Post your questions and find answers here.
User avatar
Niffo
 
Posts: 47
Joined: Sat Jun 16, 2018 10:30 pm

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

by Niffo Wed Jan 09, 2019 3:32 pm

Since parameter "Flag" in LoadFont() is ignored, how to draw text in "bold" style in a CanvasGadget ?
User avatar
Peter
 
Posts: 596
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

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

by Peter Wed Jan 09, 2019 7:52 pm

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
User avatar
Niffo
 
Posts: 47
Joined: Sat Jun 16, 2018 10:30 pm

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

by Niffo Mon Jan 14, 2019 8:25 pm

Thank you very much Peter for this workaround !
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 6 guests