Class: HarfBuzz::Subset::Plan

Inherits:
Object
  • Object
show all
Defined in:
lib/harfbuzz/subset.rb

Overview

Wraps hb_subset_plan_t — a more fine-grained subsetting plan

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(face, input) ⇒ Plan

Creates a subset plan for a face using the given input

Parameters:

Raises:



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

#ptrObject (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

#executeHarfBuzz::Face

Executes the plan and returns the subsetted face

Returns:

Raises:



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

#inspectObject



120
121
122
# File 'lib/harfbuzz/subset.rb', line 120

def inspect
  "#<HarfBuzz::Subset::Plan>"
end

#new_to_old_glyph_mappingHarfBuzz::Map

Returns the new→old glyph ID mapping (borrowed)

Returns:



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_mappingHarfBuzz::Map

Returns the old→new glyph ID mapping (borrowed)

Returns:



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_mappingHarfBuzz::Map

Returns the unicode→old glyph ID mapping (borrowed)

Returns:



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