Class: HarfBuzz::Subset::Plan
- Inherits:
-
Object
- Object
- HarfBuzz::Subset::Plan
- Defined in:
- lib/harfbuzz/subset.rb
Overview
Wraps hb_subset_plan_t — a more fine-grained subsetting plan
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute ⇒ HarfBuzz::Face
Executes the plan and returns the subsetted face.
-
#initialize(face, input) ⇒ Plan
constructor
Creates a subset plan for a face using the given input.
- #inspect ⇒ Object
-
#new_to_old_glyph_mapping ⇒ HarfBuzz::Map
Returns the new→old glyph ID mapping (borrowed).
-
#old_to_new_glyph_mapping ⇒ HarfBuzz::Map
Returns the old→new glyph ID mapping (borrowed).
-
#unicode_to_old_glyph_mapping ⇒ HarfBuzz::Map
Returns the unicode→old glyph ID mapping (borrowed).
Constructor Details
#initialize(face, input) ⇒ Plan
Creates a subset plan for a face using the given input
83 84 85 86 87 88 89 90 |
# File 'lib/harfbuzz/subset.rb', line 83 def initialize(face, input) raise UnavailableError, "libharfbuzz-subset is not available" unless C.available? @ptr = C.hb_subset_plan_create_or_fail(face.ptr, input.ptr) raise SubsetError, "Failed to create subset plan" if @ptr.null? HarfBuzz::Subset::Plan.define_finalizer(self, @ptr) end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
76 77 78 |
# File 'lib/harfbuzz/subset.rb', line 76 def ptr @ptr end |
Class Method Details
.define_finalizer(obj, ptr) ⇒ Object
124 125 126 127 |
# File 'lib/harfbuzz/subset.rb', line 124 def self.define_finalizer(obj, ptr) destroy = C.method(:hb_subset_plan_destroy) ObjectSpace.define_finalizer(obj, proc { destroy.call(ptr) }) end |
Instance Method Details
#execute ⇒ HarfBuzz::Face
Executes the plan and returns the subsetted face
95 96 97 98 99 100 |
# File 'lib/harfbuzz/subset.rb', line 95 def execute ptr = C.hb_subset_plan_execute_or_fail(@ptr) raise SubsetError, "Subset plan execution failed" if ptr.null? HarfBuzz::Face.wrap_owned(ptr) end |
#inspect ⇒ Object
120 121 122 |
# File 'lib/harfbuzz/subset.rb', line 120 def inspect "#<HarfBuzz::Subset::Plan>" end |
#new_to_old_glyph_mapping ⇒ HarfBuzz::Map
Returns the new→old glyph ID mapping (borrowed)
110 111 112 |
# File 'lib/harfbuzz/subset.rb', line 110 def new_to_old_glyph_mapping HarfBuzz::Map.wrap_borrowed(C.hb_subset_plan_new_to_old_glyph_mapping(@ptr)) end |
#old_to_new_glyph_mapping ⇒ HarfBuzz::Map
Returns the old→new glyph ID mapping (borrowed)
104 105 106 |
# File 'lib/harfbuzz/subset.rb', line 104 def old_to_new_glyph_mapping HarfBuzz::Map.wrap_borrowed(C.hb_subset_plan_old_to_new_glyph_mapping(@ptr)) end |
#unicode_to_old_glyph_mapping ⇒ HarfBuzz::Map
Returns the unicode→old glyph ID mapping (borrowed)
116 117 118 |
# File 'lib/harfbuzz/subset.rb', line 116 def unicode_to_old_glyph_mapping HarfBuzz::Map.wrap_borrowed(C.hb_subset_plan_unicode_to_old_glyph_mapping(@ptr)) end |