quran / quran.com-api

Quran.com content APIs
https://api-docs.quran.foundation/docs/category/content-apis
MIT License
922 stars 192 forks source link

الم Harakat #78

Closed imranbaig1977 closed 8 years ago

imranbaig1977 commented 8 years ago

I have been experimenting with following GET request. https://quran.com/api/v2/surahs/2/ayahs?from=1&to=1&audio=8&content%5B%5D=53&quran=1

It results into first ayah surah Bakra.

I need to know how to get الم with All HARAKAT. On website https://quran.com/2:1 Alif Laam Meen appears with Madh but in the api response it comes back without HARAKAT.

ahmedre commented 8 years ago

there are two ways of writing arabic text - "imlaei" (the way Arabic is written today in books, newspapers, etc), and "uthmani" (the handwritten script drawn specifically for the Quran). when you load quran.com, before the fonts load, you see the imlaei text, and once the fonts are loaded, you get the uthmani image:

before the font load:

screen shot 2016-11-06 at 1 22 56 pm

after the font load:

screen shot 2016-11-06 at 1 23 05 pm

the key here is the font - this font is a hand drawn font from the Quran Complex in Saudi Arabia, where each word has a glyph (as opposed to the standard "each letter is a glyph").

in summary, you get two pieces of data from the api: arabic - the imlaei arabic text - this has harakat, but for something like "الم", it doesn't show the "madd" because there's no "madd" tashkeel in today's written Arabic.

code - that's what's used to draw the word using the uthmani font for that page (from the page 2 font in that case). see quran/quran.com-images for the fonts and how we generate images from these if you are curious as to how they work.

closing for now, please feel free to reopen if there's something else to expound on.

imranbaig1977 commented 7 years ago

Jazak Allah Khair for your help. However, I could not find the relationship between code property ( inside the words JSON array) and the appearance of الم. I do understand code contains unicode fb51 ( ﭑ ) how does that unicode draws https://quran.com/2:1 الٓـمّٓ. Your help would enable me to complete my Quranic App.

ahmedre commented 7 years ago

the uthmani font is not a letter by letter font - it's a letter to word font. in other words, each letter pressed (fb51, or, easier, an ! in ascii range would work too), maps to a single word drawn as one piece - not to the letter alif, followed by the letter lam, followed by the letter meem (as would happen in standard imlaei writing). in other words, you can't split up the words.

i've attached two screenshots that might help explain.

this shows each character slot and what it contains:

screen shot 2016-11-13 at 1 36 37 pm

and this shows the fb5a / ! and what it maps to: screen shot 2016-11-13 at 1 36 49 pm

in an ideal world, you'd be able to have an uthmani font representing the entire Quran, so that you could do the same things as you could with a normal font. my guess is that they didn't do this because the same word on two separate pages may be drawn slightly different (because it's hand drawn). there are some people who put together actual uthmani fonts that work the way you'd expect (the me_quran font is one of the more popular ones), but i haven't found one that looks nearly as good as these do.

imranbaig1977 commented 7 years ago

Jazzak Allah Khair, I am using your ttf files and using typeface per word.