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 / 10171
10170  |  10172
Subject: 
Re: TrueType font converter?
Newsgroups: 
lugnet.cad.dev
Date: 
Sat, 26 Feb 2005 14:34:12 GMT
Viewed: 
1867 times
  
In lugnet.cad.dev, Ross Crawford wrote:
Does anyone know of a utility to convert TT font glyphs to LDraw DATs? I would
be interested in looking at writing such a beast, if it hasn't already been
done. I'm looking at this to be able to create LDraw representations of custom
stickers.

Your best bet to get a quick result would probably be to look in
some 3D graphics libraries for OpenGL and find working code to
get a TT glyph out into a mesh model. Exporting a flat mesh model
to LDraw format yourself is not very difficult, but if you happen
to find a utility that writes 3DS files, I have a freshly written
converter from 3DS to LDR format that also handles optional lines
and outline edges correctly, if yo need that:

http://www.itn.liu.se/~stegu/lego/ase2dat


1. An algorithm to approximate 2-d bezier curves with line segments

Two methods are commonly used: either you just use a fixed amount
of steps and eveluate the curve at N points along each segment, or
you apply some error metric and state that the straight line segments
should nveer deviate more than some distance from the smooth curve.
Most 3D modeling software uses the fixed amount of steps method
for simplicity and polygon count consistency during deformations.
Good 2D rendering software like PostScript uses the adaptive method.
The fixed steps method creates many unnecessary line segments, but
is very simple to implement using only the definition of the Bezier
curve polynomials.

2. An algorithm for filling a closed curve with tris/quads

This is far from trivial, but a number of methods exist and can be found
in good computer graphics textbooks, or occasionally on the Internet:

http://www.cosy.sbg.ac.at/~held/projects/triang/triang.html
http://web.informatik.uni-bonn.de/I/GeomLab/Triangulation/index.html.en

No source code on either page, but "FIST", the first one, is,
explicitly available on request, and I'm sure the second author
would be willing to share his Java code if you ask him, it's
merely an implementation of a published algorithm for which he
gives the reference.
The first link handles polygons with holes correctly, the
second does not. FIST seems to be the ideal choice for
complex shapes like character outlines, and there is
working C++ source code available on request.

A very good summary of the theory behind triangulation,
and a few pracitical algorithms (no code, but lots of good
information) is on:

http://www.cs.ucsb.edu/~suri/cs235/Triangulation.pdf

Polygons with holes are not treated in that document,
but apart from that it is a very good summary.

  Good luck!



Message has 1 Reply:
  Re: TrueType font converter?
 
(...) Thanks Stefan, I have already written the basic code to export the glyph using the FreeType library. (...) Thanks for that info too - I have now found some refs on the net. (...) the hardest part of the problem, your references will help (...) (20 years ago, 26-Feb-05, to lugnet.cad.dev)

Message is in Reply To:
  TrueType font converter?
 
Does anyone know of a utility to convert TT font glyphs to LDraw DATs? I would be interested in looking at writing such a beast, if it hasn't already been done. I'm looking at this to be able to create LDraw representations of custom stickers. And (...) (20 years ago, 26-Feb-05, to lugnet.cad.dev)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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