LDraw.org Discussion Forums

Full Version: txt2dat for unicode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there a tool like txt2dat but allows unicode characters?
(2020-05-07, 23:39)Orion Pobursky Wrote: [ -> ]Is there a tool like txt2dat but allows unicode characters?
None I know of... I use the character code I want to add with -a option:
eg. to get the ®
Code:
txt2dat -s "LEGO" -a 174 -s " House" -o house.dat -l -p 50 -h 80 -c 15 -b 0 Arial.ttf
After that... need to shrink to get superscript, but that's another story Wink
(2020-05-08, 9:56)Philippe Hurbain Wrote: [ -> ]None I know of... I use the character code I want to add with -a option:
eg. to get the ®
Code:
txt2dat -s "LEGO" -a 174 -s " House" -o house.dat -l -p 50 -h 80 -c 15 -b 0 Arial.ttf
After that... need to shrink to get superscript, but that's another story Wink

Note that in theory you can get a lot of characters generated this way by changing your Windows Code Page. I don't know off-hand how to do that, or if simply setting an environment variable can localize it to the command window where you're running txt2dat.

Side note: txt2dat appears to be gone from the internet.
(2020-05-09, 3:36)Travis Cobbs Wrote: [ -> ]Note that in theory you can get a lot of characters generated this way by changing your Windows Code Page. I don't know off-hand how to do that, or if simply setting an environment variable can localize it to the command window where you're running txt2dat.

You could use a font editor to get the needed characters in the 65-90 range in a modified custom font file.

my 2cts
(2020-05-09, 22:16)Roland Melkert Wrote: [ -> ]You could use a font editor to get the needed characters in the 65-90 range in a modified custom font file.

my 2cts

There's no ascii code. It's U-201C
(2020-05-09, 23:12)Orion Pobursky Wrote: [ -> ]There's no ascii code. It's U-201C

Font files have a character table, so with an editor (maybe fontforge ?) you can move whatever is at U-201C to e.g. 65.

Then use the modified (saved as) font file with txt2dat to let it render 'A' which is actually the U-201C character.
(2020-05-09, 23:16)Roland Melkert Wrote: [ -> ]maybe fontforge ?

It's very easy in font forge:
https://fontforge.org/en-US/

Just copy the glyph at 0x201c and paste it in an ascii character slot (e.g. the normal " one) so non unicode programs can use it anyway.
(2020-05-09, 23:36)Roland Melkert Wrote: [ -> ]It's very easy in font forge:
https://fontforge.org/en-US/

Just copy the glyph at 0x201c and paste it in an ascii character slot (e.g. the normal " one) so non unicode programs can use it anyway.

Oh. Ok. Cool. Thanks 👍
(2020-05-09, 23:12)Orion Pobursky Wrote: [ -> ]There's no ascii code. It's U-201C

That's character 147 in the default Windows code page in America (CP 1252, Windows Latin 1):

https://en.wikipedia.org/wiki/Windows-1252

So, -a 147 should produce that character without requiring any font editing.
(2020-05-09, 23:12)Orion Pobursky Wrote: [ -> ]There's no ascii code. It's U-201C
Note that I didn't talk of ASCII code... I explore the character table of the font I want to use till I find the glyph I need, and add the (decimal) code to txt2dat command line:
Code:
txt2dat -a 7682 -a 65210 -a 946 -a 1488 -a 9567 -o characters.dat -l -p 50 -h 120 -c 15 -b 0 Arial.ttf
[attachment=5203]
Gives this
[attachment=5204]
Pages: 1 2