Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typography: Add option for vertical text (writing-mode/text-orientation) #50319

Open
jasmussen opened this issue May 4, 2023 · 10 comments · May be fixed by #60030
Open

Typography: Add option for vertical text (writing-mode/text-orientation) #50319

jasmussen opened this issue May 4, 2023 · 10 comments · May be fixed by #60030
Assignees
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Typography Font and typography-related issues and PRs Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@jasmussen
Copy link
Contributor

jasmussen commented May 4, 2023

Through a combination of text-orientation: mixed; and writing-mode: vertical-rl;, you can achieve vertical text. This is useful for some writing forms. Shown here, a 12th century Japanese scroll:

Image

Beyond enabling vertically written languages, the orientation can also have decorative properties:

Image

We should consider adding support via the Typography panel. An initial version could be a single directional toggle, similar to that of Layout blocks:

Image

This should be fairly simple to implement, as it's a matter of adding writing-mode to paragraphs:

writing-mode: vertical-rl;

Note that the rl part would have to be derived from the general writing direction (LTR needs vertical-rl, RTL needs vertical-lr).

See also: https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode

Depending on the utility, the feature could theoretically be expanded in the future with glyph orientation (text-orientation). But I want to emphasize the following mockup would be a future followup, and the design control and iconography could use feedback:

Vertical text, slightly longer term version with more options

The above would require the addition of text-orientation: upright; (where text-orientation: mixed; is otherwise a good adaptive default).

See also: https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation

@jasmussen jasmussen added Needs Design Feedback Needs general design feedback. [Feature] Typography Font and typography-related issues and PRs labels May 4, 2023
@jasmussen
Copy link
Contributor Author

CC: @WordPress/gutenberg-design for awareness.

@mtias mtias added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label May 4, 2023
@beafialho
Copy link

Thank you for bringing this up @jasmussen! I love this and was wondering if we could extend this to Post Navigation links so we'd be able to achieve something like this:

tile

@jasmussen
Copy link
Contributor Author

I love this and was wondering if we could extend this to Post Navigation links so we'd be able to achieve something like this:

Nice!

Given navigation links have the Typography panel, I would expect this control also to be available there:

Screenshot 2023-05-08 at 15 33 58

@jasmussen jasmussen added Needs Dev Ready for, and needs developer efforts and removed Needs Design Feedback Needs general design feedback. labels May 8, 2023
@carolinan carolinan self-assigned this May 21, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label May 22, 2023
@carolinan
Copy link
Contributor

@jasmussen Could I get a sanity check on this:

Note that the rl part would have to be derived from the general writing direction (LTR needs vertical-rl, RTL needs vertical-lr).

On LTR, the text is now displayed right to left:
a paragraph of vertical text

@jasmussen
Copy link
Contributor Author

Yep, it's a bit of an exotic case when you'll ever see this, and I think it's related to when the paragraph container has a fixed width, which might happen in flex containers. I updated this codepen to make it clearer:

screenshot of the various behaviors

In that codepen I also added the text-flipping CSS that might pair well with the alignment dropdown as we mused on here.

@ramonjd
Copy link
Member

ramonjd commented Aug 3, 2023

There's an older issue that raises similar questions:

The intention in that issue was to start with a locale-first approach.

Back then I experimented both with adding writing mode to individual blocks, e.g., Paragraphs, and to containing blocks, e.g., Groups

The reason behind looking at containing blocks was because text-orientation changes the block flow direction and requires the use of margin-block-start and other logical properties to control typographical layout.

See https://drafts.csswg.org/css-writing-modes/#block-flow, and the related discussion points here:

Even the examples on MDN apply these rules to the containing block: https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation

Refer also to this comment and the cited Japanese example.

The drive to add writing mode + text orientation was the reason I added CSS logical properties to the layout implementation:

I know there's been some exploratory work going on over in #53175 but I suspect it might be worth starting from a i18n perspective first, that is, to support displaying vertical text flow to support languages that use it.

After that I think the ground work would be there to offer augmented "design first" options that can rotate text of any language according to design rather than locale. This is what #20926 proposed.

@carolinan
Copy link
Contributor

carolinan commented Aug 3, 2023

Please note that the writing mode block support is already in Gutenberg, "starting from" is not an option anymore.

Please help me understand if what you are suggesting technically, means that the current support is removed, or that it is simply applied to container blocks and text blocks differently.

It would be possible to have a new support under "layout", but part of the CSS would be very similar, we should try to re-use it instead of duplicating.

@carolinan
Copy link
Contributor

We also have to consider very carefully where in the UI it should go, there is also a language menu option in the RichText toolbar that has a text-orientation option that lets us choose between ltr and rtl.

@ramonjd
Copy link
Member

ramonjd commented Aug 3, 2023

Please note that the writing mode block support is already in Gutenberg, "starting from" is not an option anymore.

I get that, and I don't see any issue with the current implementation of writing mode. Sorry for the confusion!

It looks like the current implementation of writing-mode is pretty agnostic, that is, we could apply it to a group block if we wanted to have writing-modes on containers (unless I'm mistaken).

This issue specifically mentions text-orientation. My comments were directed at the relationship between writing-mode (in Gutenberg) and text-orientation and the effect, when both are applied, they have on writing flow. I'm thinking of multiple paragraphs that flow vertically in a logical order.

Please help me understand if what you are suggesting technically, means that the current support is removed, or that it is simply applied to container blocks and text blocks differently.

No, not suggesting we remove anything 😄 And definitely don't want to block progress on this issue. I'm very happy you've picked it up again, thanks.

The way I understand it, we have writing mode, and we want to now add some sort of text orientation control, is that right?

My only argument is this: we should taken into account how such features act on document and block flow not just design. For example, with the new tools, could a user build something like this?

Screenshot 2023-08-03 at 1 03 56 pm

If so, then great.

It would be possible to have a new support under "layout", but part of the CSS would be very similar, we should try to re-use it instead of duplicating.

I think targeting typography, like you've done, is perfectly logical.

@burnuser
Copy link

Feature not available in Gutenberg 16.7.0 RC 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Typography Font and typography-related issues and PRs Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
Status: Needs dev
8 participants