Class: HarfBuzz::PaintFuncs
- Inherits:
-
Object
- Object
- HarfBuzz::PaintFuncs
- Defined in:
- lib/harfbuzz/paint_funcs.rb
Overview
Wraps hb_paint_funcs_t — callbacks for color glyph rendering (COLRv1)
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 ⇒ PaintFuncs
constructor
A new instance of PaintFuncs.
- #inspect ⇒ Object
-
#make_immutable! ⇒ self
Makes immutable.
-
#on_color {|is_foreground, color| ... } ⇒ Object
Sets color callback.
-
#on_pop_clip { ... } ⇒ Object
Sets pop_clip callback.
-
#on_pop_group {|mode| ... } ⇒ Object
Sets pop_group callback.
-
#on_pop_transform { ... } ⇒ Object
Sets pop_transform callback.
-
#on_push_clip_glyph {|glyph| ... } ⇒ Object
Sets push_clip_glyph callback.
-
#on_push_clip_rectangle {|xmin, ymin, xmax, ymax| ... } ⇒ Object
Sets push_clip_rectangle callback.
-
#on_push_group { ... } ⇒ Object
Sets push_group callback.
-
#on_push_transform {|xx, yx, xy, yy, dx, dy| ... } ⇒ Object
Sets push_transform callback.
Constructor Details
#initialize ⇒ PaintFuncs
Returns a new instance of PaintFuncs.
8 9 10 11 12 13 |
# File 'lib/harfbuzz/paint_funcs.rb', line 8 def initialize @ptr = C.hb_paint_funcs_create raise AllocationError, "Failed to create paint_funcs" if @ptr.null? HarfBuzz::PaintFuncs.define_finalizer(self, @ptr) end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
6 7 8 |
# File 'lib/harfbuzz/paint_funcs.rb', line 6 def ptr @ptr end |
Class Method Details
.define_finalizer(obj, ptr) ⇒ Object
129 130 131 132 |
# File 'lib/harfbuzz/paint_funcs.rb', line 129 def self.define_finalizer(obj, ptr) destroy = C.method(:hb_paint_funcs_destroy) ObjectSpace.define_finalizer(obj, proc { destroy.call(ptr) }) end |
Instance Method Details
#immutable? ⇒ Boolean
Returns true if immutable.
16 17 18 |
# File 'lib/harfbuzz/paint_funcs.rb', line 16 def immutable? C.from_hb_bool(C.hb_paint_funcs_is_immutable(@ptr)) end |
#inspect ⇒ Object
125 126 127 |
# File 'lib/harfbuzz/paint_funcs.rb', line 125 def inspect "#<HarfBuzz::PaintFuncs immutable=#{immutable?}>" end |
#make_immutable! ⇒ self
Makes immutable
22 23 24 25 |
# File 'lib/harfbuzz/paint_funcs.rb', line 22 def make_immutable! C.hb_paint_funcs_make_immutable(@ptr) self end |
#on_color {|is_foreground, color| ... } ⇒ Object
Sets color callback
91 92 93 94 95 96 97 98 99 |
# File 'lib/harfbuzz/paint_funcs.rb', line 91 def on_color(&block) @color_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :int, :uint32, :pointer]) do |_pfuncs, _paint_data, is_foreground, color, _user_data| block.call(C.from_hb_bool(is_foreground), color) end @color_ffi = cb C.hb_paint_funcs_set_color_func(@ptr, cb, nil, nil) end |
#on_pop_clip { ... } ⇒ Object
Sets pop_clip callback
79 80 81 82 83 84 85 86 87 |
# File 'lib/harfbuzz/paint_funcs.rb', line 79 def on_pop_clip(&block) @pop_clip_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer]) do |_pfuncs, _paint_data, _user_data| block.call end @pop_clip_ffi = cb C.hb_paint_funcs_set_pop_clip_func(@ptr, cb, nil, nil) end |
#on_pop_group {|mode| ... } ⇒ Object
Sets pop_group callback
115 116 117 118 119 120 121 122 123 |
# File 'lib/harfbuzz/paint_funcs.rb', line 115 def on_pop_group(&block) @pop_group_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :int, :pointer]) do |_pfuncs, _paint_data, mode, _user_data| block.call(mode) end @pop_group_ffi = cb C.hb_paint_funcs_set_pop_group_func(@ptr, cb, nil, nil) end |
#on_pop_transform { ... } ⇒ Object
Sets pop_transform callback
42 43 44 45 46 47 48 49 50 |
# File 'lib/harfbuzz/paint_funcs.rb', line 42 def on_pop_transform(&block) @pop_transform_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer]) do |_pfuncs, _paint_data, _user_data| block.call end @pop_transform_ffi = cb C.hb_paint_funcs_set_pop_transform_func(@ptr, cb, nil, nil) end |
#on_push_clip_glyph {|glyph| ... } ⇒ Object
Sets push_clip_glyph callback
54 55 56 57 58 59 60 61 62 |
# File 'lib/harfbuzz/paint_funcs.rb', line 54 def on_push_clip_glyph(&block) @push_clip_glyph_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :uint32, :pointer, :pointer]) do |_pfuncs, _paint_data, glyph, _font, _user_data| block.call(glyph) end @push_clip_glyph_ffi = cb C.hb_paint_funcs_set_push_clip_glyph_func(@ptr, cb, nil, nil) end |
#on_push_clip_rectangle {|xmin, ymin, xmax, ymax| ... } ⇒ Object
Sets push_clip_rectangle callback
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/harfbuzz/paint_funcs.rb', line 66 def on_push_clip_rectangle(&block) @push_clip_rectangle_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :float, :float, :float, :float, :pointer]) do |_pfuncs, _paint_data, xmin, ymin, xmax, ymax, _user_data| block.call(xmin, ymin, xmax, ymax) end @push_clip_rectangle_ffi = cb C.hb_paint_funcs_set_push_clip_rectangle_func(@ptr, cb, nil, nil) end |
#on_push_group { ... } ⇒ Object
Sets push_group callback
103 104 105 106 107 108 109 110 111 |
# File 'lib/harfbuzz/paint_funcs.rb', line 103 def on_push_group(&block) @push_group_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :pointer]) do |_pfuncs, _paint_data, _user_data| block.call end @push_group_ffi = cb C.hb_paint_funcs_set_push_group_func(@ptr, cb, nil, nil) end |
#on_push_transform {|xx, yx, xy, yy, dx, dy| ... } ⇒ Object
Sets push_transform callback
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/harfbuzz/paint_funcs.rb', line 29 def on_push_transform(&block) @push_transform_callback = block cb = FFI::Function.new(:void, [:pointer, :pointer, :float, :float, :float, :float, :float, :float, :pointer]) do |_pfuncs, _paint_data, xx, yx, xy, yy, dx, dy, _user_data| block.call(xx, yx, xy, yy, dx, dy) end @push_transform_ffi = cb C.hb_paint_funcs_set_push_transform_func(@ptr, cb, nil, nil) end |