B4J Question [Solved]Test FontAndTextSize from B4XSwfButton library.

Theera

Expert
Licensed User
Longtime User
After I have edited own B4XSwfButton library (It's from Erel's SwiftButton and addition Font and TextSize properties).
I 've still problem in B4J about display font which is not correct ,but in B4A,the result is correct. I need someone how to solve the
problem. I don't understand what something be wrong. Thank you in advance.

P.S. Font is in Shared Files folder
 

Attachments

  • TestFontAndTextSizeWithB4XSwfButton.zip
    12.2 KB · Views: 17
Solution
In B4J you can use CSS style properties to set a font.
B4X:
'      B4XSwfButton1.Font=myFont
'      B4XSwfButton1.TextSize=24
#if B4J
    'https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#typefont
    ' each property separately
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-style","italic")
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-weight","bold")
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-size",20)
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-family","Monospace")
    ' or in one shorthand property string (put the 4 separate property settings in comment)
'    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font","italic bold 20 Monospace")
    ' if...

klaus

Expert
Licensed User
Longtime User
Your project is a B4XPages project.
Therefore you should zip the project by clicking on this line in the IDE on top of the B4çMainPage module.
This will include the B4J part of the project and the SharedFiles folder..

1756291970829.png
 

Attachments

  • 1756291960410.png
    1756291960410.png
    20.6 KB · Views: 12
Upvote 0

Theera

Expert
Licensed User
Longtime User
I'm sorry that,Now this is a new one.
 

Attachments

  • TestFontAndTextSizeWithB4XSwfButton.zip
    204.4 KB · Views: 19
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
In B4J you can use CSS style properties to set a font.
B4X:
'      B4XSwfButton1.Font=myFont
'      B4XSwfButton1.TextSize=24
#if B4J
    'https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#typefont
    ' each property separately
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-style","italic")
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-weight","bold")
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-size",20)
    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-family","Monospace")
    ' or in one shorthand property string (put the 4 separate property settings in comment)
'    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font","italic bold 20 Monospace")
    ' if the special font is available on the system this should work too
'    CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font","italic bold 20 playpensansthai-extrabold")
#End If
This test was done in the B4XMainPage module.
Now it's up to you to adjust the library code accordingly.
 
Upvote 0
Solution

Theera

Expert
Licensed User
Longtime User
ใน B4J คุณสามารถใช้คุณสมบัติสไตล์ CSS เพื่อตั้งค่าแบบอักษรได้
[รหัส=b4x]' B4XSwfButton1.Font=แบบอักษรของฉัน
' B4XSwfButton1.TextSize=24
#ถ้า B4J
'https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#typefont
' แต่ละทรัพย์สินแยกกัน
CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-style","ตัวเอียง")
CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-weight","ตัวหนา")
CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-size",20)
CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font-family","Monospace")
' หรือในสตริงคุณสมบัติย่อหนึ่งรายการ (ใส่การตั้งค่าคุณสมบัติแยกกัน 4 รายการในความคิดเห็น)
' CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font","ตัวเอียงหนา 20 โมโนสเปซ")
' ถ้ามีแบบอักษรพิเศษในระบบก็ควรจะใช้งานได้เช่นกัน
' CSSUtils.SetStyleProperty(B4XSwfButton1.xLBL,"-fx-font","ตัวเอียงหนา 20 playpensansthai-extrabold")
#สิ้นสุดถ้า[/CODE]
การทดสอบนี้ทำในโมดูล B4XMainPage
ตอนนี้ขึ้นอยู่กับคุณที่จะปรับรหัสห้องสมุดให้เหมาะสม
ฉันเพิ่งเจอโค้ดของผู้เชี่ยวชาญที่เหมือนกับกลยุทธ์ของคุณ ขอบคุณนะ พอลเมอริส

โพสต์ในกระทู้ '[B4X] [XUI] AutoTextSizeLabel' https://www.b4x.com/android/forum/threads/b4x-xui-autotextsizelabel.100187/post-645021
 
Upvote 0
Top