Skip to content

Added option to display Surah Header and Skip BismiLlah - #20

Open
samwids wants to merge 10 commits into
ashaltu:mainfrom
samwids:main
Open

Added option to display Surah Header and Skip BismiLlah#20
samwids wants to merge 10 commits into
ashaltu:mainfrom
samwids:main

Conversation

@samwids

@samwids samwids commented Dec 27, 2025

Copy link
Copy Markdown
  1. Added a CLI option to display the Surah header, including its font size and top margin, in generated video, (below top margin for video in portrait mode 720x1280) e.g.:

CLI = --show-surah-header --surah-header-font-size 40 --surah-header-margin-top 200
config.json =
"surahHeaderFont": {
"family": "Alvi Nastaleeq",
"file": "fonts/Alvi Nastaleeq Regular.ttf",
"size": 50,
"color": "FFFFFF"
},

  1. Added a CLI option to skip Bismillah. When skipping it, the Ayah number was missing from the first Ayah, so this was handled separately:

CLI = --skip-start-bismillah

@ashaltu ashaltu added the enhancement New feature or request label Dec 28, 2025

@ashaltu ashaltu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assalamu alaykum,

JazzakAllahu Khair for the changes and your patience, things are a bit untidy. Some other notes:

  1. Update the README with the new CLI flags.
  2. Include an [Unreleased] section in CHANGELOG.md. Here is an example commit (it doesn't have to be verbose like this, short and sweet is fine): 6cb9df1
  3. Since there isn't complete testing setup, can you list out the different commands you ran to test edge cases. Screenshots are helpful too and save a bunch of time reviewing, otherwise I'll just manually re-run each command to verify.

Comment thread assets/fonts/Alvi Nastaleeq Regular.ttf Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not include this in the repo? Imagine every language added in the future we have more than one font for it, it'll bloat the repo. Although, if this font is better in general for Urdu (in your opinion) than whats present, I'm fine if you replace it.

To be honest, this is related to a general problem that needs to be addressed, which is how much and what data to serve. Do you think including all fonts in the data.tar makes most sense rather than in the repo?

Comment thread config.json
"_comment": "Video dimensions and quality",
"width": 1280,
"height": 720,
"width": 720,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep the default as 1280x720?

Comment thread config.json
"size": 70,
"color": "FFFFFF"
},
"translationFont": {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise keep English translation font as the default config.json values?

Comment thread src/config_loader.cpp Outdated

// Load surahHeaderFont configuration
if (data.contains("surahHeaderFont") && data["surahHeaderFont"].is_object()) {
cfg.surahHeaderFont.family = data["surahHeaderFont"].value("family", cfg.arabicFont.family);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the default values in the config you provided shows an Urdu header:

Image

But the fall back you wrote is to use the Arabic font for the Surah header, but it doesn't seem to be rendering properly:

Image

Could you address this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Removed the 'surahHeaderFont' section that was previously added in 'config.json'. The project now uses consistent Arabic Surah names as headers.
  2. Added 'ar.json' in 'data/surah-names' for Surah headers. This fixes issues where Surah names were not rendering correctly due to text/font incompatibility.
    260308-171456-vlc-Surah_-2_182_183-Al-Baqarah-t4_r25 mp4-VLC-E5kX4

Comment thread src/recitation_utils.cpp
const std::string& localAudioPath,
bool skipStartBismillah) {

if (skipStartBismillah) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? From what it looks like, your changes in LiveApiClient.cpp alter the condition to be options.surah != 1 && options.surah != 9 && !options.skipStartBismillah, so skipStartBismillah here will always be false (except maybe in the unit tests).

Also, I'm not sure if the following problem is occurring because of this line or another line, but when I generate for Surah Fatiha using ./build/qvm 1 1 7 --skip-start-bismillah or any other verse range in that surah, it shows the verse number twice:
Image

It should look like this:
Image

@samwids samwids Mar 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Fixed an issue where two Ayah numbers were being displayed.
    260308-154407-vlc-Surah_-1_1_7-Al-Fatiha-t4_r25 mp4-_VLC_media-R5PEZ

Comment thread src/subtitle_builder.cpp

ass_file << "Dialogue: 0," << format_time_ass(header_start_time) << ","
<< format_time_ass(total_video_duration)
<< ",Translation,,0,0,0,,{\\an8\\pos(" << config.width/2 << "," << header_y_position << ")"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using Translation here, so the final video shows the Translation font, this probably the source of the bug mentioned in the other comment. Did you mean to use the Arabic font, especially since there's a bunch of logic above where you write out the Surah in Arabic.

Alternatively, if you really do want the surah in the translation font, you can utilize the jsons in data/misc and data/surah-names. The util functions to access that stuff is in localization_utils.cpp.

samwids added 5 commits March 8, 2026 16:27
2. Updates related to the new translation:
   * Updated 'quran_data.h' for French translation (id = 5).
   * Updated 'numbers.json' in 'data/misc'.
   * Updated 'surah.json' in 'data/misc'.
   * Added translation file 'fr-hamidullah-clean.json' in 'data/translations/fr/'. Translation got from tanzil.net
3. Added CLI parameter '--show-surah-header'.
4. Added CLI parameter '--surah-header-font-size'.
5. Added CLI parameter '--surah-header-margin-top'.
6. Added CLI parameter '--skip-start-bismillah'.
7. Added CLI parameter '--translation-font-size'.
8. Added CLI parameter '--translation-font-color'.
9. Updated 'ur-fatah-muhammad-jalandhari-simple.json' in 'data/translations/urd' to fix brackets and exclamation marks so they render correctly with the Urdu font.
10. Changed the default/fallback font from 'American Captain.ttf' to 'Roboto-Regular.ttf'.
11. Added 'Roboto-Regular.ttf' in 'assets/fonts' to be used as a common font for French, English, and other LTR languages.
12. Removed 'family' and 'size' from the 'translationFont' section in 'config.json'. These are now read from 'quran_data.h' depending on whether the translation language is LTR or RTL.
13. Removed the 'surahHeaderFont' section that was previously added in 'config.json'. The project now uses consistent Arabic Surah names as headers.
14. Added 'ar.json' in 'data/surah-names' for Surah headers. This fixes issues where Surah names were not rendering correctly due to text/font incompatibility.
15. Set the default video dimension and quality to '720x1280' (portrait), which was required for my use case (social media).
16. Changed the output MP4 filename format to:
    'Surah - [SurahNumber]_[StartAyat]_[EndAyat] - [Surah Name] - t[TranslationId]_r[ReciterId].mp4'
	Example: 'Surah - 44_10_10 - Ad-Dukhan - t4_r25.mp4'
17. Fixed an issue where two Ayah numbers were being displayed.
@samwids

samwids commented Mar 8, 2026

Copy link
Copy Markdown
Author

Salaam,

I sincerely apologize for getting back so late, as I did not get the time to work on this or properly follow your advice. Unfortunately, it is not feasible for me due to my extremely busy schedule, and I cannot provide any commitment at this time.

I used and modified this project for my specific requirements, but the changes may not meet your well-defined coding standards or documentation expectations. Also, I am not very well-versed in C++ anymore, as it has been over 15–20 years and many things have changed since then.

However, I have committed some of my enhancements and listed the functions and changes I added below. If you find any of them useful when comparing with your commits, please feel free to incorporate them in whatever way you think is best.

Also, feel free to let me know if I can help in any way. As mentioned, however, I may not be able to provide any firm commitment due to my current engagements.

Changes and additions:

  1. Added French translation.
  2. Updates related to the new translation:
    • Updated 'quran_data.h' for French translation (id = 5).
    • Updated 'numbers.json' in 'data/misc'.
    • Updated 'surah.json' in 'data/misc'.
    • Added translation file 'fr-hamidullah-clean.json' in 'data/translations/fr/'. Translation got from tanzil.net
  3. Added CLI parameter '--show-surah-header'.
  4. Added CLI parameter '--surah-header-font-size'.
  5. Added CLI parameter '--surah-header-margin-top'.
  6. Added CLI parameter '--skip-start-bismillah'.
  7. Added CLI parameter '--translation-font-size'.
  8. Added CLI parameter '--translation-font-color'.
  9. Updated 'ur-fatah-muhammad-jalandhari-simple.json' in 'data/translations/urd' to fix brackets and exclamation marks so they render correctly with the Urdu font.
  10. Changed the default/fallback font from 'American Captain.ttf' to 'Roboto-Regular.ttf'.
  11. Added 'Roboto-Regular.ttf' in 'assets/fonts' to be used as a common font for French, English, and other LTR languages.
  12. Removed 'family' and 'size' from the 'translationFont' section in 'config.json'. These are now read from 'quran_data.h' depending on whether the translation language is LTR or RTL.
  13. Removed the 'surahHeaderFont' section that was previously added in 'config.json'. The project now uses consistent Arabic Surah names as headers.
  14. Added 'ar.json' in 'data/surah-names' for Surah headers. This fixes issues where Surah names were not rendering correctly due to text/font incompatibility.
  15. Set the default video dimension and quality to '720x1280' (portrait), which was required for my use case (social media).
  16. Changed the output MP4 filename format to:
    'Surah - [SurahNumber][StartAyat][EndAyat] - [Surah Name] - t[TranslationId]_r[ReciterId].mp4'
    Example: 'Surah - 44_10_10 - Ad-Dukhan - t4_r25.mp4'
  17. Fixed an issue where two Ayah numbers were being displayed.
  18. Updated data.tar for new french translation and fixed Arabic surah names, compressed as data.zip

Some of the changes are specific to my own requirements and may not be suitable for the main project (for example, portrait video mode or the output filename format I use for my automation). Please feel free to ignore those if they are not relevant.

e.g. CLI

Urdu
./build/qvm.exe 44 10 13 --reciter 25 --translation 4 --translation-font-size 55 --translation-font-color FFFFFF --show-surah-header --surah-header-font-size 50 --surah-header-margin-top 100 --skip-start-bismillah

./build/qvm.exe 1 1 7 --reciter 25 --translation 4 --translation-font-size 55 --translation-font-color FFFFFF --show-surah-header --surah-header-font-size 50 --surah-header-margin-top 100 --skip-start-bismillah

French
./build/qvm.exe 44 10 13 --reciter 25 --translation 5 --translation-font-size 35 --translation-font-color FFFFFF --show-surah-header --surah-header-font-size 50 --surah-header-margin-top 100 --skip-start-bismillah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants