← Back to all sparks
T

textshaping

ANALYTICS
Velocity0.0

Bindings to the HarfBuzz library for Text Shaping. Contribute to r-lib/textshaping development by creating an account on GitHub.

Rewrote its shaping engine for bidirectional text, then spent a year fixing what that broke.

typographytext-shapingbidigraphics-stackr-package
Current state
textshaping is the text layout layer beneath R's modern graphics stack, feeding ragg, ggplot2 and marquee. Version 1.0.0 rewrote the shaping engine to honour the global direction of text, adding a direction argument that defaults to automatic detection, align settings that resolve against that direction, and ICU-based soft break locations that handle ideographic scripts properly. The five releases since have been consecutive bug fixes against that rewrite — bidi embedding arrangement, line positioning with mixed sizes, a weak hash in the shape cache, a signed integer overflow, and font fallback regressions.
Where it's heading
The package has moved from Latin-first layout to script-agnostic layout in two rewrites, 0.4.0 and 1.0.0, and is now in the long correctness tail that follows. The bug reports arriving from ggplot2, ragg and marquee issue numbers show how it works in practice: textshaping bugs surface as rendering defects in the packages above it, which is why so many fixes here cite another package's issue tracker.
Prediction
Expect continued fixes driven by downstream rendering reports rather than new layout features, as the 1.0.x series stabilises. The font fallback path has produced two of the recent bugs and is the most likely source of the next.

Recent moves

  1. 5mo ago

    Fixes reverting between font fallbacks

    A single fix in the fallback chain when reverting from one fallback font to the previous one. The fallback path introduced in the 0.4.0 rewrite continues to be where the residual bugs live.

    View source ↗
  2. 9mo ago

    Guards against freetype version mismatches with systemfonts

    Defensive handling for incompatible freetype versions between textshaping and systemfonts, a failure mode users would otherwise hit as an unexplained crash. Purely protective, with no change to shaping behaviour.

    View source ↗
  3. 11mo ago

    Fixes a signed integer overflow in the previous fix

    A follow-up to the shape cache hash fix shipped one day earlier. Notable mainly as evidence of how tightly this package is coupled to ragg's rendering behaviour.

    View source ↗
  4. 11mo ago

    Fixes bidi single-line shaping and a weak shape-cache hash

    Three real defects from the 1.0.0 rewrite: bidi embedding arrangement on single lines, a weak vector hash causing shape cache collisions, and line positioning when a line mixes text sizes. All three arrived as bug reports from ggplot2 and ragg, which is how layout defects usually reach this package.

    View source ↗
  5. 1y ago

    Fixes hard line breaks across multiple embeddings

    Hard line breaks were ignored when a line consisted of multiple embeddings, and newline characters were inflating line width enough to insert spurious empty lines. Both were reported through marquee, the rich-text package that sits directly on top of this one.

    View source ↗
  6. 1y ago

    Shaping engine rewritten to honour global text direction

    ⚡ SPARK

    The release that changes what the R graphics stack can typeset: direction-aware shaping, direction-resolving alignment, and ICU-based break locations for ideographic scripts. Every release since has been correctness work on this engine, which is the usual shape of a layout rewrite landing in production.

    View source ↗