Class: Fontisan::Models::Ucd::UcdChar

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

Overview

Single element from the UCDXML flat file.

UCDXML uses two forms:

<char cp="0041" name="..." script="Latin" block="Basic Latin" .../>
<char first-cp="3400" last-cp="4DBF" name="..." script="Han" .../>

The first form describes one codepoint. The second form describes a closed range of codepoints that share the same properties (used for CJK ideograph ranges where each codepoint would otherwise need its own entry).

Both forms can appear in the same document; cp is mutually exclusive with first-cp/last-cp.

Instance Method Summary collapse

Instance Method Details

#codepointsObject

The codepoints covered by this entry, as Integers. For a single-codepoint entry, returns a one-element array. For a range entry, returns the inclusive range as an array (caller should treat this lazily if the range is huge — CJK ranges can have tens of thousands of codepoints).



55
56
57
58
59
60
61
62
63
# File 'lib/fontisan/models/ucd/ucd_char.rb', line 55

def codepoints
  if range?
    (first_cp.to_i(16)..last_cp.to_i(16)).to_a
  elsif cp
    [cp.to_i(16)]
  else
    []
  end
end

#range?Boolean

True if this entry describes a codepoint range rather than a single codepoint.

Returns:

  • (Boolean)


46
47
48
# File 'lib/fontisan/models/ucd/ucd_char.rb', line 46

def range?
  !first_cp.nil? && !last_cp.nil?
end