استعمل خطوط القرآن في تطبيقك
ثلاثة أمثلة تغطي معظم التطبيقات: (1) خطوط نصية يونيكود — ألصق @font-face واعرض الآيات مباشرة. (2) خطوط مقطعية — خط لكل صفحة، يُقترن بخريطة رموز PUA. (3) صور التجويد — بلا خط، صور PNG فقط.
مثال 1 · خط نصي يونيكود
الخطوط النصية اليونيكود تعرض أي آية مباشرة — بلا حاجة لبيانات مقترنة.
/* 1. Load the font */
@font-face {
font-family: 'UthmanicHafs';
src: url('https://fonts.quran.ws/assets/fonts/uthmanic-hafs-v22.woff2') format('woff2');
font-display: swap;
}
/* 2. Use it on any Arabic text */
.quran {
font-family: 'UthmanicHafs', 'Amiri', serif;
direction: rtl;
font-size: 2rem;
line-height: 2.3;
}
مثال 2 · خط مقطعي (صفحة بصفحة)
الخطوط المقطعية لا تعرض اليونيكود. لا بد من تحميل ملف البيانات المقترن (mushaf.txt للإصدارات 1 و1.5 و2، وquran.json للإصدار 4) لمعرفة رموز PUA في كل صفحة.
<!-- 1. Load the font for the specific page you want -->
<style>
@font-face {
font-family: 'QCF_P001';
src: url('https://fonts.quran.ws/assets/fonts/qpc-hafs-v1/QCF_P001.woff2') format('woff2');
}
.page-glyph {
font-family: 'QCF_P001';
unicode-bidi: bidi-override; /* PUA defaults to LTR; override to RTL */
direction: rtl;
font-size: 2rem;
}
</style>
<!-- 2. Fetch the paired ayah-keyed glyph data -->
<script>
const data = await fetch('https://fonts.quran.ws/bundles/qpc-hafs-v1/quran-glyphs.json').then(r => r.json());
// Each ayah is {surah, ayah, chunks: [{p, family, file, text}]} — render the first chunk
const ayah = data.ayat[0];
document.querySelector('.page-glyph').textContent = ayah.chunks.map(c => c.text).join('');
</script>
<!-- 3. Render -->
<div class="page-glyph"></div>
مثال 3 · نص التجويد الملوّن
بيانات التجويد تحمل أحكامًا لكل كلمة. استعملها مع خط واعٍ بالتجويد (QPC v4) أو اعرضها بألوان span.
<!-- No font needed — pair the tajweed-coloured mushaf text with any renderer. -->
<!-- Grab the ready-to-use bundle from https://fonts.quran.ws/bundles/hafs-tajweed/ -->
<script>
const r = await fetch('https://fonts.quran.ws/bundles/hafs-tajweed/quran.json').then(r => r.json());
const ayah = r.ayat.find(a => a.surah === 2 && a.ayah === 255);
document.querySelector('.ayah').textContent = ayah.text;
</script>
<span class="ayah"></span>
الربط بين الخط والبيانات
| الإصدار | اسم الخط | صفحة → خط | البيانات |
|---|---|---|---|
v1 |
QCF_P{page:03d} |
QCF_P{page:03d} |
hafs-glyphs/v1/data/mushaf.txt |
v1.5 |
page_{page} |
page_{page} |
hafs-glyphs/v1.5/data/mushaf.txt |
v2 |
QCF2{page:03d} |
QCF2{page:03d} |
hafs-glyphs/v2/data/mushaf.txt |
v4 Hafs |
QCF4_Hafs_{range:02d}_W |
per-word p field |
hafs-glyphs/v4/data/quran.json |
v4 Warsh |
QCF4_Warsh_{range:02d}_W |
per-word p field |
warsh-glyphs/v4/data/quran.json |