CTLine
class CTLine
class Truncation
Start, End, Middle = 0, 1, 2
end
def initialize(attributed_string)
@backing_store_string
end
def create_justified_line(line, justification_factor, justification_width)
line
end
def create_truncated_line(line, width, truncation_type, truncation_token)
line
end
def create_with_attributed_string(attributed_string)
line
end
# GlyphRunsを
def draw(context)
end
# このグリフ総数は、行を形成するグリフラン配列の中の、全グリフの合計と等しい
def glyph_count
@glyph_runs.inject(0){|glyph_count, glyph_run|
glyph_count += glyph_run.glyph.count
}
end
def glyph_runs
end
end
line = CTLine.new attributed_string
line.glyph_count# 行に渡されたグリフ総数
glyph_runs = line.glyph_runs
glyph_runs.each{|glyph_run|
glyph_run# glyph_runで何ができるのかが分かってないな・・・
}
# 行がどの矩形に描かれているかがわかる
rect = line.image_bounds context
puts "#{rect.origin.x}#{rect.origin.y}#{rect.size.w}#{rect.size.h}"
# ストリングインデックスのためのグラフィカルオフセットまたはオフセッツを決定する
offset = line.offsetForStringIndex(char_index, secondary_offset)
puts "オフセットは#{offset}です。"
# よくわからないので保留。キャレットが関係している?
# chara_index文字目のポジションを教えてくださいみたいな感じ?
#
pen_offset = line.pen_offset_for_flush(flush_factor, flush_width)
#
index = line.string_index_for_position(position)
puts "行の原点から(#{position.x}, #{position.y})の位置、つまり#{index}文字目がクリックされましたよ"
#
range = line.string_range
puts "stringの#{range.location}文字目から、#{range.length}文字分が、この行です。"
#
puts "ホワイトスペースの幅は#{line.trailing_whitespace_width}です。"
#
puts "この行のタイポグラフィー幅は#{line.typographic_bounds(ascent, descent, leading)}です。"
See also
Link
最終更新:2010年06月12日 12:05