Skip to content

Support for letter-spacing #10

Open

Description

@maxhoffmann

Thank you for creating dropflow! It looks really cool. 🙂

I was wondering if you are also planning to add letter-spacing at some point? It’s the one essential typographic feature I’m currently missing.

Activity

  1. chearon commented on Mar 22, 2024

    @chearon
    Owner

    Thank you! I'd love to add letter-spacing support. I think it's simple: walk the glyph array and increase advances at the end of each unicode grapheme:

    This property specifies additional spacing (commonly called tracking) between adjacent typographic character units. Letter-spacing is applied after bidi reordering and is in addition to kerning and word-spacing. [CSS-WRITING-MODES-4] [CSS-FONTS-3] Depending on the justification rules in effect, user agents may further increase or decrease the space between typographic character units in order to justify text.

    For the purpose of letter-spacing, each consecutive run of atomic inlines (such as images and inline blocks) is treated as a single typographic character unit.

    Letter-spacing must not be applied at the beginning of a line. Whether letter-spacing is applied at the end of a line is undefined in this level.

    — CSS Text §7.2

  2. chearon commented on Mar 23, 2024

    @chearon
    Owner

    I did more reading and thinking on this. It's harder than I thought because the spacing has to be applied after bidi reordering. But letter-spacing also needs to be followed when measuring text for fit. If bidi text splits an inline, the common ancestor's letter-spacing is used. It sounds like I'm supposed to do a simple test of "will this split an inline", rather than trying to calculate the "hypothetical" bidi order.

    Currently, none of the major browsers do this correctly: test.

    LineWidthTracker, ShapedItem.measure, and createLineboxes all need to be updated to have letter spacing state. Those use logical order, but the total number of spaces will be the same as the after-bidi letter spacing. Also ShapedShim will need to gain an advance property since inline-blocks and <img> in the future also get spaces after them through letter-spacing.

  3. added a commit that references this issue on Mar 26, 2024
  4. chearon commented on Mar 13, 2025

    @chearon
    Owner

    Further reading: w3c/csswg-drafts#10193

  5. BobPritchett commented on Jul 1, 2025

    @BobPritchett

    FWIW, it sounds like 'continuing with browser implementations' has won, with possible flags for the future alternate implementation. So just adding to the advance width, like most browsers, would be useful and meet expectations.

  6. chearon commented on Jul 4, 2025

    @chearon
    Owner

    It's too bad there's been no movement on w3c/csswg-drafts#10193. Going with current browser behavior is fine, as long as the advance goes on the left side for RTL text, the way Firefox does. Some of the proposals in that issue sound way better than what browsers are doing, but it's probably best to wait until that gets resolved.

    I'd still like to get the BIDI test to work in dropflow even though browsers don't do that either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions