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.



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

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.



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

def smooth
  @smooth
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

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)


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

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

#on_curve?Boolean

Returns:

  • (Boolean)


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

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

#to_hHash

Returns suitable for to_glif output.

Returns:

  • (Hash)

    suitable for to_glif output



31
32
33
34
35
# File 'lib/fontisan/ufo/point.rb', line 31

def to_h
  h = { x: @x, y: @y, type: @type }
  h[:smooth] = true if @smooth
  h
end