class TTFunk::Table::Glyf::PathBased

TrueType-compatible representation of a CFF glyph.

Attributes

horizontal_metrics[R]

Glyph horizontal metrics. @return [TTFunk::Table::Hmtx::HorizontalMetric]

left_side_bearing[R]

Left side bearing. @return [Integer, Float]

path[R]

Glyph outline. @return [TTFunk::Table::Cff::Path]

right_side_bearing[R]

Rigth side bearing. @return [Integer, Float]

x_max[R]

Maximum X. @return [Integer, Float]

x_min[R]

Minimum X. @return [Integer, Float]

y_max[R]

Maximum Y. @return [Integer, Float]

y_min[R]

Minimum Y. @return [Integer, Float]

Public Class Methods

new(path, horizontal_metrics) click to toggle source

@param path [TTFunk::Table::Cff::Path] @param horizontal_metrics [TTFunk::Table::Hmtx::HorizontalMetric]

# File lib/ttfunk/table/glyf/path_based.rb, line 42
def initialize(path, horizontal_metrics)
  @path = path
  @horizontal_metrics = horizontal_metrics

  @x_min = 0
  @y_min = 0
  @x_max = horizontal_metrics.advance_width
  @y_max = 0

  path.commands.each do |command|
    cmd, x, y = command
    next if cmd == :close

    @x_min = x if x < @x_min
    @x_max = x if x > @x_max
    @y_min = y if y < @y_min
    @y_max = y if y > @y_max
  end

  @left_side_bearing = horizontal_metrics.left_side_bearing
  @right_side_bearing =
    horizontal_metrics.advance_width -
    @left_side_bearing -
    (@x_max - @x_min)
end

Public Instance Methods

compound?() click to toggle source

Is this glyph compound?

@return [false]

# File lib/ttfunk/table/glyf/path_based.rb, line 78
def compound?
  false
end
number_of_contours() click to toggle source

Number of contour.

@return [Integer]

# File lib/ttfunk/table/glyf/path_based.rb, line 71
def number_of_contours
  path.number_of_contours
end