Class: Ucode::Models::Audit::GaspRange

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

Overview

One entry from the TrueType ‘gasp` (Grid-fitting And Scan-conversion Procedure) table.

Each entry describes the hinting/smoothing policy that applies up to the given ‘max_ppem` (pixels-per-em). The OpenType spec defines four single-bit flags; the high 12 bits of the raw rangeFlags uint16 are reserved.

Construct via GaspRange.from_flags from the raw uint16 pair; never hand-build the bit decoding at call sites.

Constant Summary collapse

GRIDFIT =

OpenType gasp rangeFlags bit masks.

0x0001
DO_GRAY =
0x0002
SYMMETRIC_GRIDFIT =
0x0004
SYMMETRIC_SMOOTHING =
0x0008

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_flags(max_ppem, flags) ⇒ GaspRange

Build a GaspRange from the raw uint16 pair stored in the gasp table.

Parameters:

  • max_ppem (Integer)

    rangeMaxPPEM (exclusive upper bound)

  • flags (Integer)

    raw rangeFlags bitfield

Returns:



44
45
46
47
48
49
50
51
52
# File 'lib/ucode/models/audit/gasp_range.rb', line 44

def self.from_flags(max_ppem, flags)
  new(
    max_ppem: max_ppem,
    gridfit: (flags & GRIDFIT).positive?,
    do_gray: (flags & DO_GRAY).positive?,
    symmetric_gridfit: (flags & SYMMETRIC_GRIDFIT).positive?,
    symmetric_smoothing: (flags & SYMMETRIC_SMOOTHING).positive?,
  )
end

Instance Method Details

#gridfit_and_smoothing?Boolean

Derived: both gridfit and do_gray are set. Mac historically treated this combination as “do everything”. Not serialized — compute on demand.

Returns:

  • (Boolean)


57
58
59
# File 'lib/ucode/models/audit/gasp_range.rb', line 57

def gridfit_and_smoothing?
  gridfit && do_gray
end