Class: Fontisan::Ufo::Image

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

Overview

A background image anchored to a glyph (common in color fonts).

In UFO 3, images live in UFO/images/ as binary blobs (PNG in practice). Each image is referenced from a glyph's GLIF via <image fileName="..."/>. The image set stores the actual bytes and deduplicates by sha256 content hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name:, transformation: nil, color: nil, sha: nil, bytes: nil) ⇒ Image

Returns a new instance of Image.

Parameters:

  • file_name (String)

    filename within the UFO images/ directory

  • transformation (Hash, nil) (defaults to: nil)

    UFO image transformation matrix

  • color (String, nil) (defaults to: nil)

    optional color hint

  • sha (String, nil) (defaults to: nil)

    content sha256 hex digest

  • bytes (String, nil) (defaults to: nil)

    raw image bytes (set by ImageSet)



19
20
21
22
23
24
25
26
# File 'lib/fontisan/ufo/image.rb', line 19

def initialize(file_name:, transformation: nil, color: nil, sha: nil,
               bytes: nil)
  @file_name = file_name.to_s
  @transformation = transformation
  @color = color
  @sha = sha
  @bytes = bytes
end

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes.



12
13
14
# File 'lib/fontisan/ufo/image.rb', line 12

def bytes
  @bytes
end

#colorObject (readonly)

Returns the value of attribute color.



12
13
14
# File 'lib/fontisan/ufo/image.rb', line 12

def color
  @color
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



12
13
14
# File 'lib/fontisan/ufo/image.rb', line 12

def file_name
  @file_name
end

#shaObject (readonly)

Returns the value of attribute sha.



12
13
14
# File 'lib/fontisan/ufo/image.rb', line 12

def sha
  @sha
end

#transformationObject (readonly)

Returns the value of attribute transformation.



12
13
14
# File 'lib/fontisan/ufo/image.rb', line 12

def transformation
  @transformation
end