Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yagl text output
#1
Does anyone know how i would calculate the x-length of a string in pixels to be outputted by the Yagl text thingo?
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#2
You can use GfxFont::getTextDimensions (YaglGfxFont_getTextDimensions in the wrapper):

Code:
Dim font As YaglGfxFont
Dim text As String
Dim x As UInteger, y As UInteger

...

text = "Hello, world"

YaglGfxFont_getTextDimensions(font, text, x, y)
Reply
#3
it doesn't seem to work the compiler yields the error
error 10: expected '=', found 'dispfont'
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#4
Could you post your code?
Reply
#5
Code:
SUB makebutton (x1, y1, x2, y2, text$, idx)

z = buttonindex(idx)

If z = 0 Then leftcol = rgb(255, 255, 255): rightcol = rgb(200, 200, 200): fontcol = 0
If z = 1 Then leftcol = rgb(200, 200, 200): rightcol = rgb(255, 255, 255): fontcol = rgb(0, 0, 255)

YaglGfxDevice_SolidBox x1, y1, x2, y2, rgb(240, 240, 240), 1
YaglGfxDevice_Solidbox x1, y1, x2, y1 + 2, leftcol, 1
YaglGfxDevice_SolidBox x1, y1, x1 + 2, y2, leftcol, 1

YaglGfxDevice_SolidBox x2, y2, x2 - 2, y1, rightcol, 1
YaglGfxDevice_SolidBox x2, y2, x1, y2 - 2, rightcol, 1

YaglGfxFont_getTextDimensions dispfont, text$, strxlen, strylen
'YaglGfxFont_getTextDimensions


'strlen = len(text$) * 12

xlen = x2 - x1
ylen = y2 - y1
xdisp = (xlen - strxlen) \ 2

ydisp = (ylen - strylen) \ 2

YaglGfxDevice_Printat text$, x1 + xdisp, y1 + ydisp, fontcol, dispfont, 1



END SUB
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#6
Its ok i figured out what's wrong. for some reason the function is YagGfxDevice, and is missing an l.
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#7
Hmm, there's a typo in the latest released yaglwrapper.bi - change "YagGfxFont_getTextDimensions" to "YaglGfxFont_getTextDimensions" (add the "L").
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)