| Ticket UUID: | 4eef1fa86e61ce5f6fbfce23d90a6e422b2719b4 | |||
| Title: | 9.1b1 X11 (HarfBuzz/SheenBidi font backend): strings longer than 512 characters are truncated when drawn, and glyphs beyond 16-bit coordinates wrap around | |||
| Type: | Bug | Version: | 9.1b1 | |
| Submitter: | serhiy.storchaka | Created on: | 2026-09-22 09:29:01 | |
| Subsystem: | 46. Unix Fonts | Assigned To: | aku | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-13 11:30:59 | |
| Resolution: | Fixed | Closed By: | kevin_walzer | |
| Closed on: | 2026-10-13 11:30:59 | |||
| Description: |
The glyph drawing loops in tkUnixBidiFont.c collect glyphs in a fixed array of MAX_GLYPHS (512) XftGlyphFontSpec and stop when it is full, so anything drawn with more than 512 characters in one call is cut off. A canvas text item with 600 characters shows only the first 512:
canvas .c -width 300 -height 60 -scrollregion {0 0 20000 60}
pack .c
.c create text 0 20 -anchor w -text [string repeat M 600] -font {Courier 12}
.c xview moveto 0.3
The loops also store the positions in the 16-bit x and y fields of XftGlyphFontSpec without a check, so glyphs beyond ±32767 pixels wrap around instead of being skipped, as the Xft backend does since [bce3c9222f] (8.6.9). This is what makes the old [770578] (a very long canvas text item disappears when scrolled) fail again on 9.1: only the first 512 characters were drawn at all. The text and entry widgets are not affected, they draw in shorter ranges. The shaper for complex scripts (ShapedGlyphBuffer and the run lists) has fixed 512-glyph buffers as well, so a single complex-script string longer than that is still truncated by the shaping; that is not addressed here. | |||
| User Comments: |
kevin_walzer added on 2026-10-13 11:30:59:
Fix merged to trunk. Thank you. serhiy.storchaka added on 2026-09-29 11:38:46: Thanks for testing! Checking the shaper, I found that strings of 1024 or more bytes shaped by HarfBuzz even crash the application, see [965dae4a6d]. The 512-glyph limit of the shaper is removed in branch x11-shaper-unlimited (based on x11-bidi-long-text, which now also includes the fix for [965dae4a6d]). Now font measure {sans-serif 10} [string repeat \u4e2d 600] returns 8400, as in 9.0, and long RTL text is drawn completely. Test unixfont-10.2. anonymous added on 2026-09-29 09:10:31: Tested branch x11-bidi-long-text (1e3ca6c160) on Linux/X11: a 600-character
Latin label and a 600-character "-wrap none" text line now draw completely;
on 9.1.0rc1 both were blank after glyph 512. Thanks.
One case the branch does not cover: text that IsSimpleOnly() sends through
HarfBuzz (RTL scripts, CJK, ...) is still cut at 512 glyphs, because the
shaping buffer itself is capped (X11Shaper_ShapeString: "glyphCount <
MAX_GLYPHS", and the MAX_GLYPHS-sized glyphs[]/visualIndex[] arrays in
the buffer). Even the measurement is affected:
font measure {sans-serif 10} [string repeat \u4e2d 600]
font measure {sans-serif 10} [string repeat \u4e2d 512]
both return 7168 on the branch (and 9.0.4 returns 8400 for the first). The
same happens with Hebrew (\u05d0): 4608 for both lengths.
Jan ([email protected])
serhiy.storchaka added on 2026-09-22 09:35:39: Fixed in [4c1e52f0d9] (branch x11-bidi-long-text): the glyphs are drawn in batches of 512 (AddGlyph()/FlushGlyphs()) in all four drawing loops, and glyphs outside the 16-bit range are skipped. Tests canvText-22.1 (item of 1000 characters) and canvText-22.2 (the item of [770578] scrolled by up to 100000 pixels). The 512-glyph limit of the shaper for complex scripts remains. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki