Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub GW_GetTextWidth
- ' GraphicsWindow | get text width
- ' param fs - font size
- ' param fn - font name
- ' param fb - font bold
- ' param fi - font italic
- ' param txt - text to get width in px
- ' return width - text width
- yc = 4
- bc = "#FFFFFF"
- bc6 = Text.GetSubTextToEnd(bc, Text.GetLength(bc) - 5)
- fc = "#FEFEFE"
- GraphicsWindow.BrushColor = bc
- GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
- GraphicsWindow.FontSize = fs
- GraphicsWindow.FontName = fn
- GraphicsWindow.FontBold = fb
- GraphicsWindow.FontItalic = fi
- GraphicsWindow.BrushColor = fc
- GraphicsWindow.DrawText(0, yc, "||")
- y0 = yc
- y1 = yc + fs
- x0 = 0
- x1 = fs * 2
- If gw < x1 Then
- x1 = gw - 1
- EndIf
- GW_Measure()
- px0 = px
- GraphicsWindow.BrushColor = bc
- GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
- str = "|" + txt + "|"
- GraphicsWindow.BrushColor = fc
- GraphicsWindow.DrawText(0, yc, str)
- x1 = fs * Text.GetLength(str)
- If gw < x1 Then
- x1 = gw - 1
- EndIf
- GW_Measure()
- width = px - px0
- EndSub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement