VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.72

Just starting out? Need help? Post your questions and find answers here.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.72

Post by Saki »

Hi all,
it look, VectorTextWidth() fail with line break

It is probably because DrawVectorText cannot do Multiline on Mac;
which would have to be clarified, since it works on Linux and Windows

But, it should work because VectorTextHeight works

Regards Saki

Code: Select all

Define wID=OpenWindow(#PB_Any , 0 , 0 , 900 , 600 , "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define cID=CanvasGadget(#PB_Any , 0 , 0 , WindowWidth(wID) , WindowHeight(wID))

Define font=LoadFont(#PB_Any , " Monotype Corsiva ", 20 , #PB_Font_Italic )

StartVectorDrawing(CanvasVectorOutput(cID))

VectorFont(FontID(font) , 12)

Define text1$="The quick brown fox jumps over the lazy dog"+#LF$+
              "The quick brown fox jumps over the lazy dog"
Debug text1$
Debug VectorTextWidth(text1$)
Debug VectorTextHeight(text1$)

Define text2$="The quick brown fox jumps over the lazy dog"
Debug text2$
Debug VectorTextWidth(text2$)
Debug VectorTextHeight(text2$)

StopVectorDrawing()
地球上の平和
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by freak »

This is not supported.
quidquid Latine dictum sit altum videtur
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by Olliv »

Saki wrote:But, it should work because VectorTextHeight works
Hello Saki,

the supported versions on Linux and Windows : is it multi-font ?
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by Saki »

@Freak
Thanks for the info.

Its not difficult to emulate this feature for Mac

Hi Olliv,
what you mean with multi font ?

Sorry all, i understand not good english

Regards Saki
地球上の平和
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by Olliv »

multi-font
複数のフォント
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by Danilo »

Saki probably means multi-line:

Code: Select all

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
    ProcedureReturn result
EndProcedure

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


Define wID=OpenWindow(#PB_Any , 0 , 0 , 900 , 600 , "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define cID=CanvasGadget(#PB_Any , 0 , 0 , WindowWidth(wID) , WindowHeight(wID))

Define font=LoadFont(#PB_Any , " Monotype Corsiva ", 20 , #PB_Font_Italic )

StartVectorDrawing(CanvasVectorOutput(cID))

VectorFont(FontID(font) , 12)

Define text1$="The quick brown fox jumps over the lazy dog"+#LF$+
              "The quick brown fox jumps over the lazy dog"+#LF$+
              "The quick brown fox jumps over the lazy dog and falls."
Debug text1$
Debug "Width = " + VectorTextWidth(text1$) + " Multi = " + VectorTextWidthPro(text1$)
Debug VectorTextHeightPro(text1$)

Define text2$="The quick brown fox jumps over the lazy dog"
Debug text2$
Debug "Width = " + VectorTextWidth(text2$) + " Multi = " + VectorTextWidthPro(text2$)
Debug VectorTextHeight(text2$)

StopVectorDrawing()
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: VectorTextWidth funktioniert nicht mit Zeilenumbruch 5.7

Post by Saki »

Ih Olliv,
Yes, multi font

Hi Danielo,
Thanks for the changed code
With StringField it is very elegant

Best regards Saki
地球上の平和
Post Reply