Git Product home page Git Product logo

Comments (7)

henrik avatar henrik commented on July 22, 2024

I noticed prawn-format has some support for this. You can add something like

if options[:letter_spacing]
  state[:text].character_space(options[:letter_spacing])
end

to Line#draw_on and then do something like

text "foo", :letter_spacing => 123

, but this messes up line wrapping and likely a bunch of other things.

Maybe someone can build on it, though.

from prawn.

practicingruby avatar practicingruby commented on July 22, 2024

Patches are welcome for this feature but they need to be well tested and come with examples.

from prawn.

henrik avatar henrik commented on July 22, 2024

If it helps someone else, I ended up faking it (in Rails, hence the chars) like this:

require "prawn/format"
my_string = "some text\nsome more"
spaced_string = my_string.lines.map {|line| line.chars.split('').join('<space></space>') }.join('<br/>')
text spaced_string, :tags => { :space => { :width => '1' } }  # fake letter-spacing

from prawn.

semarco avatar semarco commented on July 22, 2024

Hi, thank you, I have something like the following in my rails/lib now

class Prawn::Document
  def text_spaced text, options = {}
  
    spaced_string = text.lines.map {|line| line.chars.split('').join('') }.join('
') text spaced_string, {:tags => { :space => { :width => (options[:letter_spacing] || 1).to_s } }}.merge(options) # fake letter-spacing end end

cheers. Marco

from prawn.

practicingruby avatar practicingruby commented on July 22, 2024

Please don't post prawn-format related examples here until prawn-format is maintained. They are only relevant to Prawn <= 0.6.x

from prawn.

Bluejade avatar Bluejade commented on July 22, 2024

Since I've rewritten text and written formatted text, it would be most straightforward for me to take this on.

from prawn.

Bluejade avatar Bluejade commented on July 22, 2024

Pushed to master
http://github.com/sandal/prawn/commit/3d15b75f4d70cc3ee89414854c11942b7c11a42c
http://github.com/sandal/prawn/commit/68513ef76fad352ae362bc00c2578ea5bbd5f269
http://github.com/sandal/prawn/commit/a5a8603d8fa226671f9b9bfda74b5e9cbc2db7a0
http://github.com/sandal/prawn/commit/8b8232c808dd27e7184d6785c06d46b6bf83f455

from prawn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.