Hi, I need to create an app that transforms texts into GCodes. Example:
Can someone help me?
Thank you
Can someone help me?
Thank you
The last photo on the right is part of a polymer extrusion die....?
Ilan,
See the google store app "Text to CNC".
I have read some articles that talk about manipulating TTF fonts or "engraving fonts" and I think that is the way. Would you or anyone here from the fourm help me with any code? I have no idea how to do this.
Does B4A have any library for manipulating TTF fonts?
i have a solution
How are you planning to get the kerning pairs? Or are you planning on using only monospaced fonts?
Another relevant example: https://www.b4x.com/android/forum/threads/b4x-xui-minisearchview-autocomplete-field.93564/#content
The characters are manually drawn as there is no "CSBuilder" in B4J. It is not 100% perfect. There are some inaccuracies mostly with space characters.
I'm curious, can you also produce a screenshot of the word VAN, all caps? Preferably large size.
Sub measureTextWidth(Text As String, font As Font) As Float
Dim lbl As Label
lbl.Initialize("")
lbl.Text = Text
lbl.Font = font
MainForm.RootPane.AddNode(lbl,0,0,-1,-1)
lbl.Snapshot
lbl.RemoveNodeFromParent
Return lbl.Width
End Sub
Sub measureTextWidth(Text As String, font As Font) As Float
Dim cnx As B4XCanvas
cnx.Initialize(MainForm.RootPane)
Return cnx.MeasureText(Text, font).Width
' Dim lbl As Label
' lbl.Initialize("")
' lbl.Text = Text
' lbl.Font = font
' MainForm.RootPane.AddNode(lbl,0,0,-1,-1)
' lbl.Snapshot
' lbl.RemoveNodeFromParent
' Return lbl.Width
End Sub
i had to get my revenge
Of course, I would expect nothing less!
The lack of kerning is visible in both pics, the last one most. Looking forward to seeing the magic method you will be using to solve that.
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
Dim cvs As B4XCanvas
cvs.Initialize(Pane1)
Dim fnt As Font = jFX.CreateFont("Segoe Script", 150, False, False)
DrawTextWithBorder(cvs, "VAN", fnt, xui.Color_Red, Pane1.Width / 2, Pane1.Height / 2)
cvs.Invalidate
End Sub
I'm not exactly sure what you are measuring. DrawTextWithBorder seems to be accurate with this font:
Kerning is the space between individual characters. As each character can be followed by many different characters, there needs to be a lookup table with all the combinations. This is called kerning pairs, and it's something that typographers spend many, many hours perfecting for each typeface.