Arabic text is not rendered correctly
See original GitHub issueExpected Behavior
Let’s take the following arabic sentence: بِسْمِ الله الرَّحْمٰنِ الرَّحِيمِ’ Natively it renders to the following form:
Current Behavior
With current version of opentype.js (and even with merged PR #361 and #362 from @solomancode it looks like this:
- serifs look different
- last word looks significantly different
- the semi-vertical lines have incorrect x position and are a bit lower
- second word (allah) misses a “w”
Steps to Reproduce
Create following js file in opentype.js directory:
var opentype = require('./dist/opentype');
var fs = require("fs");
var Canvas = require("canvas").Canvas;
opentype.load('fonts/Scheherazade-Bold.ttf', function(err, font) {
if (err) {
alert('Font could not be loaded: ' + err);
} else {
var canvas = new Canvas(1000, 500, "png");
var ctx = canvas.getContext('2d');
var path = font.getPath('بِسْمِ الله الرَّحْمٰنِ الرَّحِيمِ', 0, 200, 100);
path.draw(ctx);
var buf = canvas.toBuffer();
fs.writeFileSync("test.png", buf);
}
});
(additionally, use npm install canvas
to be able to render font to png))
Your Environment
- Version used: 0.11.0
- Font used: Scheherazade-Bold.ttf
- Browser Name and version: Chrome Canary
- Operating System and version (desktop or mobile): Windows 10
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Arabic text not rendered correctly (rendered as rubbish)
There is no need to decode and no issue with fonts (at least in my case). Just render the text again, and it...
Read more >Solved: Re: Arabic Text not rendering correctly in EPUB
The fix is to use the zero-width-joiner character () before the <span> and before the character inside the <span>. Then, you need to...
Read more >arabic not rendered correctly - SFML
Re: arabic not rendered correctly ... Ok, I see now. The right-to-left layout could be added to sf::Text as an option; I'll add...
Read more >Arabic not rendering in Internet Explorer 9/11 in Windows 7/10
Seems it is not a font system issue as the text is perfectly readable on the dev tool console. Most probably is about...
Read more >Arabic text inside of listings - TeX - LaTeX Stack Exchange
Remove the spacing for the left frame line that seems to be caused by the Arabic text. listings · font-encodings · html ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Regarding the Allah word, Scheherazade is following the Unicode specification. Fonts should only form the allah ligature when the shadda and the superscript alef are present in the character sequence. See the note about FDF2 in https://www.unicode.org/versions/Unicode11.0.0/ch09.pdf#page=32:
However many fonts, including widely used system fonts, do form the ligature without the shadda and superscript alef being present in the character sequence. So it is understandable that there is such a user expectation but it is problematic for the reasons given in the Unicode standard.
I don’t understand your question, واللـهِ That’s ‘Kasra’ not Shadda, and it’s not related to the spec.