Class: Ucode::Glyphs::EmbeddedFonts::TraceGlyph
- Inherits:
-
Struct
- Object
- Struct
- Ucode::Glyphs::EmbeddedFonts::TraceGlyph
- Defined in:
- lib/ucode/glyphs/embedded_fonts/trace_glyph.rb
Overview
Value object for one glyph emitted by mutool trace.
Each <g> element in the trace XML maps to one TraceGlyph:
The font_name is inherited from the enclosing <span>:
Instance Attribute Summary collapse
-
#font_name ⇒ Object
Returns the value of attribute font_name.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#unicode ⇒ Object
Returns the value of attribute unicode.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
-
.name_match?(a, b) ⇒ Boolean
True when
aandbresolve to the same normalized name. -
.normalize_name(name) ⇒ String?
The name truncated to the trace limit.
Instance Attribute Details
#font_name ⇒ Object
Returns the value of attribute font_name
27 28 29 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 27 def font_name @font_name end |
#gid ⇒ Object
Returns the value of attribute gid
27 28 29 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 27 def gid @gid end |
#unicode ⇒ Object
Returns the value of attribute unicode
27 28 29 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 27 def unicode @unicode end |
#x ⇒ Object
Returns the value of attribute x
27 28 29 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 27 def x @x end |
#y ⇒ Object
Returns the value of attribute y
27 28 29 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 27 def y @y end |
Class Method Details
.name_match?(a, b) ⇒ Boolean
True when a and b resolve to the same normalized
name. Treats nil as never matching (avoids accidental
collision on missing names).
52 53 54 55 56 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 52 def name_match?(a, b) return false if a.nil? || b.nil? normalize_name(a) == normalize_name(b) end |
.normalize_name(name) ⇒ String?
Returns the name truncated to the trace limit.
39 40 41 42 43 |
# File 'lib/ucode/glyphs/embedded_fonts/trace_glyph.rb', line 39 def normalize_name(name) return nil if name.nil? name.length <= TRACE_NAME_LIMIT ? name : name[0, TRACE_NAME_LIMIT] end |