Module: HarfBuzz::OT::Math
- Defined in:
- lib/harfbuzz/ot/math.rb
Overview
OpenType Math Typesetting API
Class Method Summary collapse
-
.constant(font, constant) ⇒ Integer
Returns a MATH constant value.
-
.glyph_assembly(font, glyph, dir) ⇒ Hash
Returns math glyph assembly (extensible glyph parts).
-
.glyph_extended_shape?(face, glyph) ⇒ Boolean
True if glyph is an extended shape.
-
.glyph_italics_correction(font, glyph) ⇒ Integer
Italics correction in font units.
-
.glyph_kerning(font, glyph, kern, correction_height) ⇒ Integer
Returns the math kerning value.
-
.glyph_top_accent_attachment(font, glyph) ⇒ Integer
Top accent attachment in font units.
-
.glyph_variants(font, glyph, dir) ⇒ Array<C::HbOtMathGlyphVariantT>
Returns math glyph variants.
-
.has_data?(face) ⇒ Boolean
True if the face has a MATH table.
-
.min_connector_overlap(font, dir) ⇒ Integer
Minimum connector overlap in font units.
Class Method Details
.constant(font, constant) ⇒ Integer
Returns a MATH constant value
19 20 21 |
# File 'lib/harfbuzz/ot/math.rb', line 19 def constant(font, constant) C.hb_ot_math_get_constant(font.ptr, constant) end |
.glyph_assembly(font, glyph, dir) ⇒ Hash
Returns math glyph assembly (extensible glyph parts)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/harfbuzz/ot/math.rb', line 80 def glyph_assembly(font, glyph, dir) count_ptr = FFI::MemoryPointer.new(:uint) count_ptr.write_uint(0) italics_ptr = FFI::MemoryPointer.new(:int32) total = C.hb_ot_math_get_glyph_assembly( font.ptr, glyph, dir, 0, count_ptr, nil, italics_ptr ) parts = if total.zero? [] else parts_ptr = FFI::MemoryPointer.new(C::HbOtMathGlyphPartT, total) count_ptr.write_uint(total) C.hb_ot_math_get_glyph_assembly( font.ptr, glyph, dir, 0, count_ptr, parts_ptr, italics_ptr ) actual = count_ptr.read_uint actual.times.map do |i| C::HbOtMathGlyphPartT.new(parts_ptr + i * C::HbOtMathGlyphPartT.size) end end { parts: parts, italics_correction: italics_ptr.read_int32 } end |
.glyph_extended_shape?(face, glyph) ⇒ Boolean
Returns true if glyph is an extended shape.
40 41 42 |
# File 'lib/harfbuzz/ot/math.rb', line 40 def glyph_extended_shape?(face, glyph) C.from_hb_bool(C.hb_ot_math_is_glyph_extended_shape(face.ptr, glyph)) end |
.glyph_italics_correction(font, glyph) ⇒ Integer
Returns Italics correction in font units.
26 27 28 |
# File 'lib/harfbuzz/ot/math.rb', line 26 def glyph_italics_correction(font, glyph) C.hb_ot_math_get_glyph_italics_correction(font.ptr, glyph) end |
.glyph_kerning(font, glyph, kern, correction_height) ⇒ Integer
Returns the math kerning value
50 51 52 |
# File 'lib/harfbuzz/ot/math.rb', line 50 def glyph_kerning(font, glyph, kern, correction_height) C.hb_ot_math_get_glyph_kerning(font.ptr, glyph, kern, correction_height) end |
.glyph_top_accent_attachment(font, glyph) ⇒ Integer
Returns Top accent attachment in font units.
33 34 35 |
# File 'lib/harfbuzz/ot/math.rb', line 33 def (font, glyph) C.(font.ptr, glyph) end |
.glyph_variants(font, glyph, dir) ⇒ Array<C::HbOtMathGlyphVariantT>
Returns math glyph variants
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/harfbuzz/ot/math.rb', line 59 def glyph_variants(font, glyph, dir) count_ptr = FFI::MemoryPointer.new(:uint) count_ptr.write_uint(0) C.hb_ot_math_get_glyph_variants(font.ptr, glyph, dir, 0, count_ptr, nil) count = count_ptr.read_uint return [] if count.zero? variants_ptr = FFI::MemoryPointer.new(C::HbOtMathGlyphVariantT, count) count_ptr.write_uint(count) C.hb_ot_math_get_glyph_variants(font.ptr, glyph, dir, 0, count_ptr, variants_ptr) actual = count_ptr.read_uint actual.times.map do |i| C::HbOtMathGlyphVariantT.new(variants_ptr + i * C::HbOtMathGlyphVariantT.size) end end |
.has_data?(face) ⇒ Boolean
Returns true if the face has a MATH table.
11 12 13 |
# File 'lib/harfbuzz/ot/math.rb', line 11 def has_data?(face) C.from_hb_bool(C.hb_ot_math_has_data(face.ptr)) end |
.min_connector_overlap(font, dir) ⇒ Integer
Returns Minimum connector overlap in font units.
106 107 108 |
# File 'lib/harfbuzz/ot/math.rb', line 106 def min_connector_overlap(font, dir) C.hb_ot_math_get_min_connector_overlap(font.ptr, dir) end |