Handbook
Glossary
x>offset ( x font string -- n )
Factor handbook
»
UI framework
»
Implementing new gadgets
»
Customizing gadget appearance
»
Implementing custom drawing logic
»
Rendering text
Prev:
line-metrics ( font string -- metrics )
Next:
offset>x ( n font string -- x )
Vocabulary
ui
.
text
Inputs
x
a
real
font
a
font
string
a
string
Outputs
n
an
integer
Generic word contract
Outputs the string index closest to the given x coordinate.
Definition
USING:
ui.text.private
;
IN:
ui.text
HOOK:
x>offset
font-renderer
( x font string -- n )
Methods
USING:
accessors
core-graphics.types
core-text
io.encodings.string
io.encodings.utf16
kernel
math
opengl
sequences
ui.text
ui.text.core-text
;
M::
core-text-renderer
x>offset
( x font string -- n )
x font string
[
2drop
0
]
[
cached-line
line>>
swap
gl-scale
0
<CGPoint>
CTLineGetStringIndexForPosition
2
*
0
swap
string
utf16n
encode
subseq
utf16n
decode
length
]
if-empty
;