Class: HexaPDF::Font::InvalidGlyph

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/font/invalid_glyph.rb

Overview

Represents an invalid glyph, i.e. a Unicode character that has no representation in the used font.

Constant Summary collapse

CONTROL_CHARS =

Set of codepoints for text control characters, like tabulator, line separators, non-breaking space etc.

Set.new([9, 10, 11, 12, 13, 133, 8232, 8233, 8203, 173, 160])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font_wrapper, str) ⇒ InvalidGlyph

Creates a new Glyph object.



53
54
55
56
# File 'lib/hexapdf/font/invalid_glyph.rb', line 53

def initialize(font_wrapper, str)
  @font_wrapper = font_wrapper
  @str = str
end

Instance Attribute Details

#font_wrapperObject (readonly)

The associated font wrapper object, either a Type1Wrapper or a TrueTypeWrapper.



47
48
49
# File 'lib/hexapdf/font/invalid_glyph.rb', line 47

def font_wrapper
  @font_wrapper
end

#strObject (readonly)

The string that could not be represented as a glyph.



50
51
52
# File 'lib/hexapdf/font/invalid_glyph.rb', line 50

def str
  @str
end

Instance Method Details

#apply_word_spacing?Boolean

Word spacing is never applied for the invalid glyph, so false is returned.

Returns:

  • (Boolean)


74
75
76
# File 'lib/hexapdf/font/invalid_glyph.rb', line 74

def apply_word_spacing?
  false
end

#control_char?Boolean

Returns true if this glyph represents a control character like tabulator or newline.

Returns:

  • (Boolean)


88
89
90
# File 'lib/hexapdf/font/invalid_glyph.rb', line 88

def control_char?
  CONTROL_CHARS.include?(str.ord)
end

#idObject Also known as: name

Returns the appropriate missing glyph id based on the used font.



59
60
61
# File 'lib/hexapdf/font/invalid_glyph.rb', line 59

def id
  @font_wrapper.wrapped_font.missing_glyph_id
end

#inspectObject

:nodoc:



93
94
95
# File 'lib/hexapdf/font/invalid_glyph.rb', line 93

def inspect
  "#<#{self.class.name} font=#{@font_wrapper.wrapped_font.full_name.inspect} id=#{id} #{@str.inspect}>"
end

#valid?Boolean

Returns false since this is an invalid glyph.

Returns:

  • (Boolean)


79
80
81
# File 'lib/hexapdf/font/invalid_glyph.rb', line 79

def valid?
  false
end

#x_minObject Also known as: x_max, y_min, y_max, width

Returns 0.



65
66
67
# File 'lib/hexapdf/font/invalid_glyph.rb', line 65

def x_min
  0
end