module Harfbuzz

Constants

MinimumHarfbuzzVersion

Public Class Methods

features_from_strings(feature_strings) click to toggle source
# File lib/harfbuzz/shaping.rb, line 58
def self.features_from_strings(feature_strings)
  features_len = feature_strings ? feature_strings.length : 0
  if features_len > 0
    features_ptr = FFI::MemoryPointer.new(Feature, features_len)
    feature_strings.each_with_index do |feature_string, i|
      feature_string_ptr = FFI::MemoryPointer.new(:char, feature_string.bytesize)
      feature_string_ptr.put_bytes(0, feature_string)
      feature_ptr = Feature.new(features_ptr + (i * Feature.size))
      hb_feature_from_string(feature_string_ptr, feature_string.bytesize, feature_ptr) \
        or raise "Can't get feature from string: #{feature_string.inspect}"
    end
  else
    features_ptr = nil
  end
  [features_ptr, features_len]
end
shape(font, buffer, features=nil, shapers=nil) click to toggle source
# File lib/harfbuzz/shaping.rb, line 46
def self.shape(font, buffer, features=nil, shapers=nil)
  features_ptr, features_len = features_from_strings(features)
  shapers_ptr = shapers ? FFI::MemoryPointer.from_array_of_strings(shapers) : nil
  Harfbuzz.hb_shape_full(
    font.hb_font,
    buffer.hb_buffer,
    features_ptr,
    features_len,
    shapers_ptr,
  )
end
shapers() click to toggle source
# File lib/harfbuzz/shaping.rb, line 42
def self.shapers
  Harfbuzz.hb_shape_list_shapers.read_array_of_strings
end
version() click to toggle source
# File lib/harfbuzz/version.rb, line 11
def self.version
  major_ptr = FFI::MemoryPointer.new(:uint, 1)
  minor_ptr = FFI::MemoryPointer.new(:uint, 1)
  micro_ptr = FFI::MemoryPointer.new(:uint, 1)
  hb_version(major_ptr, minor_ptr, micro_ptr)
  [
    major_ptr.read_uint,
    minor_ptr.read_uint,
    micro_ptr.read_uint,
  ]
end
version_at_least(major, minor, micro) click to toggle source
# File lib/harfbuzz/version.rb, line 23
def self.version_at_least(major, minor, micro)
  Harfbuzz.hb_version_atleast(major, minor, micro)
end
version_string() click to toggle source
# File lib/harfbuzz/version.rb, line 7
def self.version_string
  hb_version_string
end