MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / GetPartialText

Function GetPartialText

gui/utils/draw.py:62–86  ·  view source on GitHub ↗
(dc, text , maxWidth, defEllipsis="...")

Source from the content-addressed store, hash-verified

60
61
62def GetPartialText(dc, text , maxWidth, defEllipsis="..."):
63 ellipsis = defEllipsis
64 base_w, h = dc.GetTextExtent(ellipsis)
65
66 lenText = len(text)
67 drawntext = text
68 w, dummy = dc.GetTextExtent(text)
69
70 while lenText > 0:
71
72 if w + base_w <= maxWidth:
73 break
74
75 w_c, h_c = dc.GetTextExtent(drawntext[-1])
76 drawntext = drawntext[0:-1]
77 lenText -= 1
78 w -= w_c
79
80 while len(ellipsis) > 0 and w + base_w > maxWidth:
81 ellipsis = ellipsis[0:-1]
82 base_w, h = dc.GetTextExtent(ellipsis)
83 if len(text) > lenText:
84 return drawntext + ellipsis
85 else:
86 return text
87
88
89def CreateDropShadowBitmap(bitmap, opacity):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected