Post without Account — your post will be reviewed, and if appropriate, posted under Anonymous. You can also use this link to report any problems registering or logging in.

How to write perpendicular Japanese text?

  • 5 Replies
  • 386 Views
*

Offline stueber

  • Newbie
  • *
  • 5
    • View Profile
    • biolib
How to write perpendicular Japanese text?
« February 05, 2021, 04:23:22 PM »
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



*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 795
    • View Profile
Re: How to write perpendicular Japanese text?
« Reply #1: February 07, 2021, 12:03:23 PM »
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.

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 795
    • View Profile
Re: How to write perpendicular Japanese text?
« Reply #2: February 07, 2021, 01:22:27 PM »
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.

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 795
    • View Profile
Re: How to write perpendicular Japanese text?
« Reply #3: February 14, 2021, 11:49:42 AM »
Have you had any luck trying out PDF::Builder with HarfBuzz::Shaper to do your vertical text Japanese?

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 795
    • View Profile
Re: How to write perpendicular Japanese text?
« Reply #4: March 27, 2021, 09:59:49 PM »
With no response from the OP, I'll assume that HarfBuzz::Shaper does the job. If not, this ticket can be reopened.

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 795
    • View Profile
Re: How to write perpendicular Japanese text?
« Reply #5: April 12, 2021, 07:25:19 PM »
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!