To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.devOpen lugnet.cad.dev in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / 10226
Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Fri, 29 Apr 2005 12:55:04 GMT
Viewed: 
4035 times
  
In lugnet.cad.dev, Ross Crawford wrote:
In lugnet.cad.dev, Don Heyse wrote:
In lugnet.cad.dev, Ross Crawford wrote:
Hi all,

I've just uploaded the first beta version of txt2dat, a command-line
program to create LDraw files from text. It has been developed using
cygwin and mingw on Windows XP, and has not been fully tested in any
other environments.

You can download it
<http://www.br-eng.info/about/lego/LDraw/txt2dat/index.htm here>.
If you wanna give it a go, and let me know if you can get it to work,
please feel free.

Wow, that's cool!  LDRAW stuff sent to stdout.  I finally get to
try ldglite with a pipe from a real program, and it all seems to
work.

  txt2dat -s hello -c 4 -p 72 c:\windows\fonts\ariel.ttf | ldglite -i1
-MFhello.png --

Thanks.  That was fun,

Nuthin like a good ol' command line utility ;) though I wouldn't be
adverse to someone creating a nice graphical interface - working out
which font file to use is a bit of a pain sometimes...

Yeah, I was gonna suggest you convert the "font" from the ldraw
lettered tiles into a cheesy builtin internal font, which would be
used by default.  Then add a -f before the font if you can find a
better one somewhere.  That way you could make something without
searching around for fonts.

But for a really cheesy GUI you could probably write a 10 line tcl
script that opens a file browser and lets you select a font file
then run something like the command line above, except skip the
-MFhello.png and let ldglite open a small window with the txt2dat
output in it.

  txt2dat -s AbCdEfG -c4 -p72 ariel.ttf | ldglite -v0 -- >NULL

Now where did I put that little tcl script for lpub...

Have funk,

Don


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Fri, 29 Apr 2005 14:57:03 GMT
Viewed: 
4277 times
  
In lugnet.cad.dev, Don Heyse wrote:
In lugnet.cad.dev, Ross Crawford wrote:
In lugnet.cad.dev, Don Heyse wrote:
In lugnet.cad.dev, Ross Crawford wrote:
Hi all,


<snip>


But for a really cheesy GUI you could probably write a 10 line tcl
script that opens a file browser and lets you select a font file
then run something like the command line above, except skip the
-MFhello.png and let ldglite open a small window with the txt2dat
output in it.

  txt2dat -s AbCdEfG -c4 -p72 ariel.ttf | ldglite -v0 -- >NULL

Now where did I put that little tcl script for lpub...

ahhh..... ummm.... LSynth?

LPub has its own built in cheezy little GUI!


Have funk,

Don

K


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Fri, 29 Apr 2005 15:48:01 GMT
Viewed: 
4646 times
  
In lugnet.cad.dev, Kevin L. Clague wrote:
In lugnet.cad.dev, Don Heyse wrote:
But for a really cheesy GUI you could probably write a 10 line tcl
script that opens a file browser and lets you select a font file
then run something like the command line above, except skip the
-MFhello.png and let ldglite open a small window with the txt2dat
output in it.

  txt2dat -s AbCdEfG -c4 -p72 ariel.ttf | ldglite -v0 -- >NULL

Now where did I put that little tcl script for lpub...

ahhh..... ummm.... LSynth?

LPub has its own built in cheezy little GUI!

Err... yeah, lsynth.  That's why I couldn't find it.  So now
that I found it it looks a bit more than 10 lines.  Oops.

Anyhow, substitute txt2dat for lsynth, make a few little
additions and ya get a cheesy GUI for txt2dat that sorta works.

Enjoy,

Don


#!/bin/sh
#-*-tcl-*-
# the next line restarts using wish \
exec wish "$0" -- ${1+"$@"}

#
# Tk GUI for txt2dat
#

# wm withdraw .
wm title . "txt2dat - Create LDraw files from text"

set rootdir $env(SystemRoot)
set fontdir $rootdir/fonts
set stickertext " "
set fontfile ""
set outfile ""
set color "\-c 4"
set pointsize "\-p 72"

set types {
    {{Font Files}       {.ttf}        }
    {{All Files}        *             }
}


proc BrowseIF {} {
    global fontfile fontdir types
    set fontfile [tk_getOpenFile -initialdir $fontdir -filetypes $types
-defaultextension ttf -initialfile arial.ttf]
    if {$fontfile != ""} {
set fontdir $fontfile
    }
}

proc BrowseOF {} {
    global outfile fontdir
    set outfile [tk_getSaveFile -initialdir $outfile]
}

proc Synthesize {} {
    global stickertext fontfile fontdir outfile color pointsize log
    if {$outfile != ""} {
      if [catch {set n [exec txt2dat "\-s" $stickertext $fontfile > $outfile]}
input] {
        $log insert end $input\n
      } else {
        $log insert end OK $n\n
      }
    } else {
      if [catch {set n [exec txt2dat "\-s" $stickertext $fontfile]} input] {
        $log insert end $input\n
      } else {
        $log insert end OK $n\n
      }
    }
}

frame .f -borderwidth 10
pack .f -side top

frame .f.row6
pack .f.row6 -side top -anchor w
label .f.row6.li -text "Sticker Text"
pack .f.row6.li -side left

frame .f.row7
pack .f.row7 -side top -fill y
entry .f.row7.inf -width 60 -relief sunken -textvariable stickertext
pack .f.row7.inf -side left

frame .f.row0
pack .f.row0 -side top -anchor w
label .f.row0.li -text "Font File"
pack .f.row0.li -side left

frame .f.row1
pack .f.row1 -side top -fill y
entry .f.row1.inf -width 60 -relief sunken -textvariable fontfile
button .f.row1.browseFontFile -text "Browse" -command {BrowseIF}
pack .f.row1.inf .f.row1.browseFontFile -side left

frame .f.row2
pack .f.row2 -side top -anchor w
label .f.row2.lo -text "Output File"
pack .f.row2.lo -side left

frame .f.row3
pack .f.row3 -side top -fill y
entry .f.row3.of -width 60 -relief sunken -textvariable outfile
button .f.row3.browseOutFile -text "Browse" -command {BrowseOF}
pack .f.row3.of .f.row3.browseOutFile -side left

frame .f.row4 -borderwidth 10
pack .f.row4 -side top -fill y
button .f.row4.synthesize -text "Process" -command {Synthesize}
pack .f.row4.synthesize -side top

frame .f.row5
pack .f.row5 -side top -fill y
set log [text .f.row5.log -width 80 -height 20 \
    -borderwidth 2 -relief raised -setgrid true \
    -yscrollcommand {.f.row5.scroll set}]
scrollbar .f.row5.scroll -command {.f.row5.log yview}
pack .f.row5.scroll -side right -fill both -expand true
pack .f.row5.log -side top -fill both -expand true

$log insert end "Welcome to txt2dat, a text sticker generator for LDRAW."
$log insert end \n
$log insert end \n


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Fri, 29 Apr 2005 23:14:15 GMT
Viewed: 
4113 times
  
In lugnet.cad.dev, Don Heyse wrote:

Yeah, I was gonna suggest you convert the "font" from the ldraw
lettered tiles into a cheesy builtin internal font, which would be
used by default.  Then add a -f before the font if you can find a
better one somewhere.  That way you could make something without
searching around for fonts.

All we need to generate the cheesy LEGO font file is an output-truetype module
for autotrace, and a ready supply of lettered tiles ;)

ROSCO


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Sat, 30 Apr 2005 02:34:04 GMT
Viewed: 
4140 times
  
In lugnet.cad.dev, Ross Crawford wrote:
In lugnet.cad.dev, Don Heyse wrote:

Yeah, I was gonna suggest you convert the "font" from the ldraw
lettered tiles into a cheesy builtin internal font, which would be
used by default.  Then add a -f before the font if you can find a
better one somewhere.  That way you could make something without
searching around for fonts.

All we need to generate the cheesy LEGO font file is an output-truetype
module for autotrace,

That's not too hard to find.

  http://www.xs4all.nl/~hanwen/mftrace/

Looks like a wrapper for autotrace and some other stuff.

and a ready supply of lettered tiles ;)

Yeah, you got me there.  I think I've got a couple a numbers from
the harry potter house sets, and that's about it.

Yer more likely to get the whole alphabet by assmembling it in MLCad
from the ldraw tiles.  Then you can always dump a large bitmap to feed
to mftrace.  Just pretend you scanned in the real tiles...

Don


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Sat, 30 Apr 2005 07:58:57 GMT
Viewed: 
4145 times
  
In lugnet.cad.dev, Don Heyse wrote:
In lugnet.cad.dev, Ross Crawford wrote:
In lugnet.cad.dev, Don Heyse wrote:

Yeah, I was gonna suggest you convert the "font" from the ldraw
lettered tiles into a cheesy builtin internal font, which would be
used by default.  Then add a -f before the font if you can find a
better one somewhere.  That way you could make something without
searching around for fonts.

All we need to generate the cheesy LEGO font file is an output-truetype
module for autotrace,

That's not too hard to find.

  http://www.xs4all.nl/~hanwen/mftrace/

Looks like a wrapper for autotrace and some other stuff.

and a ready supply of lettered tiles ;)

Yeah, you got me there.  I think I've got a couple a numbers from
the harry potter house sets, and that's about it.

Yer more likely to get the whole alphabet by assmembling it in MLCad
from the ldraw tiles.  Then you can always dump a large bitmap to feed
to mftrace.  Just pretend you scanned in the real tiles...

Actually, looking at the brick 1x1s with letters in LDraw, it should be possible
to generate glyphs straight from the DAT files. Then it's just a matter of
packaging them up nicely in a font file, saves having to convert it to a bitmap
& back.

Notice I said "possible" not "easy"...

ROSCO


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Mon, 9 May 2005 04:24:16 GMT
Viewed: 
3883 times
  
In lugnet.cad.dev, Don Heyse wrote:

Yeah, I was gonna suggest you convert the "font" from the ldraw
lettered tiles into a cheesy builtin internal font, which would be
used by default.  Then add a -f before the font if you can find a
better one somewhere.  That way you could make something without
searching around for fonts.

Your wish is my command... well almost.

http://www.br-eng.info/words/?p=7

ROSCO


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Mon, 9 May 2005 14:25:05 GMT
Viewed: 
4086 times
  
In lugnet.cad.dev, Ross Crawford wrote:
   In lugnet.cad.dev, Don Heyse wrote:
  
Yeah, I was gonna suggest you convert the “font” from the ldraw lettered tiles into a cheesy builtin internal font, which would be used by default. Then add a -f before the font if you can find a better one somewhere. That way you could make something without searching around for fonts.

Your wish is my command... well almost.

http://www.br-eng.info/words/?p=7

Very nice! That font looks better than I remember. How’d you coerce it into TrueType format?

Always one to push my luck, I do have two little quibbles. I liked the way version 1.4 printed the usage info when running txt2dat with no args. Now it prints a weird error message.

Also, the internal default font does not seem to contain the space character, despite what it says on the website and in the readme.txt file. Instead I get this.

Warning: No font specified - Using internal default.

Warning: Char 32 has no glyph in font - ignoring...

Maybe I’m using the wrong character for space?

Oh, and by the way, I managed to build 1.4 on Redhat 9. Here’s a snapshot of it running in the cheesy tcl gui. You’ll have to pretend not to see the XP Window decorations. The redhat box was headless, so I displayed it via the Cygwin X server. The only trouble I had building (other than figuring out where to put Triangle and Freetype) was with $MATH. It gets defined to -lm but it’s never used by the linker. I had to add it by hand to the linker options.

Have fun,

Don


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Mon, 9 May 2005 23:04:49 GMT
Viewed: 
4058 times
  
In lugnet.cad.dev, Don Heyse wrote:
   In lugnet.cad.dev, Ross Crawford wrote:
   In lugnet.cad.dev, Don Heyse wrote:
  
Yeah, I was gonna suggest you convert the “font” from the ldraw lettered tiles into a cheesy builtin internal font, which would be used by default. Then add a -f before the font if you can find a better one somewhere. That way you could make something without searching around for fonts.

Your wish is my command... well almost.

http://www.br-eng.info/words/?p=7

Very nice! That font looks better than I remember. How’d you coerce it into TrueType format?

Well I worked out the scale factor, and imported the DATs into an Access db (some had to have some stuff inlined first) then manually went through the polygons working out all the verteces and entered them directly using Font Creator.

   Always one to push my luck, I do have two little quibbles. I liked the way version 1.4 printed the usage info when running txt2dat with no args. Now it prints a weird error message.

Ahhhhh. That’s because before it knew there was an error if no font was specified. Now it just assumes the internal font, then complains because you didn’t enter any characters to convert. I’ll fix that.

   Also, the internal default font does not seem to contain the space character, despite what it says on the website and in the readme.txt file. Instead I get this.

Warning: No font specified - Using internal default.

Warning: Char 32 has no glyph in font - ignoring...

Maybe I’m using the wrong character for space?

Uh oh. That second bug that I “fixed” in this version, I didn’t test with space. The space char (which has no associated glyph) has to still be mapped as a valid char by freetype - I will try to figure out how to fix it.

   Oh, and by the way, I managed to build 1.4 on Redhat 9. Here’s a snapshot of it running in the cheesy tcl gui. You’ll have to pretend not to see the XP Window decorations. The redhat box was headless, so I displayed it via the Cygwin X server. The only trouble I had building (other than figuring out where to put Triangle and Freetype) was with $MATH. It gets defined to -lm but it’s never used by the linker. I had to add it by hand to the linker options.

The Makefile was basically butchered from the Freetype demos, because of the weird way Freetype does it’s platform independence. I will add $MATH to the link options.

ROSCO


Subject: 
Re: txt2dat - Create LDraw files from text
Newsgroups: 
lugnet.cad.dev
Date: 
Tue, 10 May 2005 02:02:30 GMT
Viewed: 
4466 times
  
In lugnet.cad.dev, Don Heyse wrote:
   In lugnet.cad.dev, Ross Crawford wrote:
   In lugnet.cad.dev, Don Heyse wrote:
  
Yeah, I was gonna suggest you convert the “font” from the ldraw lettered tiles into a cheesy builtin internal font, which would be used by default. Then add a -f before the font if you can find a better one somewhere. That way you could make something without searching around for fonts.

Your wish is my command... well almost.

http://www.br-eng.info/words/?p=7

OK I think I’ve fixed all THOSE bugs, now just time to find some more...

You can find it here.

ROSCO

PS: Does anyone want the brick.ttf font? It’s not really very useful because of the limited characters, but if anyone wants it, I’ll make a separate download page for it.


©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR