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.
95
96
97
98
|
# File 'lib/harfbuzz/buffer.rb', line 95
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.
93
94
95
|
# File 'lib/harfbuzz/buffer.rb', line 93
def hb_buffer
@hb_buffer
end
|
Instance Method Details
#add_utf8(text, offset = 0, length = -1)) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/harfbuzz/buffer.rb', line 100
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
119
120
121
122
123
124
125
126
|
# File 'lib/harfbuzz/buffer.rb', line 119
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
128
129
130
131
132
133
134
135
|
# File 'lib/harfbuzz/buffer.rb', line 128
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
107
108
109
|
# File 'lib/harfbuzz/buffer.rb', line 107
def guess_segment_properties
Harfbuzz.hb_buffer_guess_segment_properties(@hb_buffer)
end
|
#length ⇒ Object
115
116
117
|
# File 'lib/harfbuzz/buffer.rb', line 115
def length
Harfbuzz.hb_buffer_get_length(@hb_buffer)
end
|
#normalize_glyphs ⇒ Object
111
112
113
|
# File 'lib/harfbuzz/buffer.rb', line 111
def normalize_glyphs
Harfbuzz.hb_buffer_normalize_glyphs(@hb_buffer)
end
|