PureBasic Forum
https://www.purebasic.fr/english/

DrawText and single characters
https://www.purebasic.fr/english/viewtopic.php?f=4&t=53711
Page 1 of 1

Author:  tycoon [ Wed Feb 27, 2013 6:10 pm ]
Post subject:  DrawText and single characters

Code:
;DrawText and single characters

;Some characters are clipped off with DrawText and DrawRotatedText
;it works on WindowOutput but not on ImageOutput and CanvasOutput
;there is also a difference between DrawText and DrawRotatedText
;(same on Linux but with no difference in DrawText and DrawRotatedText)


Procedure Draw(txt$,output)
  StartDrawing(output)
 
  Box(0,0,300,300,0)
  DrawingMode(#PB_2DDrawing_Transparent)

  DrawingFont(FontID(0))
 
  For i = 1 To Len(txt$)
    Char$ = Mid(txt$, i, 1)
    width = TextWidth(Char$)
    DrawText(pos, 10, Char$, $FF)
    DrawRotatedText(pos, 100, Char$, 0, $FF)
    pos + width
  Next
  ;DrawText(0, 190, txt$, $FF00)
 
  StopDrawing()
EndProcedure


 OpenWindow(0, 20, 20, 900, 300, "drawtext", #PB_Window_SystemMenu)
  ImageGadget(0,300,0,300,300,0)
  CanvasGadget(1,600,0,300,300)
 
  CreateImage(0,300,300,24)
  LoadFont(0, "Arial",50,#PB_Font_Bold|#PB_Font_Italic)
 
  txt$ = "VfgHello"
 
  Draw(txt$,WindowOutput(0))
  Draw(txt$,ImageOutput(0))
  Draw(txt$,CanvasOutput(1))
  SetGadgetState(0,ImageID(0))
 
  FreeFont(0)
 
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/