You can do a lot more now
viewtopic.php?f=13&t=75332
Best regards Saki
Code: Select all
; By Danilo
Procedure.d VectorTextWidthPro(text$, flags=#PB_VectorText_Default)
; Returns the VectorTextWidth() of the longest line (separated by #LF$)
;
Protected i, width.d, result.d = 0.0, count = CountString(text$,#LF$)
For i = 0 To count
width = VectorTextWidth(StringField(text$,i+1,#LF$),flags)
If width > result
result = width
EndIf
Next
Debug result
ProcedureReturn result
EndProcedure
; By Danilo
Procedure.d VectorTextHeightPro(text$, flags=#PB_VectorText_Default)
;
; Returns the VectorTextHeight() of all lines (separated by #LF$)
;
ProcedureReturn VectorTextHeight(text$, flags) * (CountString(text$,#LF$) + 1)
EndProcedure
; By Danilo
Procedure DrawVectorTextPro(text$, x, y)
;
; Multi-line DrawVectorText(). Lines separated by #LF$.
;
Protected count = CountString(text$,#LF$)
Protected height.d = VectorTextHeight(text$)
Protected i
For i = 0 To count
MovePathCursor(x,y+(i*height))
DrawVectorText(StringField(text$,i+1,#LF$))
Next
EndProcedure
Define window = OpenWindow(#PB_Any, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define canvas = CanvasGadget(#PB_Any, 0, 0, 800, 600)
Define font = LoadFont(#PB_Any, "", 21, #PB_Font_Bold)
Define text$ = "DrawVectorText()"+#LF$+"can also multiline"+#LF$+"output !"+#LF$+"Best regards - Saki"
Define x=200
Define y=0
StartVectorDrawing(CanvasVectorOutput(canvas))
VectorFont(FontID(font))
MovePathCursor (x, y)
RotateCoordinates(y, y, 20)
VectorSourceColor($FF00FFFF)
Define padding=VectorTextwidthPro(Space(6))
AddPathBox(x-padding, y - padding, VectorTextWidthPro(text$) + padding * 2, VectorTextHeightPro(text$))
FillPath()
VectorSourceColor($FF0000FF)
AddPathBox(x-padding, y - padding, VectorTextWidthPro(text$) + padding * 2, VectorTextHeightPro(text$))
StrokePath(6)
VectorSourceColor($FFFF0000)
DrawVectorTextPro(text$, x, y)
StopVectorDrawing()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow