-
Notifications
You must be signed in to change notification settings - Fork 5
Fixing responsive text tooling #12
Comments
Scott, as web layout isn’t the field I’m most familiar with, I don’t immediately know how to follow up on this proposal. But you’ll be welcome to brief the attendees on this proposal at the upcoming Meeting 4. |
Thank you @lianghai. I’ll admit, I am more interested in the text aspects of this group than the font aspects of this group. Not that I don’t care about fonts, I care a lot about different ways to typeset with them! So much room for improvement in these areas. As layout is getting a lot of love (with grid and flexbox) and fonts are getting a lot of attention (variable fonts etc) text needs a lot of attention to catch up to both layout and font tech in my opinion. |
No need to “admit” anything. The whole point of setting up this CG is to encourage industry-wide communication and cooperation.
“Text”, as a major subject in this industry, has a very broad spectrum of meanings. Better to clarify what exactly you refer to, when pitching other participants. Prematurely dividing concepts into “font”, “text”, and “layout” isn’t quite helpful. My initial impression of your proposal is that it’s about some interaction between block layout and inline font formatting—or is it? |
Glossary of what terms mean to me:
This proposal is about the effects layout has on typesetting and text. To reiterate above with the glossary here, layout and fonts have seen tons of improvement over the past few years but typesetting and text tooling hasn’t evolved to keep pace with layout and font tech. CSS lacks the adequate tools to take advantage of things like variable fonts or respond have text respond to layout changes introduced by things like flexbox and grid. This proposal is to explore ways text styles can respond to layout changes and take full advantage of new font features. |
I (personally) see this particular CG as operating at a (much) lower-level than block level layout, for which the CSS WG might be a better home. But this is why we have a triage process. |
Responsive typography inevitably links lower-level word and line layout with higher level text block and device frame layout, where changes in the latter can and should produce adjustments in the former. So I think understanding how that happens, and ensuring predictable and interoperable behaviour—taking into account that this will make use of font data—is within scope. For example, the recent leading-trim property proposal relies on font data—and assumes this data is correct—to improve text block alignment, and announcement of the proposal included mention of the possibility of defining new font data to enable leading-trim to work for additional, non-European scripts. So that is a case where a desire to do something that has affect at the text block layout level not only depends on data at the lower, font level, but may make unwise assumptions about existing data and overlook prior ideas for new data—e.g. BASE table v2 ideas around script- and language-specific vertical metrics—that have taken place in closed discussions. |
Thanks @tiroj, Yes the leading-trim proposal was one that peeked my interest in joining this group. Something that might concern more people here is that variable fonts still lack some basic and expected interpolation control in CSS. There is currently no way to interpolate an axis as the browser scales (without JavaScript). The behavior people expect from variable fonts on the web doesn’t exist. |
So it turns out that I have a lot to say about this. The reason I haven't said very much is that I was supposed to be giving a talk about all this at a conference but it's got cancelled due to COVID! The first thing is that responsive layout obviously interacts very strongly with variable fonts but also goes beyond variable fonts. For example, prior to variable fonts, there was a facility in OpenType (the JSTF table) which expected to be able to stretch and shrink certain glyphs as well as make certain substitutions based on the needs of the layout table. But it was never implemented, and I think there are several reasons for that. One is that (prior to variable fonts) the mechanism for stretching and shrinking glyphs was never defined. But more fundamentally, there is no mechanism within the layout pipeline for information to flow from layout engine to shaper. (There's a similar story behind the So this is why John's discussion in #24 of post-linebreaking substitution is, in my opinion, misguided. In a sense it is the Hz-Program strategy: break the lines according to the normal principles, then "deform" the glyphs to reduce the line-breaking badness. But to achieve optimum line breaks in the first place - for DJR's Fit to ever reflow - you will need to take advantage of the variability of glyphs in the same way that best-fit line breaking algorithms already take advantage of the variability of spaces. So you need to have that "conversation" with the shaper before line breaking happens. Now with advent of variable fonts there are a number of things that a line-breaking algorithm can do to determine the best fit: stretching and shrinking spaces as normal, but also stretching and shrinking glyphs (using variable font axes), and even substituting alternate glyphs as suggested in JSTF. (Go play with that example, I'll wait.) In some cases it will have to combine elements of each - Arabic is a great example where ideally you want a balance between contextual alternates as a priority, then stretching spaces (a little bit), then kashida stretching. In other words, layout engines - and we're talking web layout engines in particular - need to be majorly rewritten in order to support variable font justification really well. This is because right now layout engines assume that text is static and spaces are variable. To work with variable fonts, they will need to see space as variable and text as both variable and substitutable. The old "boxes and glue" model doesn't work so well in this world any more. (It's all glue.) This diagram shows the sort of calculations that such a line breaking engine will need to do: (Boxes show the choices available at each stage, and white boxes show the optimum collection of boxes selected by the algorithm to minimise the line breaking badness. There's eight separate permutations it needs to check out, and that's even without thinking about the variability of the glyphs.) When variable fonts came out, I wanted to add support for them to SILE, but I was stopped by two issues - the first was that getting a variable font into PDF requires embedding static instances and I couldn't do that at the time, but the second was this matter of rewriting the line breaking algorithm. I started https://github.com/simoncozens/newbreak as a project to look at how to implement a new line breaking algorithm with variable-width text. I think there's a lot of potential in that algorithm but I need to integrate it into SILE (and of course, into every browser...) to be sure.
In short, I think what you want is worthy but it's asking an awful lot. We're not just talking about exposing some properties to CSS, but we're also talking about fundamentally rewriting the layout engine code in browsers and other applications to support variable text as well as variable spaces. I think we should do it, but as you say, it's a long-term goal. |
InDesign implements |
Notes from the October 19th meeting: We discussed the scope and goals of this initiative. It spans various initiatives and may be better suited for the CSS WG. There is a lot of crossover for other working groups and the layout spec. I don’t expect his group to find a solution to these issues, but instead explore what we need for fonts and text from layout and lobby the CSS WG on those points.
Related APIs and tools:
Other proposals and related issues: |
@simoncozens I wasn’t even thinking about justification as an application for this, but this is super interesting and applicable stuff and I appreciate you sharing this in detail. When talking with typographers the top complaint I hear is that the web doesn’t have great hyphenation/justification/line breaking and that can be expanded on through this as well as other issues. I’m curious if this justification proposal can be achieved at a lower level in the text shaping? As a CSS author I’d love to write something where you can proportionally scale justification settings, maybe like
I also really love how you phrase this. |
The issues with current text styling methods
calc()
from being useful here.Min()
,max()
, andclamp()
still require lots of un-intuitive math to figure out. Figuring out the right mix of fixed length units + viewport units to get the slope of text scaling to be just right can require either lots of guess and check adjustment or writing a formula to have min and max fall at specific points. Also, all this math gets thrown off by users changing their font size.Possible solutions
length
, to allow for a better author experience and finer control.You can find a prototype of the general concepts outlined here: https://codepen.io/scottkellum/pen/OJPPOGK?editors=0100 — note that this proposal goes beyond what is shown here and aims to take advantage of the potential of native CSS as opposed to working with existing paradigms.
IP Disclosure
Typetura (Scott Kellum) has two parents regarding applications on top of this approach US10769348 and US10592087. There is prior art for the approach itself in the form of FlowType.js and Textblock.io along with the Typetura JS engine.
The text was updated successfully, but these errors were encountered: