Class: HarfBuzz::Variation
- Inherits:
-
Object
- Object
- HarfBuzz::Variation
- Defined in:
- lib/harfbuzz/variation.rb
Overview
Represents an OpenType variation axis value (e.g., "wght=700")
Class Method Summary collapse
-
.from_string(str) ⇒ Variation
Parses a variation string such as "wght=700" or "ital=1".
Instance Method Summary collapse
-
#initialize(struct) ⇒ Variation
constructor
A new instance of Variation.
- #inspect ⇒ Object
-
#tag ⇒ Integer
Variation axis tag as uint32.
-
#to_s ⇒ String
Variation string representation.
-
#to_struct ⇒ C::HbVariationT
Returns the FFI struct for passing to C functions.
-
#value ⇒ Float
Variation axis value.
Constructor Details
#initialize(struct) ⇒ Variation
Returns a new instance of Variation.
6 7 8 |
# File 'lib/harfbuzz/variation.rb', line 6 def initialize(struct) @struct = struct end |
Class Method Details
.from_string(str) ⇒ Variation
Parses a variation string such as "wght=700" or "ital=1"
24 25 26 27 28 29 30 |
# File 'lib/harfbuzz/variation.rb', line 24 def self.from_string(str) struct = C::HbVariationT.new result = C.hb_variation_from_string(str, str.bytesize, struct) raise VariationParseError, "Invalid variation string: #{str.inspect}" if result.zero? new(struct) end |
Instance Method Details
#inspect ⇒ Object
45 46 47 |
# File 'lib/harfbuzz/variation.rb', line 45 def inspect "#<HarfBuzz::Variation #{to_s}>" end |
#tag ⇒ Integer
Returns Variation axis tag as uint32.
11 12 13 |
# File 'lib/harfbuzz/variation.rb', line 11 def tag @struct[:tag] end |
#to_s ⇒ String
Returns Variation string representation.
39 40 41 42 43 |
# File 'lib/harfbuzz/variation.rb', line 39 def to_s buf = FFI::MemoryPointer.new(:char, 64) C.hb_variation_to_string(@struct, buf, 64) buf.read_string end |
#to_struct ⇒ C::HbVariationT
Returns the FFI struct for passing to C functions
34 35 36 |
# File 'lib/harfbuzz/variation.rb', line 34 def to_struct @struct end |
#value ⇒ Float
Returns Variation axis value.
16 17 18 |
# File 'lib/harfbuzz/variation.rb', line 16 def value @struct[:value] end |