Brickley Roscowicz Engineering

Brickley Roscowicz Engineering


txt2dat Print E-mail

This is a utility I wrote basically to be able to produce virtual stickers for my LDraw models. It allows you to choose any scalable typeface, and create a LDraw file containing a representation of any string in that typeface.

This is currently beta software. Use it at your own risk. Please send any comments/suggestions/bugs to This e-mail address is being protected from spambots. You need JavaScript enabled to view it .


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


By default, txt2dat produces a box oriented as per the LDraw Official Library Standard for Sticker Parts. Many attributes of the final LDraw object can be adjusted, using the options below.

By default, the LDraw commands are output to stdout, and all other output is to stderr, so the LDraw file can be captured by re-directing stdout to a file. As of version 0.2.0, the output can also be sent to a file using the -o option.

  • Mac binaries available courtesy of Jim DeVona.
VersionWindows/DOS1Linux2 Mac3 Source
0.2.3 (latest) Download Download Download Download
0.2.2 Download Download Download Download
0.2.1 Download Download Download Download
0.2.0 Download Download Download Download
0.1.6 Download N/A N/A Download
0.1.4 Download N/A N/A Download
0.1.3 Download N/A N/A Download
0.1.2 Download N/A N/A N/A
  1. Windows binary built and tested on Windows 7 using:
    - MinGW 5.1.6
    - Msys 1.0
  2. Linux binary tested on:
    - Linux web host running kernel 2.6.28
    - AMD-K6 running Debian (Etch), kernel 2.6.18
  3. Mac universal binary tested on
    - Core Duo MacBook with Mac OS X 10.6.2

Usage: txt2dat [options] [fontfile]

-a

Add an ASCII character to the output.
Characters are added in the order they appear on the command line.

-b

Specify standard LDraw background colour or - for transparent.
Default background colour is 15 (white).

-c

Specify standard LDraw font colour or - for transparent.
Default font colour is 0 (black).

-d

Specify part description line. This is output as a comment on the first line.
Default is "Sticker file".

-e

Specify error log file. All error information will go to this file.
Default is stderr.

-f

Specify part filename. This is output as a "0 FILE " line. This is for information only - the file will NOT be created.
Default is "sticker.dat".

-g

Draw edges on glyphs. Only if either -b- or -c- (not both) is used.

-h

Specify height of bounding box (in LDU).
Default height is least multiple of 8 LDU (one plate) greater than total height of characters.
The font baseline will be on the x axis.

-k

Kern glyph pairs.

-l

Don't draw edge lines on glyphs or bounding box.

-m

Specify minimum angle between segments for non-conditional line. This is only used with the -g option, must be 0 <= A < 90. Default is 10 degrees.

-o

Specify output file. All LDraw output will go to this file. Overrides -f if specified.
Default is stdout.

-p

Specify point size for text.
Default point size is 12.

-r

Spline Resolution. Must be 0 or greater.
0 = Best guess (default)
1 = Maximum
>1 = Reduces resolution.

-s

Add a string of characters to the output.
Characters are added in the order they appear on the command line.

-w

Specify width of bounding box (in LDU).
Default width is least multiple of 20 LDU (one stud) greater than total width of characters.
The text will be centred in the bounding box, and about the z axis

-x

Don't create bounding box.

-D

Specify debug level (Only available when compiled from source).
Default is 3.

fontfile

The full path to an existing scalable font file. If not supplied, the default internal font will be used.


Example:

txt2dat -s Hello -c 4 -p 72 c:\windows\fonts\arial.ttf >hello.dat

Produces the file "hello.dat" containing the string "Hello" in red 72 point Arial on a white background.

Image


Notes:

  1. Using the transparent option for colours (eg: -b -) is not the same as choosing trans white (colour 47). The latter produces triangles of colour 47 which will be rendered by your viewer, the former produces no triangles at all.
  2. The default internal font doesn't include any kerning information, so the -k option will make no difference when using that font.
  3. ASCII characters (-a) are specified one at a time as decimal numbers, eg: -a 67 -a 65
  4. I don't recommend using anything other than the default (-r 0) for spline resolution. In particular, using the maximum setting (-r 1) can consume very large amounts of memory.

Jim DeVona has now created an online version of txt2dat. You can control almost every txt2dat option, including font size and color. It is also possible to upload your own font. Just enter some text and click a button to download an LDraw “sticker” part with that text stamped right on it. You can find Jim's page here. Note I have nothing to do with that program - please contact Jim for any information!


Anders Isaksson has written a quick little Windows graphical front end for txt2dat, called quitx2d. You can read about it here, and download it here. Note I have nothing to do with that program - please contact Anders for any information!


Don Heyse also whipped up a quick TCL / Tk graphical front end - you can read about it here. Note I have nothing to do with that program - please contact Don for any information!