Git Product home page Git Product logo

Comments (23)

faisalcodes avatar faisalcodes commented on June 12, 2024

It's a well known issue and I could not find a universal solution. But I'll leave it open until I provide a way to solve it.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

@faisalcodes Uthmani Hafs font's verse count (double digit) is not consistent like other fonts
example
IndoPak (13) ---- Hafs (31) ----- King Fahd complex V1 (13)
           |_____> It seems using Left to Right (Expected: Right to Left)

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

I have explicitly reversed the order because on some phones, only reversing works and on others it does not. I think I should provide a button which should be used to fix the order.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

@faisalcodes On which android versions , you have seen this bug?

image
On Android 11, the count is rendering as expected

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

It is a brand specific issue.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

I am using Redmi 9t

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

I tested on a Redmi Android 10 and it works.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

Have you tried using .ttf hafs font?

Link: https://github.com/mustafa0x/qpc-fonts

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

Tried all of them but had no luck. The same font is found everywhere.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

#210 (comment) relates to harfbuzz/harfbuzz#501

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

But the behaviour is different on different mobile brands. Some support RTL numbering and others LTR.

from quranapp.

khaledhosny avatar khaledhosny commented on June 12, 2024

Most likely the phones with bad rendering ship with old versions of HarfBuzz

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

I think that too.

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

My doubt is that Android 12-> 13 has this issue

so I modified existing script json to "end": "٠١"} , number render correctly on Android 13 , but broke Android 11

Further Test need to be done on emulators like Android 12, 12L (Emulator from Android Studio are very slow on my Laptop :( .)

My theory is that to make another json script file for android 12+ devices which contains verse count with zeros like here "end": "٠١"}
and existing file works on Android 11 and below
Application should choose .json file based Android Version

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

@Luciogi
If the issue is specific to Android Version then it can be solved easily. There is no need to create two different json files as I have done the reversing of numbers manually with following code:

CharSequence text = shouldReverse ? new StringBuilder(serialText).reverse().toString() : serialText;

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

For this solution hafs font numbers should in RTL like 21

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

I would like to see you create new branch to test this solution

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

But I doubt that it's the Android version. I tested on an Android 12 phone and it does not work without reversing. It seems to be an issue of phone brands as stated by khaledhosny earlier:

Most likely the phones with bad rendering ship with old versions of HarfBuzz

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

Can I get reversing code ?

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

Yes, it' here:

CharSequence text = shouldReverse ? new StringBuilder(serialText).reverse().toString() : serialText;

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024
index 47ad86d..ef8bdb6 100644
--- a/app/src/main/java/com/quranapp/android/utils/verse/VerseUtils.java
+++ b/app/src/main/java/com/quranapp/android/utils/verse/VerseUtils.java
@@ -30,6 +30,8 @@ import java.time.Duration;
 import java.util.Calendar;
 import java.util.Random;
 
+import android.os.Build;
+
 public abstract class VerseUtils {
     private static final int VOTD_RESET_MINUTES = 24 * 60; // one day
     private static int VOTD_chap_no = -1;
@@ -109,7 +111,12 @@ public abstract class VerseUtils {
         boolean shouldReverse,
         int verseTextSize
     ) {
-        CharSequence text = shouldReverse ? new StringBuilder(serialText).reverse().toString() : serialText;
+        CharSequence text;
+        if (Build.VERSION.SDK_INT >= 33)
+            text = serialText;
+        else
+            text = new StringBuilder(serialText).reverse().toString();
+        // CharSequence text = shouldReverse ? new StringBuilder(serialText).reverse().toString() : serialText;
 
         SpannableString verseNoSpannable = new SpannableString(text);
         // Set the typeface to span over verse number text

Test this patch with android 12 and 10

Edit: This code Worked fine on Android 11 , 13 and Android 14(Preview)

Android SDK/API LEVELS: https://support.google.com/googleplay/android-developer/answer/11926878?hl=en

  • Please test if my changes does not affect other fonts

from quranapp.

faisalcodes avatar faisalcodes commented on June 12, 2024

So, by default the number is rendered properly on API >=33 only?

from quranapp.

Luciogi avatar Luciogi commented on June 12, 2024

Summary: Below Android 13, Font was not rendered as RTL (rather it was using LTR), So Developer reversed as a hack. Which created above issue on , Android 13 >=, it renders RTL as expected.

🙃

from quranapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.