sile icon indicating copy to clipboard operation
sile copied to clipboard

How do I horizontally squish content?

Open ctrlcctrlv opened this issue 3 years ago • 13 comments

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.

ctrlcctrlv avatar Jun 21 '21 11:06 ctrlcctrlv

Here's an illustration.

What I have

image

What I want

image

ctrlcctrlv avatar Jun 21 '21 11:06 ctrlcctrlv

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.

simoncozens avatar Jun 21 '21 11:06 simoncozens

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 avatar Jun 21 '21 11:06 alerque

@alerque I'm getting somewhere.

image i need fire

ctrlcctrlv avatar Jun 23 '21 07:06 ctrlcctrlv

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 avatar Jun 23 '21 08:06 ctrlcctrlv

@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 avatar Sep 03 '22 13:09 Omikhleia

@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).

ctrlcctrlv avatar Sep 03 '22 14:09 ctrlcctrlv

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).

image

Even writing this horizontally, in a well-made (i.e. professionally typeset) grid-based book, you will squish the NPO.

ctrlcctrlv avatar Sep 03 '22 14:09 ctrlcctrlv

I mean sure my Japanese language documents are a bit strange, they have to be as they're about esoteric internet topics lol

image

ctrlcctrlv avatar Sep 03 '22 14:09 ctrlcctrlv

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).

Omikhleia avatar Sep 03 '22 14:09 Omikhleia

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.

ctrlcctrlv avatar Sep 03 '22 14:09 ctrlcctrlv

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.

Omikhleia avatar Sep 03 '22 15:09 Omikhleia

I agree, at least the low level functionality here should be provided in core for any packages to use in normal or creative ways.

alerque avatar Sep 03 '22 22:09 alerque