Module: HarfBuzz::OT::Metrics

Defined in:
lib/harfbuzz/ot/metrics.rb

Overview

OpenType Metrics API

Class Method Summary collapse

Class Method Details

.position(font, tag) ⇒ Integer?

Returns a metric position value (returns nil if not available)

Parameters:

  • font (Font)

    Sized font

  • tag (Integer)

    Metric tag

Returns:

  • (Integer, nil)

    Position or nil



13
14
15
16
17
# File 'lib/harfbuzz/ot/metrics.rb', line 13

def position(font, tag)
  pos_ptr = FFI::MemoryPointer.new(:int32)
  ok = C.hb_ot_metrics_get_position(font.ptr, tag, pos_ptr)
  ok.zero? ? nil : pos_ptr.read_int32
end

.position_with_fallback(font, tag) ⇒ Integer

Returns a metric position with fallback (always returns a value)

Parameters:

  • font (Font)

    Sized font

  • tag (Integer)

    Metric tag

Returns:

  • (Integer)

    Position



23
24
25
26
27
# File 'lib/harfbuzz/ot/metrics.rb', line 23

def position_with_fallback(font, tag)
  pos_ptr = FFI::MemoryPointer.new(:int32)
  C.hb_ot_metrics_get_position_with_fallback(font.ptr, tag, pos_ptr)
  pos_ptr.read_int32
end

.variation(font, tag) ⇒ Float

Returns a metric float variation value

Parameters:

  • font (Font)

    Sized font

  • tag (Integer)

    Metric tag

Returns:

  • (Float)

    Variation value



33
34
35
# File 'lib/harfbuzz/ot/metrics.rb', line 33

def variation(font, tag)
  C.hb_ot_metrics_get_variation(font.ptr, tag)
end

.x_variation(font, tag) ⇒ Integer

Returns the X variation for a metric

Parameters:

  • font (Font)

    Sized font

  • tag (Integer)

    Metric tag

Returns:

  • (Integer)

    X variation



41
42
43
# File 'lib/harfbuzz/ot/metrics.rb', line 41

def x_variation(font, tag)
  C.hb_ot_metrics_get_x_variation(font.ptr, tag)
end

.y_variation(font, tag) ⇒ Integer

Returns the Y variation for a metric

Parameters:

  • font (Font)

    Sized font

  • tag (Integer)

    Metric tag

Returns:

  • (Integer)

    Y variation



49
50
51
# File 'lib/harfbuzz/ot/metrics.rb', line 49

def y_variation(font, tag)
  C.hb_ot_metrics_get_y_variation(font.ptr, tag)
end