开发者

Arabic TTF (TrueType font) in UIWebView iOS 4.2.1

开发者 https://www.devze.com 2023-03-02 03:18 出处:网络
Hi I want to use custom arabic font in UIWebView, I read that iOS 4.2 onwards we can use TTF webfonts.

Hi I want to use custom arabic font in UIWebView, I read that iOS 4.2 onwards we can use TTF webfonts.

I have arabic font in my resources and following is the code I am using:

<html>
    <head>
        <title>@font-face Demo</title>
        <style type="text/css">
            @font-face {
                font-family: 'me_quran Regular';
                src: local('me_quran Regular'), 
         开发者_Go百科                   local('me_quran'), 
                            url('me_quran.ttf') format('truetype');

            }


            h1, p {
                font-family: 'me_quran Regular';
            }
            h1 {
                font-size: 45px;
            }
            p {
                font-size: 18px;
                line-height: 27px;
            }
            #container{
                width: 800px;
                margin: 0 auto 0 auto;
            }

            }

        </style>
    </head>
    <body>
        <div id="container">
            <h1>بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ</h1>

            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </body>
</html>

The problem is: I am getting the arabic text in UIWebView but its not the one I loaded, its the default arabic font iOS uses.

Help me out! Note: I have tested many English TTF, they all are working fine with iOS 4.2.1.


Hi I finally figured it out. You can load almost all (.ttf) fonts, either arabic, english or whatever on iOS 3.2 above. You just need to use the correct text (in terms of unicode), to display it.

0

精彩评论

暂无评论...
验证码 换一张
取 消