Class: Harfbuzz::Buffer
- Inherits:
-
Base
- Object
- Base
- Harfbuzz::Buffer
show all
- Defined in:
- lib/harfbuzz/buffer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#define_finalizer, finalize
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
89
90
91
92
|
# File 'lib/harfbuzz/buffer.rb', line 89
def initialize
@hb_buffer = Harfbuzz.hb_buffer_create
define_finalizer(:hb_buffer_destroy, @hb_buffer)
end
|
Instance Attribute Details
#hb_buffer ⇒ Object
Returns the value of attribute hb_buffer.
87
88
89
|
# File 'lib/harfbuzz/buffer.rb', line 87
def hb_buffer
@hb_buffer
end
|
Instance Method Details
#add_utf8(text, offset = 0, length = -1)) ⇒ Object
94
95
96
97
98
99
|
# File 'lib/harfbuzz/buffer.rb', line 94
def add_utf8(text, offset=0, length=-1)
raise "Expected text in UTF-8 encoding, but received #{text.encoding} (#{text.inspect})" unless text.encoding == Encoding::UTF_8
text_ptr = FFI::MemoryPointer.new(:char, text.bytesize)
text_ptr.put_bytes(0, text)
Harfbuzz.hb_buffer_add_utf8(@hb_buffer, text_ptr, text.bytesize, offset, length)
end
|
#get_glyph_infos ⇒ Object
113
114
115
116
117
118
119
120
|
# File 'lib/harfbuzz/buffer.rb', line 113
def get_glyph_infos
length_ptr = FFI::MemoryPointer.new(:uint, 1)
info_ptr = Harfbuzz.hb_buffer_get_glyph_infos(@hb_buffer, length_ptr)
length = length_ptr.read_uint
length.times.map do |i|
GlyphInfo.new(info_ptr + (i * GlyphInfo.size))
end
end
|
#get_glyph_positions ⇒ Object
122
123
124
125
126
127
128
129
|
# File 'lib/harfbuzz/buffer.rb', line 122
def get_glyph_positions
length_ptr = FFI::MemoryPointer.new(:uint, 1)
positions_ptr = Harfbuzz.hb_buffer_get_glyph_positions(@hb_buffer, length_ptr)
length = length_ptr.read_uint
length.times.map do |i|
GlyphPosition.new(positions_ptr + (i * GlyphPosition.size))
end
end
|
#guess_segment_properties ⇒ Object
101
102
103
|
# File 'lib/harfbuzz/buffer.rb', line 101
def guess_segment_properties
Harfbuzz.hb_buffer_guess_segment_properties(@hb_buffer)
end
|
#length ⇒ Object
109
110
111
|
# File 'lib/harfbuzz/buffer.rb', line 109
def length
Harfbuzz.hb_buffer_get_length(@hb_buffer)
end
|
#normalize_glyphs ⇒ Object
105
106
107
|
# File 'lib/harfbuzz/buffer.rb', line 105
def normalize_glyphs
Harfbuzz.hb_buffer_normalize_glyphs(@hb_buffer)
end
|