Balaji Dhanasekar
Balaji Dhanasekar

Reputation: 1080

Arabic font issue in the Android WebView

I am trying to load a HTML file into android webview. I have fonts and html folder inside the assests. In the fonts folder I have Arabic Regular.otf and Arabic Bold.otf. On loading the page into webview i can't see the difference between bold and regular fonts. I have searched in SO, and then changed the font from otf to svg format. It works fine for me in Jelly Bean, but not exactly in HoneyComb. Please Help.

My styles in HTML file.

.c0{direction:rtl}


p span.medium { font-family:"AdobeArabic-Bold", sans-serif; }
p span { font-family:"AdobeArabic-Regular", sans-serif; }


@font-face {
font-family: 'AdobeArabic-Regular';
src: url('file:///android_asset/fonts/AdobeArabic-Regular.svg');    
}

@font-face {
font-family: 'AdobeArabic-Bold';
src: url('file:///android_asset/fonts/AdobeArabic-Bold.svg');    
}

And my Activity Code;

WebView wv=(WebView) findViewById(R.id.webView1);
wv.loadUrl("file:///android_asset/html/policy.html"); 

And my HTML code is

<p class="c0"><span class="medium">المعلومات التي تقدمها.</span></p>
<p class="c0"><span>لكي تتمكن من تصفح هذا الموقع، يجب عليك إدخال بعض المعلومات الشخصية المعرفة (مثل الإسم والبريد الإلكتروني وتاريخ الميلاد). بهدف أن تستفيد من بعض المزايا المميزة. سوف يتم إعلامك أية معلومات مطلوبة منك وأيها اختياري ولأي هدف سنستخدمها.</span></p>

Upvotes: 1

Views: 1724

Answers (1)

gnclmorais
gnclmorais

Reputation: 4971

Try something like this, setting them as the same family, but different weights:

@font-face {
    font-family: "AdobeArabic";
    src: url('file:///android_asset/fonts/AdobeArabic-Regular.svg');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: "AdobeArabic";
    src: url('file:///android_asset/fonts/AdobeArabic-Bold.svg');
    font-weight: bold;
    font-style: normal;
}

And then:

p span {
    font-family: "AdobeArabic-Regular", sans-serif;
}
p span.medium {
    font-weight: bold;
}

Upvotes: 1

Related Questions