Closed PhilterPaper closed 3 years ago
Phil Perry replied:
I think textlabel is set up strictly for left-to-right text, and the whole thing can be rotated at some angle. To get vertical text with unrotated characters and proper punctuation will be very difficult. Have you tried HarfBuzz::Shaper support in PDF::Builder? The example for it shows some Chinese text in vertical mode -- no punctuation there, but you should try it anyway to see if it does the job for you. That might be a lot easier than trying to bend textlabel() to handle this.
Phil Perry replied:
Note: be careful choosing your .ttf or .otf CJK font file. Some do not permit embedding the font at all (requiring that the recipient have their own copy); some insist on embedding the entire font file (your PDF gets really huge); and some will permit embedding of a subset. Try to choose one that does the subset, as it will minimize the size of your PDF file.
With no response from the OP, I'll assume that HarfBuzz::Shaper does the job. If not, this ticket can be reopened.
By the way, Kurt, if HarfBuzz::Shaper does the job for you, and you have any nice tricks for using it for vertical mode CJK texts, please feel free to share so I can update and expand the documentation!
Just a note that I finally got around to trying this with CJK text (in Chinese) to see if punctuation was rotated in vertical mode -- it was. I'm not sure if the period is quite right (may be a font issue), but ( and ) certainly are correct. This should be in the next release's examples/HarfBuzz.pl
. Anyway, this should work for your purposes, so I'll keep this ticket closed. Let me know if you experience problems using it.
Vertical writing: see https://www.mail-archive.com/search?l=harfbuzz@lists.freedesktop.org&q=subject:%22%5C%5BHarfBuzz%5C%5D+vertical+text+for+RTL+scripts%5C%3F%22&o=newest&f=1 for some discussion on this (using HarfBuzz).
Kurt steuber wrote:
Dear Phil,
In the textlabel command
($width = $txt->textlabel($x,$y, $font, $size, $text, %opts)
I find an option-rotate => $deg
With this I could rotate my text by 90 degrees. But I would like to format a Japanese text the normal way, this means all characters remain upright but in a perpendicular row (which is normal in Japan :-) ) Placing the characters by single character strings below each other does not work either, since at least the interpunctation marks (brackets, full stop, quotes etc) have to be different in a perpendicular line. For instance brackets are indeed rotated by 90 degrees, full stops are placed in the upper right corner instead etc. I attach an image of a text sample where you can see that the comma is not correctly placed.Greetings Kurt