CTTypesetterCreateLineWithOffset 与 CTTypesetterCreateLine 有何不同?
文档说调用 CTTypesetterCreateLine
与调用 CTTypesetterCreateLineWithOffset
并将 offset
设置为 0.0 相同,但描述了 offset 的意思是相当缺乏:“行位置偏移。”
我尝试为其提供不同的值,它似乎对生成的 CTLineRef
的印刷边界或图像边界没有任何影响,也似乎不会影响绘制线条的结果使用CTLineDraw
。谁能告诉我这个额外参数的用途吗?
The docs say that calling CTTypesetterCreateLine
is the same as calling CTTypesetterCreateLineWithOffset
with offset
set to 0.0, but the description of what offset
means is rather lacking: "The line position offset."
I've tried providing different values to it and it doesn't seem to have any impact on the typographic bounds or image bounds of the resulting CTLineRef
, nor does it seem to affect the result of drawing the line using CTLineDraw
. Can anyone clue me in as to the purpose of this extra parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
偏移量是制表符偏移量。它不适用于整个行,而是适用于第一个制表位。
来自 http://lists.apple.com/archives/Coretext- dev/2011/Feb/msg00021.html
您创建一个包含制表符的字符串,如“A[tab]B”,制表符位置为 200。
当您创建一条偏移量为零的线并将其绘制在 (x, y) 处时,它将如下所示。
当你创建一条偏移量为 50 的线并在 (x + 50, y) 处绘制它时(←你需要自己调整 X 坐标),它会显示如下,
AB
(x+50,y) (x+200,y)
请注意,即使该线从不同的位置开始,“B”仍保持在相同的位置。如果您传递偏移量 0 并将其绘制在 (x + 50, y) 处,则结果将如下所示。
The offset is a tab offset. It doesn't apply to the line as a whole, but to the first tab-stop.
From http://lists.apple.com/archives/Coretext-dev/2011/Feb/msg00021.html
You create a string containing a tab like "A[tab]B" with Tab position at 200.
When you create a line with offset Zero and draw it at (x, y), it will appear like this.
When you create a line with offset 50 and draw it at (x + 50, y) (← you need to adjust X coordinate yourself), it will appear like this,
A B
(x+50,y) (x+200,y)
Note that "B" remains at the same position even though the line starts at a different position. If you were passing offset 0 and draw it at (x + 50, y), it would have been like the following.