Text versus visual representation

You can show a reader the Qur’an as a string set in a font, or as the printed page of a specific muṣḥaf drawn as vectors. They look similar on screen and they are different products with different data, different weights and different failure modes. Most apps need both. This page is about choosing which one answers which question.

For most readers the Qur’an is a particular printed page: the same line breaks, the same page ends, the same ornaments they memorised from. A string in a font gives them the same words in a layout they have never seen. That is fine for search results, translations and study tools, and wrong for a memorisation app, where "the ayah at the bottom of the left page" is how people remember.

The choice is: does the reader need the words, or the page?

The two representations, side by side

TextVisual
What you receiveUnicode strings, one per word, in seven readingsGlyph outlines of one printed page, plus a layer that says which ink is which verse or word
FromQuran TextQuran SVG, Quran SVG Elements, Quran Engine
Layoutyours — the browser or platform lays it outthe publisher's, exactly: line breaks, page breaks, ornaments
Needs a fontyes, and a specific one per editionno — the ink is in the file
Selectable, find-in-page, copyyesno — there is no <text> element in any page
Smallest addressable thinga characteran ayah (SVG), a word or a mark (Elements, Engine)
Smallest download for one ayahthe whole edition: 1.9–3.1 MBone page: page 1 of Ḥafṣ is 196 KB raw, 33 KB Brotli
Riwayat availableall sevenfive (SVG); one, Ḥafṣ (Elements, Engine)
Fails silently whenthe font is missing — words render blankyou assume the file knows what an ayah says
Text with the wrong font renders as nothing, not as an error

Warsh, Qālūn and al-Sūsī use Arabic Extended-B code points that Unicode only added in 2021, and almost no general font draws them. text.length is right, a code-point dump is right, and the screen shows empty boxes or blank space. Every muṣḥaf file in Quran Text names the font its text is set in; ship that one — seven fonts, one per edition, not one for all seven.

A page does not know what it says

Quran SVG's pages carry no text at all: a tap resolves to a surah and ayah attribute on a polygon, and that is everything the file knows. Elements goes further, every word group carries its printed form as data-rasm-uthmani, but there is still nothing to search, select or copy. If your feature needs the words, join to Quran Text by word key. Nothing throws if you forget; you have a page you can tap but cannot read from.

Choosing

The reader wants toUseBecause
Read or memorise from the page they knowvisualthe layout is the content for them
See search results, a translation beside the text, a quoted ayahtextyou control layout and the string is selectable
Tap a verse on the page and see its translationvisual + textpolygon → reference → Quran Text
Tap a word, colour a word, follow a recitation word by wordElements or Engine, + textthose are the only visual formats that address a word
Colour tajwīd on a stringtext + Quran Tajweedspans are character offsets into a text
Colour tajwīd on the printed pageElements + Tajweeda mark is its own path, so a rule can address it
Show any reading other than Ḥafṣ with word-level interactionnothing todayonly the Ḥafṣ muṣḥaf has been split — see Riwayat
Render pages on a phoneEngineSVG of a full page's density does not perform on mobile

The three visual blocks are not a queue. Coverage narrows as addressing deepens: Quran SVG covers every vectorised muṣḥaf and addresses an ayah; Elements covers only what has been split and addresses a word or a mark; Engine draws the split muṣḥafs on mobile. Elements ships 604 whole pages too; the difference is what you can address once a page is on screen, never "pages versus parts".

What the two do not share

They are built from the same publisher, and they still do not share coordinates, offsets or strings.

  1. Decide per feature, not per app

    A study app's reading view is visual; its search is text; its share-as-image is a visual crop. Write the decision down for each screen.

  2. Load the visual page, resolve taps to a reference

    root.querySelectorAll<SVGPathElement>(".ayahPolygon").forEach((p) => {
      p.addEventListener("click", () => {
        open(Number(p.getAttribute("surah")), Number(p.getAttribute("ayah")));
      });
    });
    

    This is the Quran SVG integration the demo on this site runs, trimmed. The reference is all the page gives you.

  3. Fetch the words for that reference from the text dataset

    const m = await Mushaf.hafs();
    m.ayah(surah, ayah).text;
    

    The muṣḥaf you loaded for the page and the edition you loaded for the text must be the same reading, or the ayah numbers will not line up. Persist both keys.

How this data is made

The text is extracted unedited from the publisher's digital packages, one per reading, and each file names its package and digest. The pages are vectorised from the publisher's printed edition; Quran SVG derives its ayah polygons from each page's own ayah medallions, and Elements regroups that ink into words and named marks without moving or redrawing a path.