AlfaizDev Well-Known Member Licensed User Longtime User Jul 6, 2021 #1 I use this code in B4A It works well When I used it in B4I The coordination works except the custom Font It shows me to write default Font for mobile B4X: File.Copy(File.DirAssets, "uthmantn1ver10.otf",File.DirLibrary,"uthmantn1ver10.otf") Code: Dim Deel As String =Content Dim pish As String = "<html><head><style type='text/css'>@font-face {font-family: MyFont;src: url('" _ & File.DirLibrary &"/uthmantn1ver10.otf')}body {font-family: MyFont;font-size: "&20&"pt}</style></head><body> " Dim pas As String = "</body></html>" Dim myHtmlString As String = pish & Deel &pas WebView1.LoadHtml(myHtmlString) Last edited: Jul 6, 2021
I use this code in B4A It works well When I used it in B4I The coordination works except the custom Font It shows me to write default Font for mobile B4X: File.Copy(File.DirAssets, "uthmantn1ver10.otf",File.DirLibrary,"uthmantn1ver10.otf") Code: Dim Deel As String =Content Dim pish As String = "<html><head><style type='text/css'>@font-face {font-family: MyFont;src: url('" _ & File.DirLibrary &"/uthmantn1ver10.otf')}body {font-family: MyFont;font-size: "&20&"pt}</style></head><body> " Dim pas As String = "</body></html>" Dim myHtmlString As String = pish & Deel &pas WebView1.LoadHtml(myHtmlString)
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2021 #2 1. The less you use WebView the simpler things will be. 2. You should learn how to use smart strings: https://www.b4x.com/android/forum/threads/50135/#content 3. Save the html in a file in File.DirLibrary and load it with LoadURL. Try it without the full path to the font file, only the file name. Upvote 0
1. The less you use WebView the simpler things will be. 2. You should learn how to use smart strings: https://www.b4x.com/android/forum/threads/50135/#content 3. Save the html in a file in File.DirLibrary and load it with LoadURL. Try it without the full path to the font file, only the file name.
AlfaizDev Well-Known Member Licensed User Longtime User Jul 6, 2021 #3 Erel said: 1. The less you use WebView the simpler things will be. Click to expand... Sometimes they are for use for Text Adjust arabic Is there another solution for Text ADJUST? thanks Upvote 0
Erel said: 1. The less you use WebView the simpler things will be. Click to expand... Sometimes they are for use for Text Adjust arabic Is there another solution for Text ADJUST? thanks
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2021 #4 What is text adjust? Upvote 0
AlfaizDev Well-Known Member Licensed User Longtime User Jul 6, 2021 #5 Erel said: What is text adjust? Click to expand... Align text adjust in label Instead of using WebView Upvote 0
Erel said: What is text adjust? Click to expand... Align text adjust in label Instead of using WebView
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2021 #6 Justify? set label alignment to justify Hi, How can I set label alignment to justify? www.b4x.com Upvote 0
AlfaizDev Well-Known Member Licensed User Longtime User Jul 6, 2021 #7 Erel said: Justify? Click to expand... Yes I mean Justify Thank you so much Upvote 0
Semen Matusovskiy Well-Known Member Licensed User Jul 6, 2021 #8 In ios 9+ you can force rtl individually for any view(). Take a look semanticContentAttribute Upvote 0
AlfaizDev Well-Known Member Licensed User Longtime User Jul 6, 2021 #9 Code works Erel said: set label alignment to justify Hi, How can I set label alignment to justify? www.b4x.com Click to expand... But this code below and found the same work B4X: LContant.TextAlignment=3 I remained a small problem I want to align be justified and right The problem you get in the last line where it is back to the left He did this code and did not work B4X: LContant.TextAlignment=Bit.Or(2,3) See the image at the bottom Attachments 566.png 439.3 KB · Views: 672 Last edited: Jul 6, 2021 Upvote 0
Code works Erel said: set label alignment to justify Hi, How can I set label alignment to justify? www.b4x.com Click to expand... But this code below and found the same work B4X: LContant.TextAlignment=3 I remained a small problem I want to align be justified and right The problem you get in the last line where it is back to the left He did this code and did not work B4X: LContant.TextAlignment=Bit.Or(2,3) See the image at the bottom
Erel B4X founder Staff member Licensed User Longtime User Jul 7, 2021 #10 Please create a small project with a label and this text and upload it. Upvote 0
AlfaizDev Well-Known Member Licensed User Longtime User Aug 7, 2021 #12 Thanks The justification in Label has worked for me But can I find a solution to the line in WebView Erel said: 3. Save the html in a file in File.DirLibrary and load it with LoadURL. Try it without the full path to the font file, only the file name. Click to expand... I can't save the data as an html file Because I am importing data from databases into a WebView Upvote 0
Thanks The justification in Label has worked for me But can I find a solution to the line in WebView Erel said: 3. Save the html in a file in File.DirLibrary and load it with LoadURL. Try it without the full path to the font file, only the file name. Click to expand... I can't save the data as an html file Because I am importing data from databases into a WebView
Semen Matusovskiy Well-Known Member Licensed User Aug 7, 2021 #13 If to come back to https://www.b4x.com/android/forum/t...-in-webview1-does-not-work.132282/post-835048 1) If to use #AppFont, IOS sees a custom font like any other IOS fonts. So, I don't see a reason to File.Copy 2) font-family: MyFont ??? Your font belongs to KFGQPC Uthman Taha Naskh url - guess, not needed 3) Add something like <meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'> to header. Otherwise it will be troubles with scale. 4) I don't see text-align: justify (for example in styles) and dir=rtl (for example in <html>) Upvote 0
If to come back to https://www.b4x.com/android/forum/t...-in-webview1-does-not-work.132282/post-835048 1) If to use #AppFont, IOS sees a custom font like any other IOS fonts. So, I don't see a reason to File.Copy 2) font-family: MyFont ??? Your font belongs to KFGQPC Uthman Taha Naskh url - guess, not needed 3) Add something like <meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'> to header. Otherwise it will be troubles with scale. 4) I don't see text-align: justify (for example in styles) and dir=rtl (for example in <html>)
AlfaizDev Well-Known Member Licensed User Longtime User Aug 8, 2021 #14 Semen Matusovskiy said: 1) If to use #AppFont, IOS sees a custom font like any other IOS fonts. So, I don't see a reason to File.Copy Click to expand... Thanks, I didn't notice that The situation is different from b4a Semen Matusovskiy said: 2) font-family: MyFont ??? Your font belongs to KFGQPC Uthman Taha Naskh url - guess, not needed Click to expand... What will the path of the line be in the html code? instead of this B4X: Dim Deel As String =Content Dim pish As String = "<html><head><style type='text/css'>@font-face {font-family: MyFont;src: url('" _ [B] & File.DirLibrary &"/uthmantn1ver10.otf')[/B]}body {font-family: MyFont;font-size: "&20&"pt}</style></head><body> " Semen Matusovskiy said: 3) Add something like <meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'> to header. Otherwise it will be troubles with scale. 4) I don't see text-align: justify (for example in styles) and dir=rtl (for example in <html>) Click to expand... Format codes are in the database The text is stored in the database as html Upvote 0
Semen Matusovskiy said: 1) If to use #AppFont, IOS sees a custom font like any other IOS fonts. So, I don't see a reason to File.Copy Click to expand... Thanks, I didn't notice that The situation is different from b4a Semen Matusovskiy said: 2) font-family: MyFont ??? Your font belongs to KFGQPC Uthman Taha Naskh url - guess, not needed Click to expand... What will the path of the line be in the html code? instead of this B4X: Dim Deel As String =Content Dim pish As String = "<html><head><style type='text/css'>@font-face {font-family: MyFont;src: url('" _ [B] & File.DirLibrary &"/uthmantn1ver10.otf')[/B]}body {font-family: MyFont;font-size: "&20&"pt}</style></head><body> " Semen Matusovskiy said: 3) Add something like <meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'> to header. Otherwise it will be troubles with scale. 4) I don't see text-align: justify (for example in styles) and dir=rtl (for example in <html>) Click to expand... Format codes are in the database The text is stored in the database as html
Semen Matusovskiy Well-Known Member Licensed User Aug 8, 2021 #15 I placed UthmanTN1Ver10.otf into Special subfolder and added #AppFont : UthmanTN1Ver10.otf In Application_Start I did Log (Font.CreateNew2 ("KFGQPC Uthman Taha Naskh", 20dip)). Result: <B4IFontWrapper: <UICTFont: 0x7fd768641970> font-family: "KFGQPC Uthman Taha Naskh"; font-weight: normal; font-style: normal; font-size: 20.00pt>. Means IOS sees a font family. HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt } Upvote 0
I placed UthmanTN1Ver10.otf into Special subfolder and added #AppFont : UthmanTN1Ver10.otf In Application_Start I did Log (Font.CreateNew2 ("KFGQPC Uthman Taha Naskh", 20dip)). Result: <B4IFontWrapper: <UICTFont: 0x7fd768641970> font-family: "KFGQPC Uthman Taha Naskh"; font-weight: normal; font-style: normal; font-size: 20.00pt>. Means IOS sees a font family. HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt }
AlfaizDev Well-Known Member Licensed User Longtime User Aug 9, 2021 #16 Semen Matusovskiy said: HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt } Click to expand... Well I will try on it Thanks Upvote 0
Semen Matusovskiy said: HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt } Click to expand... Well I will try on it Thanks
AlfaizDev Well-Known Member Licensed User Longtime User Aug 14, 2021 #17 Semen Matusovskiy said: HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt } Click to expand... It looks like the one in the picture I tried with the code and it didn't work B4X: Dim pish As String = "<html><head><style type=text/css>body" _ & " { font-family:'KFGQPC Uthman Taha Naskh;'; font-size: 80pt;text-align: center; color: #E2341D; }</style></head> " Dim Deel As String = txt Dim pas As String = "</body></html>" Dim myHtmlString As String = pish & Deel &pas WebView1.LoadHtml(myHtmlString) Code: من أسباب الاصابة بمرض تكون العظم الناقص. إن اضطراب العظام الخلقية تترافق مع عيب في النسيج الضام، مما يؤدي إلى عدم القدرة على بناء العظم أو تكوينه ويؤدي إلى سهولة كسر العظام، وغالبا ما يكون سبب تلك الكسور غير ظاهر. Last edited: Aug 14, 2021 Upvote 0
Semen Matusovskiy said: HTML ... It's hard to test, because I don't know how a font looks. Guess, inside <style type=text/css> it's neccessary to do something like body { font-family: KFGQPC Uthman Taha Naskh; font-size: 20pt } Click to expand... It looks like the one in the picture I tried with the code and it didn't work B4X: Dim pish As String = "<html><head><style type=text/css>body" _ & " { font-family:'KFGQPC Uthman Taha Naskh;'; font-size: 80pt;text-align: center; color: #E2341D; }</style></head> " Dim Deel As String = txt Dim pas As String = "</body></html>" Dim myHtmlString As String = pish & Deel &pas WebView1.LoadHtml(myHtmlString) Code: من أسباب الاصابة بمرض تكون العظم الناقص. إن اضطراب العظام الخلقية تترافق مع عيب في النسيج الضام، مما يؤدي إلى عدم القدرة على بناء العظم أو تكوينه ويؤدي إلى سهولة كسر العظام، وغالبا ما يكون سبب تلك الكسور غير ظاهر.
Semen Matusovskiy Well-Known Member Licensed User Aug 15, 2021 #18 I did some experiments, 1) It looks that B4I WebView.LoadHtml does not set baseurl. So I replaced it to OBJC, 2) Fonts are really should be described in CSS, because WKWebView (probably) works in another process. 3) About your font I am not sure. But Latin fonts are correct. Attachments s23.zip s23.zip 473.1 KB · Views: 602 Last edited: Aug 16, 2021 Upvote 0
I did some experiments, 1) It looks that B4I WebView.LoadHtml does not set baseurl. So I replaced it to OBJC, 2) Fonts are really should be described in CSS, because WKWebView (probably) works in another process. 3) About your font I am not sure. But Latin fonts are correct.