Class: Fontisan::Ufo::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/ufo/point.rb

Overview

A single outline point. UFO's point element has:

- x, y          (Float, font units)
- type          (one of "move", "line", "offcurve", "curve", "qcurve")
- smooth        (Bool, optional)

"offcurve" is the UFO 1/2 name; UFO 3 uses "qcurve". Both are accepted on read.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, type:, smooth: false) ⇒ Point

Returns a new instance of Point.



16
17
18
19
20
21
# File 'lib/fontisan/ufo/point.rb', line 16

def initialize(x:, y:, type:, smooth: false)
  @x = x
  @y = y
  @type = type.to_s
  @smooth = smooth
end

Instance Attribute Details

#smoothObject (readonly)

Returns the value of attribute smooth.



14
15
16
# File 'lib/fontisan/ufo/point.rb', line 14

def smooth
  @smooth
end

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/fontisan/ufo/point.rb', line 14

def type
  @type
end

#xObject

Returns the value of attribute x.



13
14
15
# File 'lib/fontisan/ufo/point.rb', line 13

def x
  @x
end

#yObject

Returns the value of attribute y.



13
14
15
# File 'lib/fontisan/ufo/point.rb', line 13

def y
  @y
end

Instance Method Details

#off_curve?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/fontisan/ufo/point.rb', line 27

def off_curve?
  @type == "offcurve" || @type == "qcurve"
end

#on_curve?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fontisan/ufo/point.rb', line 23

def on_curve?
  @type == "line" || @type == "move" || @type == "curve"
end