Skip to content

Commit 6e1719e

Browse files
committed
docs(text-shaping): add new text shaping feature info to docs
1 parent 218d97b commit 6e1719e

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A powerful Python library for creating complex visual compositions and beautiful
1515

1616
- **Component-Based Layout**: Compose complex visuals by nesting powerful layout primitives like `Row`, `Column`, and `Image`.
1717
- **Rich Styling**: Gradients, multiple shadows, borders with rounded corners, and text decorations.
18-
- **Advanced Typography**: Custom fonts, variable fonts, line height, and alignment.
18+
- **Advanced Typography**: Custom fonts, variable fonts, line height, alignment, and text shaping with kerning and ligatures.
1919
- **Automatic Font Fallback**: Seamlessly render emojis and multilingual text.
2020
- **Flexible Output**:
2121
- **Raster**: Save as PNG/JPEG/WebP, or convert to NumPy/Pillow.

docs/text.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,70 @@ canvas.render("Variable Font").save("variable_font.png")
8888

8989
`FontWeight` can be an enum member (e.g., `FontWeight.BOLD`) or an integer from 100 to 900.
9090

91+
## Text Shaping
92+
93+
`PicTex` includes advanced text shaping capabilities that improve text rendering quality through kerning, ligatures, and complex script support. This feature is automatically enabled and works behind the scenes to provide professional typography.
94+
95+
### Kerning
96+
97+
Kerning automatically adjusts the spacing between specific character pairs for better visual balance. For example, characters like "AV", "TY", or "Wo" will have optimized spacing.
98+
99+
### Ligatures
100+
101+
When using fonts that support ligatures, character sequences are automatically replaced with single, specially designed glyphs for improved readability.
102+
103+
```python
104+
from pictex import Canvas, NamedColor
105+
106+
(
107+
Canvas()
108+
.font_family("FiraCode-Medium.ttf")
109+
.font_size(100)
110+
.background_color(NamedColor.BEIGE)
111+
.color(NamedColor.BLUE)
112+
.render("-> != <= ==")
113+
.save("ligature.png")
114+
)
115+
```
116+
117+
![Ligature result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1759127040/docs-ligature_rwlxmg.png)
118+
119+
### Complex Script Support
120+
121+
Text shaping properly handles complex scripts like Arabic, where characters need to connect and change forms based on their position.
122+
123+
```python
124+
from pictex import Canvas, NamedColor
125+
126+
(
127+
Canvas()
128+
.font_size(100)
129+
.background_color(NamedColor.BEIGE)
130+
.color(NamedColor.DARKGREEN)
131+
.render("كتاب")
132+
.save("docs-arabic.png")
133+
)
134+
```
135+
136+
![Script support result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1759127040/docs-arabic_yffazq.png)
137+
138+
### Complex Emoji Sequences
139+
140+
Multi-part emoji sequences (like 👩‍🔬) are rendered as single glyphs instead of separate emoji characters.
141+
142+
```python
143+
from pictex import Canvas
144+
145+
(
146+
Canvas()
147+
.font_size(100)
148+
.render("👩‍🔬 🏳️‍🌈")
149+
.save("docs-emoji.png")
150+
)
151+
```
152+
153+
![Emoji sequences result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1759127041/docs-emoji_ekahio.png)
154+
91155
## Multi-line Text and Alignment
92156

93157
`PicTex` fully supports multi-line text using newline characters (`\n`). Additionally, text can automatically wrap when placed in containers with fixed widths.

0 commit comments

Comments
 (0)