Class: Prawn::SVG::Elements::TextPath
- Inherits:
-
TextComponent
- Object
- Base
- DirectRenderBase
- TextComponent
- Prawn::SVG::Elements::TextPath
- Defined in:
- lib/prawn/svg/elements/text_path.rb
Constant Summary
Constants inherited from Base
Base::COMMA_WSP_REGEXP, Base::MissingAttributesError, Base::PAINT_TYPES, Base::SVG_NAMESPACE, Base::SkipElementError, Base::SkipElementQuietly
Constants included from Attributes::Stroke
Attributes::Stroke::CAP_STYLE_TRANSLATIONS, Attributes::Stroke::JOIN_STYLE_TRANSLATIONS
Instance Attribute Summary
Attributes inherited from TextComponent
#children, #dx, #dy, #fallback_fonts, #font, #inside_clip_path, #length_adjust, #parent_component, #rotation, #text_length, #x_values, #y_values
Attributes inherited from Base
#attributes, #base_calls, #calls, #document, #parent_calls, #properties, #source, #state
Instance Method Summary collapse
- #parse ⇒ Object
- #render_component(prawn, renderer, _cursor, _translate_x = nil, accumulated_baseline_shift = 0) ⇒ Object
- #transformable? ⇒ Boolean
Methods inherited from TextComponent
#calculated_width, #current_length_adjust_is_scaling?, #initialize, #kerning_enabled?, #kerning_pixels, #lay_out, #letter_spacing_pixels, #word_spacing_pixels
Methods inherited from DirectRenderBase
Methods inherited from Base
#initialize, #name, #parse_and_apply, #process
Methods included from TransformParser
Methods included from PDFMatrix
#load_matrix, #matrix_for_pdf, #rotation_matrix, #scale_matrix, #translation_matrix
Methods included from Attributes::Space
Methods included from Attributes::Stroke
#parse_stroke_attributes_and_call
Methods included from Attributes::Mask
#parse_mask_attribute_and_call
Methods included from Attributes::ClipPath
#parse_clip_path_attribute_and_call
Methods included from Attributes::Opacity
#parse_opacity_attributes_and_call
Methods included from Attributes::Transform
#parse_transform_attribute_and_call
Constructor Details
This class inherits a constructor from Prawn::SVG::Elements::TextComponent
Instance Method Details
#parse ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/prawn/svg/elements/text_path.rb', line 3 def parse href = href_attribute unless href&.start_with?('#') warnings << '<textPath> must reference a path element' raise SkipElementQuietly end @path_element = document.elements_by_id[href[1..]] unless @path_element.is_a?(Elements::Path) warnings << "<textPath> reference '#{href}' is not a path element" raise SkipElementQuietly end @path_length = Calculators::PathLength.new(@path_element.commands) raise SkipElementQuietly if @path_length.total_length <= 0 @start_offset = parse_start_offset super end |
#render_component(prawn, renderer, _cursor, _translate_x = nil, accumulated_baseline_shift = 0) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/prawn/svg/elements/text_path.rb', line 25 def render_component(prawn, renderer, _cursor, _translate_x = nil, accumulated_baseline_shift = 0) raise SkipElementQuietly if computed_properties.display == 'none' add_yield_call do size = computed_properties.numeric_font_size y_offset = dominant_baseline_offset(prawn, size || prawn.font_size) || 0 with_svg_fonts(prawn) do total_baseline_shift = accumulated_baseline_shift + baseline_shift_offset(prawn, size) y_offset += total_baseline_shift current_distance = @start_offset render_children_along_path(prawn, children, size, y_offset, current_distance) end end renderer.render_calls(prawn, base_calls) end |
#transformable? ⇒ Boolean
44 45 46 |
# File 'lib/prawn/svg/elements/text_path.rb', line 44 def transformable? false end |