Class: HarfBuzz::DrawFuncs
- Inherits:
-
Object
- Object
- HarfBuzz::DrawFuncs
- Defined in:
- lib/harfbuzz/draw_funcs.rb
Overview
Wraps hb_draw_funcs_t — callbacks for glyph outline rendering
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
Instance Method Summary collapse
-
#immutable? ⇒ Boolean
True if immutable.
-
#initialize ⇒ DrawFuncs
constructor
A new instance of DrawFuncs.
- #inspect ⇒ Object
-
#make_immutable! ⇒ self
Makes immutable (call after setting all callbacks).
-
#on_close_path { ... } ⇒ Object
Sets the close_path callback.
-
#on_cubic_to {|c1x, c1y, c2x, c2y, x, y| ... } ⇒ Object
Sets the cubic_to callback.
-
#on_line_to {|x, y| ... } ⇒ Object
Sets the line_to callback.
-
#on_move_to {|x, y| ... } ⇒ Object
Sets the move_to callback.
-
#on_quadratic_to {|cx, cy, x, y| ... } ⇒ Object
Sets the quadratic_to callback.
Constructor Details
#initialize ⇒ DrawFuncs
Returns a new instance of DrawFuncs.
18 19 20 21 22 23 |
# File 'lib/harfbuzz/draw_funcs.rb', line 18 def initialize @ptr = C.hb_draw_funcs_create raise AllocationError, "Failed to create draw_funcs" if @ptr.null? HarfBuzz::DrawFuncs.define_finalizer(self, @ptr) end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
16 17 18 |
# File 'lib/harfbuzz/draw_funcs.rb', line 16 def ptr @ptr end |
Class Method Details
.define_finalizer(obj, ptr) ⇒ Object
107 108 109 110 |
# File 'lib/harfbuzz/draw_funcs.rb', line 107 def self.define_finalizer(obj, ptr) destroy = C.method(:hb_draw_funcs_destroy) ObjectSpace.define_finalizer(obj, proc { destroy.call(ptr) }) end |
Instance Method Details
#immutable? ⇒ Boolean
Returns true if immutable.
26 27 28 |
# File 'lib/harfbuzz/draw_funcs.rb', line 26 def immutable? C.from_hb_bool(C.hb_draw_funcs_is_immutable(@ptr)) end |
#inspect ⇒ Object
103 104 105 |
# File 'lib/harfbuzz/draw_funcs.rb', line 103 def inspect "#<HarfBuzz::DrawFuncs immutable=#{immutable?}>" end |
#make_immutable! ⇒ self
Makes immutable (call after setting all callbacks)
32 33 34 35 |
# File 'lib/harfbuzz/draw_funcs.rb', line 32 def make_immutable! C.hb_draw_funcs_make_immutable(@ptr) self end |
#on_close_path { ... } ⇒ Object
Sets the close_path callback
93 94 95 96 97 98 99 100 101 |
# File 'lib/harfbuzz/draw_funcs.rb', line 93 def on_close_path(&block) @close_path_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer, :pointer]) do |_dfuncs, _draw_data, _st, _user_data| block.call end @close_path_ffi = cb C.hb_draw_funcs_set_close_path_func(@ptr, cb, nil, nil) end |
#on_cubic_to {|c1x, c1y, c2x, c2y, x, y| ... } ⇒ Object
Sets the cubic_to callback
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/harfbuzz/draw_funcs.rb', line 79 def on_cubic_to(&block) @cubic_to_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer, :float, :float, :float, :float, :float, :float, :pointer]) do |_dfuncs, _draw_data, _st, c1x, c1y, c2x, c2y, x, y, _user_data| block.call(c1x, c1y, c2x, c2y, x, y) end @cubic_to_ffi = cb C.hb_draw_funcs_set_cubic_to_func(@ptr, cb, nil, nil) end |
#on_line_to {|x, y| ... } ⇒ Object
Sets the line_to callback
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/harfbuzz/draw_funcs.rb', line 52 def on_line_to(&block) @line_to_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer, :float, :float, :pointer]) do |_dfuncs, _draw_data, _st, x, y, _user_data| block.call(x, y) end @line_to_ffi = cb C.hb_draw_funcs_set_line_to_func(@ptr, cb, nil, nil) end |
#on_move_to {|x, y| ... } ⇒ Object
Sets the move_to callback
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/harfbuzz/draw_funcs.rb', line 39 def on_move_to(&block) @move_to_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer, :float, :float, :pointer]) do |_dfuncs, _draw_data, _st, x, y, _user_data| block.call(x, y) end @move_to_ffi = cb C.hb_draw_funcs_set_move_to_func(@ptr, cb, nil, nil) end |
#on_quadratic_to {|cx, cy, x, y| ... } ⇒ Object
Sets the quadratic_to callback
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/harfbuzz/draw_funcs.rb', line 65 def on_quadratic_to(&block) @quadratic_to_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer, :float, :float, :float, :float, :pointer]) do |_dfuncs, _draw_data, _st, cx, cy, x, y, _user_data| block.call(cx, cy, x, y) end @quadratic_to_ffi = cb C.hb_draw_funcs_set_quadratic_to_func(@ptr, cb, nil, nil) end |