a script that takes a KFGQPC (King Fahd Glorious Quran Printing Complex) font and generates line by line images with each word coordinates and updates the database with x_start,x_end,y_start,y_end coordinates.
- python (tested on python 3.10)
- pillow package
- sqlite3 package
- QCF font from here. should also work with the old one and a new one if released
- a database (available on clone)
its a custom database that is scrapped from quran com api. added some missing stuf like bismillah location and surah names with its lines and fixed some bugs. the goal was to get line by line for every page, instead of the whole text as once. see source code
in the main.py you can configure how the output images look
# --- Tuning variables
CANVAS_WIDTH = 1080
CANVAS_HEIGHT = 174
FONT_SIZE = 65
H_PADDING = 0
V_PADDING = 19
SHOW_MAREKRS = False
IS_THICK_TEXT = False # makes the text more thick
SHOW_BBOX = False # shows bbox around each glyph
PAGE_RANGES = [1, 604]
OUTPUT_FOLDER = "output/"
# --- End of tuning variables
with
....
SHOW_BBOX = True
SHOW_MARKERS = True
IS_THICK_TEXT = False
IS_TRANSPARENT = False
....
with
....
SHOW_BBOX = False
SHOW_MARKERS = False
IS_THICK_TEXT = True
IS_TRANSPARENT = True
....
and trasnparent background
- download packages
- put fonts folder in root
- run main.py
- run compress.py (recomended)
or just download the images from here and download the database from this repo and enjoy :)
huge thanks to quran.com community for providing their api and fonts