Hi,
I wrote a function to get a copy of wrapped text in a face object. I think it could be useful for someone else.
;a long text to be wrapped by face object
s: {Originally, these port numbers were used by the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP),
but are used also for the Stream Control Transmission Protocol (SCTP), and the Datagram Congestion Control Protocol (DCCP).
SCTP and DCCP services usually use a port number that matches the service of the corresponding TCP or UDP implementation if they exist.
The Internet Assigned Numbers Authority (IANA) is responsible for maintaining the official assignments of port numbers for specific uses.[1]
However, many unofficial uses of both well-known and registered port numbers occur in practice.}
gui: layout [
backcolor gray / 1
m: label 200 s white red edge [size: 4x4 color: black]
]
wrap-text: func ["Returns the wrapped text in a face object." f "Face object." /local p t tmp-face h] [
if any [none? f/text empty? f/text] [return copy ""]
;find the font height in pixels
tmp-face: make face m []
tmp-face/text: copy/part tmp-face/text 1
h: second size-text tmp-face
t: copy f/text
repeat i length? f/line-list [
p: index? offset-to-caret f as-pair 0 i + 1 * h
insert at t p + i - 1 newline
]
t
]
print wrap-text m
view gui