Title: JustyKhatt: A Script-Agnostic DOM-Level Line Justification Engine
Hello everyone,
I have developed a JavaScript library called JustyKhatt, which performs line justification at the DOM layer (in the browser) by leveraging OpenType and Variable Font capabilities.
While my initial focus has been on the Arabic script, the architecture is intentionally script-agnostic. The codebase separates the generic processing Core from independent Rule Packs. The Core handles measurement, tagging, and rendering, while Rule Packs (e.g., Naskh, Nastaliq) contain the specific calligraphic logic and decision-making for each script.
The architecture documentation (ARCHITECTURE.md) and the full source code are available here:
https://github.com/AzizMohseny/FFB/tree/main/justykhatt
You can test the behavior of the engine with your own text in the live sandbox here:
[لینک ورسل خود را اینجا بگذارید، مثلاً https://justykhatt.vercel.app]
I would be very grateful if fellow type designers and engineers could test this tool and share their technical feedback. I do not have the financial means to compensate you for your valuable time, but I am more than willing to reciprocate by offering my time, advice, or expertise on your own projects whenever you might need it.
Thank you,
Disclaimer: AI tools were used to assist with the translation and editing of this post.
Comments
-
Safari 26:

0 -
I tried this in the Chrome and Zen (FireFox fork) browsers, and it didn’t work in either of them.0
-

Thank you for the screenshots and for testing it. I really appreciate your help.I noticed something in the console: the browser is showing a warning about "Slow network is detected" and it's trying to load the font
FFB_Master-VF.ttffrom Vercel. It seems the fallback font is being used before the variable font fully loads, which is why the justification doesn't appear.This might be a CDN loading issue. To fix this for testing, I could perhaps host the font file differently or ensure it's preloaded. I will look into this and update the demo. Thank you again for pointing this out—it's a valuable technical clue!
0 -
Simon Cozens said:Safari 26:John Hudson said:Thank you so much, Simon and John, for your patience and for testing it again.
I found the root cause of the issue: it was a font-loading timing issue on the CDN. On faster connections, the scripts ran before the variable font was fully loaded, which prevented the justification from rendering correctly. I have fixed this by preloading the font and waiting for
document.fonts.readybefore executing the justification logic.I also noticed a separate issue during my tests: when the line breaks (e.g., at narrower widths), the justification logic doesn't seem to handle the last line correctly, and words might move to the next line unexpectedly. I am currently investigating this behavior in my
lineAnalyzer.jsmodule.I have updated the live demo. Could you please try it again and let me know if it works for you now? Any feedback on the line-breaking behavior would also be greatly appreciated as I continue to refine the engine.
Thank you again for your time and valuable help!
1
Categories
- All Categories
- 47 Introductions
- 4K Typeface Design
- 505 Type Design Critiques
- 597 Type Design Software
- 1.1K Type Design Technique & Theory
- 679 Type Business
- 911 Font Technology
- 29 Punchcutting
- 544 Typography
- 129 Type Education
- 333 Type History
- 82 Type Resources
- 114 Lettering and Calligraphy
- 33 Lettering Critiques
- 81 Lettering Technique & Theory
- 588 Announcements
- 102 Events
- 118 Job Postings
- 179 Type Releases
- 188 Miscellaneous News
- 270 About TypeDrawers
- 54 TypeDrawers Announcements
- 114 Suggestions and Bug Reports
