Module: Harfbuzz

Extended by:
FFI::Library
Defined in:
lib/harfbuzz.rb,
lib/harfbuzz/base.rb,
lib/harfbuzz/blob.rb,
lib/harfbuzz/face.rb,
lib/harfbuzz/font.rb,
lib/harfbuzz/buffer.rb,
lib/harfbuzz/shaping.rb,
lib/harfbuzz/version.rb

Defined Under Namespace

Classes: Base, Blob, Buffer, Face, Feature, Font, FontExtents, GlyphExtents, GlyphInfo, GlyphPosition

Constant Summary collapse

MinimumHarfbuzzVersion =
[1, 0, 4]

Class Method Summary collapse

Class Method Details

.features_from_strings(feature_strings) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# 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) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# 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

.shapersObject



42
43
44
# File 'lib/harfbuzz/shaping.rb', line 42

def self.shapers
  Harfbuzz.hb_shape_list_shapers.read_array_of_strings
end

.versionObject



11
12
13
14
15
16
17
18
19
20
21
# 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) ⇒ Object



23
24
25
# File 'lib/harfbuzz/version.rb', line 23

def self.version_at_least(major, minor, micro)
  Harfbuzz.hb_version_atleast(major, minor, micro)
end

.version_stringObject



7
8
9
# File 'lib/harfbuzz/version.rb', line 7

def self.version_string
  hb_version_string
end