sile
sile copied to clipboard
How do I horizontally squish content?
Let's say I want to take a letter and make it 0.5 of its width—how?
I'd find this useful for Ruby. It's often done in Japan.
Here's an illustration.
What I have
What I want
I don't think there's a way of doing this easily. You would have to manually set a PDF transformation matrix for the text. The pdf module might help with this.
I don't think we have something like this. Yet. We should.
We have \rebox
which can be used to forcefully change the overall size of an output box, but it doesn't change the contents, just the edges of the bounding box.
We also have a tracking adjustment that can e used to squish text together (and thus offend typ designer sensibilities), but that doesn't change the proportions of glyphs.
The only workaround I can think of right now would be a two stage thing where you generated a PDF graphic and used an image editor to squash it, then embed the resultant PDF as an image back in another document. Obviously not a very satisfactory process even if the result comes out.
A more permanent way to handle this would be some sort of hook from the output module that did the transformation. I can't image there being a representation we could keep internally though so the transform would probably have to have a matching \rebox
so that the document layout continues to be sensible.
@alerque I'm getting somewhere.
It doesn't work how you're saying. It works how @simoncozens said.
Here's raw PDF syntax for one of the squished Ruby lines:
q 1 0 0 1 406.8 94.4 cm .6667 0 0 1 0 0 cm 1 0 0 1 -406.8 -94.4 cm BT /F2 6 Tf 406.8 -94.4 Td[<05e205dd05ca>]TJ ET Q BT /F1 12
I don't know what SILE's story is with output to other formats, but this'll only work for PDF and PostScript.
@ctrlcctrlv If I understand correctly the initial question, you wanted to "re-scale" some content by some ratio. As @simoncozens suggested, using a PDF transformation matrix is a possible solution, though it would currently only work with the libtexpdf backend.
If this is indeed the question, then I actually did it there for scaling sub/super scripts to some horizontal and vertical ratios - It would be possible to extract that bit of code e.g. in a separate more general package: probably, too, an external package rather than in the core distribution? Then I can help with it if need be, let me know. But ideally, in the end, we should be able to close this issue, it's all doable.
@Omikhleia Please do. I really have wanted to fix SILE's 縦書き for a long time, and fixing ruby
package is a big part of that, and this is a requirement for proper Ruby (and 縦 in general).
To be honest we cannot support CJK even horizontal without this feature.
I figured that out while working on my paper called 【洋風 及び 和風】キャップ・トリップそして、それらの種類・歴史・算出方式・算法 一覧 for which I required pLaTeX, because so many CJK norms just aren't possible in SILE.
Consider the word NPO法人 (hōjin).
Even writing this horizontally, in a well-made (i.e. professionally typeset) grid-based book, you will squish the NPO.
I mean sure my Japanese language documents are a bit strange, they have to be as they're about esoteric internet topics lol
Hmm, but ruby is a standard SILE-distributed package. Should the extracted code be proposed as a 3rd party package ("scalebox" or whatever) or be submitted as a PR? Or just baked into the ruby package? Did you have that meta-discussion on what is expected as PR and what is not? 'Cause I am not sure where I am heading, these days^^ (sincerely said).
I will open one with my initial thoughts now that I've had some time to think of it.
Basically I think \scalebox
is a core feature because it is required to write a major world language, and all features needed for that are per se core features that should be packaged with SILE.
Go ahead, feel free to pick code/ideas from the code I linked above, and don't hesitate to ping me. If you make it such as I could remove it from textsubsuper.sile and use a then standard scalebox command, it will be even cleaner.
I agree, at least the low level functionality here should be provided in core for any packages to use in normal or creative ways.