Generation of modules for text

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Generation of modules for text

dpollard
Hi all,

I've been using openscad for a few weeks now, and it's great until I went to try and add text to an item, and could find very little! Over the past few days I've been putting some bits together, and I had a few queries about a few of the things I've been looking at, I haven't done any work with open source stuff before so this is all new!

Here's an overview of what I have so far:

MatLab side (Sorry if you don't have this, I'm unsure how to do image processing in other parts!)
- Generates polygon shapes from an image of a character, saving as module A() {}, module B() etc...
- So far done for Calibri and Consolas fonts, and can be done for more, but seeing what the reception for this is like first...

C++:
- String input
- Generates module output combining the right letter modules from the MatLab generated file with spacing

I've been thinking about two main things, and would appreciate some advice!
- At the moment I've been working with Calibri (as it's default on MS Paint), and the spacing is quite variable. Does anyone know the spacing between different letters based on letter width?
- Consolas also appears to work quite well
- Integrating with openSCAD - I'm not entirely sure how easy this is, I've not looked into this.

The source code and modules I've already generated can be found at:
https://github.com/davepollard/openSCAD_TextGenerator

Please let me know what the bugs are (there are probably a few) and any comments on how it can be improved?

Thanks for your help,

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Generation of modules for text

Kenneth Sloan
I use an embarrassingly crude method - which has the advantage of working:

a) use WORD to produce the text (complete control over fonts, etc.)
    <insert your favorite WYWIWYG program here>
b) take a screen shot
c) use ImageJ to process the image
        1) make binary
        2) (optional) edit to remove unwanted features, perhaps connect
           isolated pieces that need connecting; perhaps separate pieces that
           need separating
        3) use a custom plugin to check for (and repair) non-manifold bitmap
        4) use a custom plugin to convert the image to a 1-high solid and
           output .stl
        5) write a small OpenSCAD module to read in the .stl, scale and orient
           so that the text fits in a 1x1x1 volume
        6) uses of the text do their own positioning and scaling

It’s clunky - but it works.

The secondary advantage is that it works with any front end that can produce
a binary image.  It helps that I already had a robust STL class written in Java which
made the additional pain of implementing the two custom ImageJ plugins relatively
small.

Before anyone asks - it was just as easy to output .stl as it would have been to output
some 2D format and then extrude.  And…checking for (and repairing) non-manifold features
in the 2D bitmap turned out to be crucial.   Also, after doing it 3 wrong ways, I have found
that normalizing the text to fit in a standard 1x1x1 volume, in a standard orientation, is
very helpful.  [my 1x1x1 volume is centered on the Origin]  

NOT having to deal with yetAnotherFontPackage was also pleasant.

--
Kenneth Sloan
[hidden email]


On May 20, 2014, at 08:27 , dpollard <[hidden email]> wrote:

> Hi all,
>
> I've been using openscad for a few weeks now, and it's great until I went to
> try and add text to an item, and could find very little! Over the past few
> days I've been putting some bits together, and I had a few queries about a
> few of the things I've been looking at, I haven't done any work with open
> source stuff before so this is all new!
>
> Here's an overview of what I have so far:
>
> MatLab side (Sorry if you don't have this, I'm unsure how to do image
> processing in other parts!)
> - Generates polygon shapes from an image of a character, saving as module
> A() {}, module B() etc...
> - So far done for Calibri and Consolas fonts, and can be done for more, but
> seeing what the reception for this is like first...
>
> C++:
> - String input
> - Generates module output combining the right letter modules from the MatLab
> generated file with spacing
>
> I've been thinking about two main things, and would appreciate some advice!
> - At the moment I've been working with Calibri (as it's default on MS
> Paint), and the spacing is quite variable. Does anyone know the spacing
> between different letters based on letter width?
> - Consolas also appears to work quite well
> - Integrating with openSCAD - I'm not entirely sure how easy this is, I've
> not looked into this.
>
> The source code and modules I've already generated can be found at:
> https://github.com/davepollard/openSCAD_TextGenerator
>
> Please let me know what the bugs are (there are probably a few) and any
> comments on how it can be improved?
>
> Thanks for your help,
>
> Dave
>
>
>
> --
> View this message in context: http://forum.openscad.org/Generation-of-modules-for-text-tp8012.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Generation of modules for text

Jeff Senn-2
I did a hack for processing TTF fonts awhile ago which might be useful:

http://www.thingiverse.com/thing:96714

I had intended to go back an implement a 2D importer in OpenSCAD directly against freetype
but never did it.  The interesting part of this is not just the vectors for the text, but also the
glyph dimensions you get so you can do at least glyph-based layout directly in OpenSCAD.

There is a discussion of this (broader) topic here of historic interest:

http://forum.openscad.org/A-text-module-for-OpenSCAD-td5766.html

(I agree with Kenneth’s earlier prophesy: “the excellent is the enemy of the good”)

-Jas


On May 20, 2014, at 9:51 AM, Kenneth Sloan <[hidden email]> wrote:

> I use an embarrassingly crude method - which has the advantage of working:
>
> a) use WORD to produce the text (complete control over fonts, etc.)
>    <insert your favorite WYWIWYG program here>
> b) take a screen shot
> c) use ImageJ to process the image
> 1) make binary
> 2) (optional) edit to remove unwanted features, perhaps connect
>           isolated pieces that need connecting; perhaps separate pieces that
>   need separating
> 3) use a custom plugin to check for (and repair) non-manifold bitmap
> 4) use a custom plugin to convert the image to a 1-high solid and
>           output .stl
> 5) write a small OpenSCAD module to read in the .stl, scale and orient
>   so that the text fits in a 1x1x1 volume
> 6) uses of the text do their own positioning and scaling
>
> It’s clunky - but it works.
>
> The secondary advantage is that it works with any front end that can produce
> a binary image.  It helps that I already had a robust STL class written in Java which
> made the additional pain of implementing the two custom ImageJ plugins relatively
> small.
>
> Before anyone asks - it was just as easy to output .stl as it would have been to output
> some 2D format and then extrude.  And…checking for (and repairing) non-manifold features
> in the 2D bitmap turned out to be crucial.   Also, after doing it 3 wrong ways, I have found
> that normalizing the text to fit in a standard 1x1x1 volume, in a standard orientation, is
> very helpful.  [my 1x1x1 volume is centered on the Origin]  
>
> NOT having to deal with yetAnotherFontPackage was also pleasant.
>
> --
> Kenneth Sloan
> [hidden email]
>
>
> On May 20, 2014, at 08:27 , dpollard <[hidden email]> wrote:
>
>> Hi all,
>>
>> I've been using openscad for a few weeks now, and it's great until I went to
>> try and add text to an item, and could find very little! Over the past few
>> days I've been putting some bits together, and I had a few queries about a
>> few of the things I've been looking at, I haven't done any work with open
>> source stuff before so this is all new!
>>
>> Here's an overview of what I have so far:
>>
>> MatLab side (Sorry if you don't have this, I'm unsure how to do image
>> processing in other parts!)
>> - Generates polygon shapes from an image of a character, saving as module
>> A() {}, module B() etc...
>> - So far done for Calibri and Consolas fonts, and can be done for more, but
>> seeing what the reception for this is like first...
>>
>> C++:
>> - String input
>> - Generates module output combining the right letter modules from the MatLab
>> generated file with spacing
>>
>> I've been thinking about two main things, and would appreciate some advice!
>> - At the moment I've been working with Calibri (as it's default on MS
>> Paint), and the spacing is quite variable. Does anyone know the spacing
>> between different letters based on letter width?
>> - Consolas also appears to work quite well
>> - Integrating with openSCAD - I'm not entirely sure how easy this is, I've
>> not looked into this.
>>
>> The source code and modules I've already generated can be found at:
>> https://github.com/davepollard/openSCAD_TextGenerator
>>
>> Please let me know what the bugs are (there are probably a few) and any
>> comments on how it can be improved?
>>
>> Thanks for your help,
>>
>> Dave
>>
>>
>>
>> --
>> View this message in context: http://forum.openscad.org/Generation-of-modules-for-text-tp8012.html
>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>> _______________________________________________
>> OpenSCAD mailing list
>> [hidden email]
>> http://rocklinux.net/mailman/listinfo/openscad
>> http://openscad.org - https://flattr.com/thing/121566
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Generation of modules for text

tp3
Jeff Senn-2 wrote
There is a discussion of this (broader) topic here of historic interest:
http://forum.openscad.org/A-text-module-for-OpenSCAD-td5766.html
Why historic? It's almost ready to merge https://github.com/openscad/openscad/issues/512
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Generation of modules for text

Jeff Senn-2

On May 20, 2014, at 10:16 AM, tp3 <[hidden email]> wrote:

> Jeff Senn-2 wrote
>> There is a discussion of this (broader) topic here of historic interest:
>> http://forum.openscad.org/A-text-module-for-OpenSCAD-td5766.html
>
> Why historic? It's almost ready to merge

“Historic” because it’s the first time it was mentioned :-)

> https://github.com/openscad/openscad/issues/512

Excellent!  I see you are going to some trouble to minimize dependencies….nice.
(Sadly I have not had much time to follow OpenSCAD lately…)

>
>
>
>
> -----
> -- Torsten
> --
> View this message in context: http://forum.openscad.org/Generation-of-modules-for-text-tp8012p8015.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566