Comments (7)
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.
Patches are welcome for this feature but they need to be well tested and come with examples.
from prawn.
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.
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.
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.
Since I've rewritten text and written formatted text, it would be most straightforward for me to take this on.
from prawn.
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)
- No way to give dynamic-height bounding boxes a background color HOT 1
- Incompatibility with ruby 3.1 HOT 1
- "Cursor" with repeater dynamic not working HOT 3
- Error in the manual? (page 11) HOT 2
- Issue with image colors when converting to PDF HOT 1
- Question about re-using some Prawn code to render appearance streams for AcroForm annotations HOT 2
- Push New Version to Ruby Gems to Deal with Ruby 3.1 Removing Matrix HOT 6
- Setting multi page table top margin
- Does this gem support chartjs?
- PDF/A-1
- PDF/A-3
- Rails 7.X ActionView::Base.full_sanitizer.sanitize(Prawn::Text::NBSP) returns " " HOT 1
- [FR] OpenType Support, Enable/Disable Ligatures and Multiple weight settings HOT 8
- Subtable with colspan and multi-line text breaks across pages
- Grid broken if no gutter defined HOT 5
- TypeError: can't convert nil into Float HOT 1
- The Return of the Embedded Font Issue HOT 15
- Font error with 2.5 and Adobe Acrobat HOT 4
- Circular require warning in prawn 2.5.0
- Question / Feature Request: Is it possible to layout text into a fixed number of rows?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prawn.