Class: HexaPDF::Font::InvalidGlyph
- Inherits:
-
Object
- Object
- HexaPDF::Font::InvalidGlyph
- 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
-
#font_wrapper ⇒ Object
readonly
The associated font wrapper object, either a Type1Wrapper or a TrueTypeWrapper.
-
#str ⇒ Object
readonly
The string that could not be represented as a glyph.
Instance Method Summary collapse
-
#apply_word_spacing? ⇒ Boolean
Word spacing is never applied for the invalid glyph, so
falseis returned. -
#control_char? ⇒ Boolean
Returns
trueif this glyph represents a control character like tabulator or newline. -
#id ⇒ Object
(also: #name)
Returns the appropriate missing glyph id based on the used font.
-
#initialize(font_wrapper, str) ⇒ InvalidGlyph
constructor
Creates a new Glyph object.
-
#inspect ⇒ Object
:nodoc:.
-
#valid? ⇒ Boolean
Returns
falsesince this is an invalid glyph. -
#x_min ⇒ Object
(also: #x_max, #y_min, #y_max, #width)
Returns 0.
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_wrapper ⇒ Object (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 |
#str ⇒ Object (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.
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.
88 89 90 |
# File 'lib/hexapdf/font/invalid_glyph.rb', line 88 def control_char? CONTROL_CHARS.include?(str.ord) end |
#id ⇒ Object 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 |
#inspect ⇒ Object
: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.
79 80 81 |
# File 'lib/hexapdf/font/invalid_glyph.rb', line 79 def valid? false end |
#x_min ⇒ Object 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 |