question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Arabic text is not rendered correctly

See original GitHub issue

Expected Behavior

Let’s take the following arabic sentence: بِسْمِ الله الرَّحْمٰنِ الرَّحِيمِ’ Natively it renders to the following form: reference

Current Behavior

With current version of opentype.js (and even with merged PR #361 and #362 from @solomancode it looks like this: test_scheh

  • 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:open
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
moyogocommented, Dec 7, 2018

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:

U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM is a very common ligature, used to display the name of God. When the formation of the allah ligature is desired, the recommended way to represent the word would be <alef, lam, lam, shadda, superscript alef, heh><0627, 0644, 0644, 0651, 0670, 0647>. In non-Arabic languages, other forms of heh, such as heh goal (U+06C1), may also form the ligature. Extra care should be taken not to form the ligature in the absence of the shadda and the superscript alef, as the sequences <alef, lam, lam, heh> and <alef, lam, lam, shadda, heh> exist in Persian and other languages with different meanings or pronunciations, where the formation of the ligature would be incorrect and inappropriate.

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.

0reactions
solomancodecommented, Oct 2, 2022

I don’t understand your question, واللـهِ That’s ‘Kasra’ not Shadda, and it’s not related to the spec.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found