### Home Classes Methods

### In Files

- lib/rvg/misc.rb

### Parent

Magick::RVG::Utility::TextStrategy

### Methods

- #get_letter_spacing
- #get_word_spacing
- #render

### Files

- MANIFEST
- Makefile

### Class/Module Index

Quicksearch

- Magick
- Magick::DestroyedImageError
- Magick::Draw
- Magick::Enum
- Magick::FatalImageMagickError
- Magick::Geometry
- Magick::GeometryValue
- Magick::GradientFill
- Magick::HatchFill
- Magick::IPTC
- Magick::IPTC::Application
- Magick::IPTC::Envelope
- Magick::IPTC::ObjectData
- Magick::IPTC::Post_ObjectData_Descriptor
- Magick::IPTC::Pre_ObjectData_Descriptor
- Magick::Image
- Magick::Image::DrawOptions
- Magick::Image::Info
- Magick::Image::PolaroidOptions
- Magick::Image::View
- Magick::Image::View::Pixels
- Magick::Image::View::Rows
- Magick::ImageList
- Magick::ImageList::Montage
- Magick::ImageMagickError
- Magick::OptionalMethodArguments
- Magick::Pixel
- Magick::RVG
- Magick::RVG::Circle
- Magick::RVG::ClipPath
- Magick::RVG::Describable
- Magick::RVG::Duplicatable
- Magick::RVG::Ellipse
- Magick::RVG::Embellishable
- Magick::RVG::Group
- Magick::RVG::Image
- Magick::RVG::ImageConstructors
- Magick::RVG::Line
- Magick::RVG::Path
- Magick::RVG::PathData
- Magick::RVG::Pattern
- Magick::RVG::PolyShape
- Magick::RVG::Polygon
- Magick::RVG::Polyline
- Magick::RVG::PreserveAspectRatio
- Magick::RVG::Rect
- Magick::RVG::ShapeConstructors
- Magick::RVG::Stretchable
- Magick::RVG::StructureConstructors
- Magick::RVG::Stylable
- Magick::RVG::Text
- Magick::RVG::TextBase
- Magick::RVG::TextConstructors
- Magick::RVG::Transformable
- Magick::RVG::Use
- Magick::RVG::UseConstructors
- Magick::RVG::Utility
- Magick::RVG::Utility::DefaultTextStrategy
- Magick::RVG::Utility::GraphicContext
- Magick::RVG::Utility::LRTextStrategy
- Magick::RVG::Utility::RLTextStrategy
- Magick::RVG::Utility::TBTextStrategy
- Magick::RVG::Utility::TextAttributes
- Magick::RVG::Utility::TextStrategy
- Magick::TextureFill
- Object

No matching classes.

# Magick::RVG::Utility::LRTextStrategy

### Public Instance Methods

get_letter_spacing(glyph) click to toggle source

    # File lib/rvg/misc.rb, line 184
    def get_letter_spacing(glyph)
        gx, gy = glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, glyph)
        [gx+@ctx.text_attrs.letter_spacing, gy]
    end

get_word_spacing() click to toggle source

    # File lib/rvg/misc.rb, line 179
    def get_word_spacing()
        @word_space ||= glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, ' ')[0]
        [@word_space + @ctx.text_attrs.word_spacing, 0]
    end

render(x, y, text) click to toggle source

    # File lib/rvg/misc.rb, line 189
    def render(x, y, text)
        x_rel_coords, y_rel_coords = text_rel_coords(text)
        dx = x_rel_coords.inject(0) {|sum, a| sum + a}
        dy = y_rel_coords.max

        # We're handling the anchoring.
        @ctx.gc.push()
        @ctx.gc.text_anchor(Magick::StartAnchor)
        if @ctx.text_attrs.text_anchor == :end
            x -= dx
        elsif @ctx.text_attrs.text_anchor == :middle
            x -= dx / 2
        end

        # Align the first glyph
        case @ctx.text_attrs.glyph_orientation_horizontal
            when 0
                ;
            when 90
                y -= dy
            when 180
                x += x_rel_coords.shift
                x_rel_coords << 0
                y -= dy
            when 270
                x += x_rel_coords[0]
        end

        y += shift_baseline(@ctx.text_attrs.glyph_orientation_horizontal, text[0,1])

        first_word = true
        text.split(::Magick::RVG::WORD_SEP).each do |word|
            unless first_word
                x += x_rel_coords.shift
            end
            first_word = false
            word.split('').each do |glyph|
                render_glyph(@ctx.text_attrs.glyph_orientation_horizontal, x, y, glyph)
                x += x_rel_coords.shift
            end
        end

        @ctx.gc.pop()
        [dx, 0]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.