Skip to content

Commit 9e1f65c

Browse files
committed
Fix: Harden HarfBuzz shaping
1 parent 4f7d759 commit 9e1f65c

65 files changed

Lines changed: 6294 additions & 5542 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
222222
<tr><td><code>fontStyle</code></td><td>Supported</td><td></td></tr>
223223
<tr><td><code>fontFeatureSettings</code></td><td>Supported via HarfBuzz text shaping. Enables OpenType features like ligatures, small caps, stylistic sets, etc.</td><td></td></tr>
224224

225-
<tr><td rowspan="14">Text</td></tr>
225+
<tr><td rowspan="13">Text</td></tr>
226226
<tr><td><code>tabSize</code></td><td>Supported</td><td></td></tr>
227-
<tr><td><code>direction</code></td><td><code>ltr</code>, <code>rtl</code>, defaults to <code>ltr</code>. Used for RTL languages like Arabic and Hebrew.</td><td></td></tr>
228227
<tr><td><code>textAlign</code></td><td><code>start</code>, <code>end</code>, <code>left</code>, <code>right</code>, <code>center</code>, <code>justify</code>, default to <code>start</code></td><td></td></tr>
229228
<tr><td><code>textIndent</code></td><td>Supported, including negative values (hanging indent)</td><td></td></tr>
230229
<tr><td><code>textTransform</code></td><td><code>none</code>, <code>lowercase</code>, <code>uppercase</code>, <code>capitalize</code>, defaults to <code>none</code></td><td></td></tr>
@@ -363,17 +362,9 @@ Example:
363362
</div>
364363
```
365364

366-
**RTL (Right-to-Left) Languages**: Satori now supports RTL languages like Arabic and Hebrew! Use the `direction` CSS property to enable RTL text rendering:
367-
368-
```jsx
369-
<div style={{ direction: 'rtl' }}>
370-
مرحبا بالعالم
371-
</div>
372-
373-
<div style={{ direction: 'rtl' }}>
374-
שלום עולם
375-
</div>
376-
```
365+
HarfBuzz also improves glyph shaping for complex scripts such as Arabic. Full
366+
Unicode bidirectional layout is not yet supported, so mixed LTR and RTL text
367+
may not follow browser ordering.
377368

378369
#### Fonts
379370

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"css-to-react-native": "^3.0.0",
133133
"emoji-regex-xs": "^2.0.1",
134134
"escape-html": "^1.0.3",
135-
"harfbuzzjs": "^0.10.0",
135+
"harfbuzzjs": "0.10.0",
136136
"linebreak": "^1.1.0",
137137
"parse-css-color": "^0.2.1",
138138
"postcss-value-parser": "^4.2.0",
@@ -141,11 +141,5 @@
141141
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
142142
"engines": {
143143
"node": ">=16"
144-
},
145-
"pnpm": {
146-
"patchedDependencies": {
147-
"yoga-layout@3.2.1": "patches/yoga-layout@3.2.1.patch",
148-
"harfbuzzjs@0.10.0": "patches/harfbuzzjs@0.10.0.patch"
149-
}
150144
}
151145
}

patches/harfbuzzjs@0.10.0.patch

Lines changed: 3 additions & 41 deletions
Large diffs are not rendered by default.

playground/cards/playground-data.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -313,60 +313,6 @@ const playgroundTabs: Tabs = {
313313
</div>
314314
)
315315
}
316-
`,
317-
'Advanced Shaping': `// Complex text shaping examples that require HarfBuzz.
318-
// Without proper shaping, these scripts would render incorrectly.
319-
320-
() => {
321-
function Label({ children }) {
322-
return <label style={{
323-
fontSize: 14,
324-
fontWeight: 600,
325-
textTransform: 'uppercase',
326-
letterSpacing: 1,
327-
margin: '20px 0 8px',
328-
color: '#666',
329-
}}>
330-
{children}
331-
</label>
332-
}
333-
334-
return (
335-
<div
336-
style={{
337-
display: 'flex',
338-
flexDirection: 'column',
339-
height: '100%',
340-
width: '100%',
341-
padding: '10px 25px',
342-
fontFamily: 'Inter',
343-
fontSize: 26,
344-
backgroundColor: 'white',
345-
}}
346-
>
347-
<Label>Arabic (RTL + Ligatures)</Label>
348-
<div style={{ direction: 'rtl' }}>
349-
السلام عليكم — لا إله إلا الله
350-
</div>
351-
<Label>Devanagari (Hindi conjuncts)</Label>
352-
<div>
353-
नमस्ते — हिन्दी — क्ष त्र ज्ञ श्री
354-
</div>
355-
<Label>Thai (complex clusters)</Label>
356-
<div>
357-
สวัสดี — ภาษาไทย — กรุงเทพฯ
358-
</div>
359-
<Label>Tamil</Label>
360-
<div>
361-
வணக்கம் — தமிழ் — ஸ்ரீ
362-
</div>
363-
<Label>Mixed RTL/LTR</Label>
364-
<div style={{ direction: 'rtl' }}>
365-
مرحبا Hello مع World السلام
366-
</div>
367-
</div>
368-
)
369-
}
370316
`,
371317
}
372318

0 commit comments

Comments
 (0)