Author Topic: Text to G-code?  (Read 8607 times)

Offline geoff_p

  • Jr. Member
  • **
  • Posts: 49
  • Country: th
Text to G-code?
« on: January 14, 2015, 11:57:12 PM »
I want to engrave some nameplates for my Thai friends.

I have DesKam's DeskEngrave, which does a decent-enough job for Western texts in almost all True-Type Fonts.  But sadly it falls down when the text is not Western, so "Hello World" is good but "สวัสดีชาวโลก" (Thai for Hello World) comes out as "????????????"

Can you suggest a one-stop converter, please?

I really don't want to embed the text in a drawing program (which I don't have) to output DXF, which I can put into a DXF-translator (which I don't have) to be written into a script for the Rasberry Pi (which I don't have) which can be sideloaded to an Arduino-running-GRBL (which I DO have.) (With apologies to Dawai who I think enjoys complexity.)

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #1 on: January 15, 2015, 07:46:14 AM »
Well I'd first separate your software conversion needs from a discussion of hardware or other people's projects if you want to solve the problem efficiently.

And a one-stop converter for Thai text to G-code, only? No work-around solutions allowed? Good luck.

I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #2 on: January 15, 2015, 08:08:03 AM »
Also, why won't your Deskengrave handle it? It supposedly accepts TrueType fonts. Are Thai fonts unavailable as TrueType?


Edit:

Here's one.

http://www.thai-language.com/downloads/dbtt.ttf
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline philf

  • Hero Member
  • *****
  • Posts: 1107
  • Country: gb
Re: Text to G-code?
« Reply #3 on: January 15, 2015, 08:19:55 AM »
Geoff,

Have a look at the free F-Engrave: http://www.scorchworks.com/Fengrave/fengrave.html

I use their free g code ripper programme which is excellent and doesn't require installation - it just runs from an executable.

Cheers.

Phil.
Phil Fern
Location: Marple, Cheshire

Offline geoff_p

  • Jr. Member
  • **
  • Posts: 49
  • Country: th
Re: Text to G-code?
« Reply #4 on: January 15, 2015, 11:42:41 AM »
VTSteam, there are plenty of TT-fonts for the Thai character set.  AngsanaUPC, BrowalliaUPC and CordiaUPC are just the first three to come to mind:  these are recognised by DeskEngrave, and work just like any others on Western texts.  DeskEngrave seems to work well with ASCII-codes up to 255 - have a look at various fonts using Windows Character Map and notice that, after 'no-break space' (0xFF)(U+00A0) the table is blank.

If you now choose a different character-set (but with the same font) the blanks get filled-in.  (Kor Kai, the first letter of the Thai alphabet, literally an Egg) is displayed (U+0E01)(0xA1)

I think DeskEngrave was probably not designed to accept the more modern 3- and 4-digit character sets.  I have tried making up some mixed text via Character Map, copying and pasting it into DeskEngrave - results in '??A?B??'

On your last point.  No it's not for just Thai to G-code.  It could equally be Yiddish or Arabic or Chinese.

Phil.  Thanks, I'm trying it just now.

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #5 on: January 15, 2015, 12:02:19 PM »
I've spent the morning trying to find a solution to your problem, Geoff. I use linux, so can't speak from a Windows perspective. I did notice that there were plenty of Thai ttl fonts, and that the fonts themselves were above 163. I did try F-engrave in WINE and had the same result coming from TTL as in Deskengrave. The ripping from graphic process was one I ddn't try because you specifically eschewed working through graphics in the first post. There are probably plenty of workarounds if you go graphic transfer, but that wasn't what you asked for.
« Last Edit: January 15, 2015, 01:14:48 PM by vtsteam »
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #6 on: January 15, 2015, 12:21:28 PM »
Seems to me that the problem might be solved if you tried a font that mapped the Thai characters to the lower ASCII range. I think there may be some out there.......
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #7 on: January 15, 2015, 01:04:19 PM »
I've just re-mapped a few characters indbtt.ttf to see whether it could be done and here's the result in DeskEngrave:

I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline philf

  • Hero Member
  • *****
  • Posts: 1107
  • Country: gb
Re: Text to G-code?
« Reply #8 on: January 15, 2015, 01:52:29 PM »
Hi again Geoff,

I've just tried a Thai font in Vectric Cut 2d and it seems to cope well with some random characters I copied from character map.



Of no use if you haven't got Cut 2d but it shows it can be done with the right software. I hope my random characters don't spell out anything bad!

Phil.
« Last Edit: July 13, 2017, 01:25:31 PM by philf »
Phil Fern
Location: Marple, Cheshire

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #9 on: January 15, 2015, 02:15:11 PM »
Okay, I've done a full substitution of Thai glyphs for the English glyphs in the low ASCIIs, creating a new typeface (attached).

You should be able to run this in Deskengrave -- the only slight hiccup is you will see the English letters in the input line, but the output window and g-code resulting will be Thai.

Ps. you need to be using the English keyboard when typing the Thai characters into the Deskengrave program -- at least I did. Shouldn't be a problem if you touch type, or have keyboard stickers in place.
« Last Edit: January 15, 2015, 08:11:40 PM by vtsteam »
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline RussellT

  • Hero Member
  • *****
  • Posts: 520
  • Country: gb
Re: Text to G-code?
« Reply #10 on: January 16, 2015, 05:44:08 AM »
 :clap: :clap:
Common sense is unfortunately not as common as its name suggests.

Offline geoff_p

  • Jr. Member
  • **
  • Posts: 49
  • Country: th
Re: Text to G-code?
« Reply #11 on: January 21, 2015, 02:02:36 AM »
Many, many thanks, VT.  A brilliant piece of work  :beer:

Now about this Urdu ....

I have to find the Thai characters the hard way - searching up and down and across my keyboard.  which ain't made any easier by the thickness of crud on the keys.  But I'm sure my Thai pals will know where their letters are, just as we know QWERTY etc.

When I've 'just done this next mod' to my mill, I'll give your work a try, so as to show it to my friends.

Meantime, I echo RussellT's sentiment  :clap:  :clap:

Geoff

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #12 on: January 21, 2015, 03:11:48 PM »
Happy to help Geoff.

I've read about Thai keyboard stickers you can place over the keys.

But maybe you can make them yourself? Maybe a print-out on label paper, and then cut them out?

I don't know how frequently you will need them though -- if this is a small job, probably wouldn't be worthwhile to make them.
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline Swarfing

  • Sr. Member
  • ****
  • Posts: 417
  • Country: gb
Re: Text to G-code?
« Reply #13 on: January 21, 2015, 03:46:27 PM »
Only just read this thread and there is something that has not been mentioned. Where the fonts installed (assuming windoze OS)? Just copying the font files across is not enough. Right click them and install is needed which may (I use Linux exclusively) be the problem they are seen as '?????' if the cam software is looking at Windoze for the font mapping?
 just a thought
Once in hole stop digging.

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Text to G-code?
« Reply #14 on: January 21, 2015, 03:59:17 PM »
Swarfing, I use Linux, too, and I did a lot of checking running fonts in X and Wine, and in the usual Windows directories. I got the same results as Geoff no matter where they are put.

The program appears to use a different on-screen font for input display than the working font used to generate the G-code (the Thai font). It then examines the input window and applies what it finds to the working font.

So what happens is, using a Thai font and shifting to a Thai keyboard doesn't work because the program display font doesn't have characters in the high range. So it outputs question marks.

Then the conversion process uses those literal input line characters (question marks) to look up how to display the output, and build the G-code. Since all the characters it looks up are the question marks it finds in the input line it does a perfect G-code program for a bunch of question marks. The Thai font, actually has English characters in the low ASCII range, and so there is no problem outputting question marks.

I just moved the Thai characters to the low range. Because the input must be English, always, you have to use the English keyboard (or you'll get question marks again), and the input line will then be English characters. BUT when it goes to do the G-code it looks to the lower range again to output these characters, but finds in their place (and works with) the Thai characters we substituted. Since they were kept in order, they should (I hope) correspond with their usual position on the keyboard on a Thai computer.
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline Swarfing

  • Sr. Member
  • ****
  • Posts: 417
  • Country: gb
Re: Text to G-code?
« Reply #15 on: January 21, 2015, 04:18:39 PM »
vsteam i now understand what you were referring to. Another option with weird fonts is to import ASCII points via cad. I use Librecad (free) and i believe you can do the same with Qcad (same engine under the hood) which is available on windows (there is free version if you look for it). Ok it is extra steps but not a lot really.
Once in hole stop digging.