Class: Fontisan::Models::Audit::EmbeddingType

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/audit/embedding_type.rb

Overview

Decoded OS/2 fsType bitfield → canonical embedding-permission string.

Per OpenType spec, fsType is a bitfield. Only one of bits 0-3 should be set (the basic permission level); bits 4-7 are modifiers that only apply when INSTALLABLE (bit 3) is set.

The decoder normalizes to one of seven canonical strings so downstream consumers don't need to know the bit layout.

Constant Summary collapse

RESTRICTED_LICENSE_NO_EMBEDDING =

Bit masks (OpenType fsType bitfield).

0x0001
PREVIEW_AND_PRINT =
0x0002
EDITABLE_EMBEDDING =
0x0004
INSTALLABLE_EMBEDDING =
0x0008
NO_SUBSETTING =
0x0100
BITMAP_EMBEDDING_ONLY =
0x0200

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decode(fs_type) ⇒ String?

Decoded canonical string for the given fsType bitfield.

Parameters:

  • fs_type (Integer, nil)

    raw OS/2 fsType value

Returns:

  • (String, nil)

    canonical permission name, or nil when fs_type is nil



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fontisan/models/audit/embedding_type.rb', line 32

def self.decode(fs_type)
  return nil if fs_type.nil?

  if fs_type & RESTRICTED_LICENSE_NO_EMBEDDING != 0
    "restricted_license"
  elsif fs_type & PREVIEW_AND_PRINT != 0
    "preview_print"
  elsif fs_type & EDITABLE_EMBEDDING != 0
    "editable"
  elsif fs_type & INSTALLABLE_EMBEDDING != 0
    installable_subcategory(fs_type)
  elsif fs_type.zero?
    "installable"
  else
    "unknown"
  end
end

.from_fs_type(fs_type) ⇒ Object

Construct from a decoded canonical string.

Parameters:

  • fs_type (Integer, nil)


53
54
55
# File 'lib/fontisan/models/audit/embedding_type.rb', line 53

def self.from_fs_type(fs_type)
  new(value: decode(fs_type))
end

Instance Method Details

#to_sObject



57
58
59
# File 'lib/fontisan/models/audit/embedding_type.rb', line 57

def to_s
  value
end