Advertisement
Guest User

Untitled

a guest
May 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Sub GW_GetTextWidth
  2. ' GraphicsWindow | get text width
  3. ' param fs - font size
  4. ' param fn - font name
  5. ' param fb - font bold
  6. ' param fi - font italic
  7. ' param txt - text to get width in px
  8. ' return width - text width
  9. yc = 4
  10. bc = "#FFFFFF"
  11. bc6 = Text.GetSubTextToEnd(bc, Text.GetLength(bc) - 5)
  12. fc = "#FEFEFE"
  13. GraphicsWindow.BrushColor = bc
  14. GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
  15. GraphicsWindow.FontSize = fs
  16. GraphicsWindow.FontName = fn
  17. GraphicsWindow.FontBold = fb
  18. GraphicsWindow.FontItalic = fi
  19. GraphicsWindow.BrushColor = fc
  20. GraphicsWindow.DrawText(0, yc, "||")
  21. y0 = yc
  22. y1 = yc + fs
  23. x0 = 0
  24. x1 = fs * 2
  25. If gw < x1 Then
  26. x1 = gw - 1
  27. EndIf
  28. GW_Measure()
  29. px0 = px
  30. GraphicsWindow.BrushColor = bc
  31. GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
  32. str = "|" + txt + "|"
  33. GraphicsWindow.BrushColor = fc
  34. GraphicsWindow.DrawText(0, yc, str)
  35. x1 = fs * Text.GetLength(str)
  36. If gw < x1 Then
  37. x1 = gw - 1
  38. EndIf
  39. GW_Measure()
  40. width = px - px0
  41. EndSub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement