Class: Ucode::Models::Audit::EmbeddingType

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/ucode/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



36
37
38
39
40
41
42
43
# File 'lib/ucode/models/audit/embedding_type.rb', line 36

def self.decode(fs_type)
  return nil if fs_type.nil?
  return "installable" if fs_type.zero?

  matched = PERMISSION_BITS.find { |mask, _| (fs_type & mask).nonzero? }
  label = matched ? matched.last : "unknown"
  label == "installable" ? installable_subcategory(fs_type) : label
end

.from_fs_type(fs_type) ⇒ Object

Construct from a decoded canonical string.

Parameters:

  • fs_type (Integer, nil)


58
59
60
# File 'lib/ucode/models/audit/embedding_type.rb', line 58

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

Instance Method Details

#to_sObject



62
63
64
# File 'lib/ucode/models/audit/embedding_type.rb', line 62

def to_s
  value
end