discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Is multiline text in bounding box possible?

TP
Torsten Paul
Sat, Mar 28, 2020 6:03 PM

On 28.03.20 17:25, Jordan Brown wrote:

Maybe I wasn't clear - maybe I let my pronouns be
poorly bound.  I was saying that my comment about
the difficulty of determining the bounding box of> an intersection was not relevant to the OP question
of flowing text into a given area.

Maybe I misread. So how about I'll try with a summary?


  1. Can we automatically wrap text into a given area?

-> Yes, but this needs additional data extracted from
the fonts separately as OpenSCAD currently does not
provide this data via a built-in command.
Better support would need to include some kind of
layout framework into OpenSCAD (e.g. Pango).

lar3ry posted links to code that does this and comes
with a data file for a number of fonts:

http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28696.html
https://www.thingiverse.com/thing:3004457
https://github.com/arpruss/miscellaneous-scad

-> There's no need to query geometry for this feature,
what's needed is to query font data. Similar functions
for DXF already exist (dxf_cross(), dxf_dim()). This
could be provided by means of a data structure returned
from text() in function context (data = text("Hello");).
The object-literals PR is initial work to implement the
core feature making that possible.


  1. Can we generate a model that fits the text bounding box?

-> Yes, Ronaldo pointed to a nice script on the Tips&Tricks
page:

http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28707.html
https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks

That does still not allow to get the actual values, so
it might not cover all scenarios but it does allow to
generate geometry that fits around the text.


  1. Can we query the geometry to get the values of the
    bounding box?

-> No, probably not anytime soon as it's not fitting well
with the declarative nature of OpenSCAD

Who knows, maybe it will happen at some point (I hope it
does). But it will require some extra work to fit into
the existing architecture.


ciao,
Torsten.

On 28.03.20 17:25, Jordan Brown wrote: > Maybe I wasn't clear - maybe I let my pronouns be > poorly bound.  I was saying that my comment about > the difficulty of determining the bounding box of> an intersection was not relevant to the OP question > of flowing text into a given area. Maybe I misread. So how about I'll try with a summary? ----------------------------------------------------------- 1) Can we automatically wrap text into a given area? -> Yes, but this needs additional data extracted from the fonts separately as OpenSCAD currently does not provide this data via a built-in command. Better support would need to include some kind of layout framework into OpenSCAD (e.g. Pango). lar3ry posted links to code that does this and comes with a data file for a number of fonts: http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28696.html https://www.thingiverse.com/thing:3004457 https://github.com/arpruss/miscellaneous-scad -> There's no need to query geometry for this feature, what's needed is to query font data. Similar functions for DXF already exist (dxf_cross(), dxf_dim()). This could be provided by means of a data structure returned from text() in function context (data = text("Hello");). The object-literals PR is initial work to implement the core feature making that possible. ----------------------------------------------------------- 2) Can we generate a model that fits the text bounding box? -> Yes, Ronaldo pointed to a nice script on the Tips&Tricks page: http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28707.html https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks That does still not allow to get the actual values, so it might not cover all scenarios but it does allow to generate geometry that fits around the text. ----------------------------------------------------------- 3) Can we query the geometry to get the values of the bounding box? -> No, probably not anytime soon as it's not fitting well with the declarative nature of OpenSCAD Who knows, maybe it will happen at some point (I hope it does). But it will require some extra work to fit into the existing architecture. ----------------------------------------------------------- ciao, Torsten.
JB
Jordan Brown
Sun, Mar 29, 2020 3:29 PM

We are on the same page.  Minor comments below.

On 3/28/2020 11:03 AM, Torsten Paul wrote:

  1. Can we automatically wrap text into a given area?
    -> Yes, but this needs additional data extracted from
    the fonts separately as OpenSCAD currently does not
    provide this data via a built-in command.
    Better support would need to include some kind of
    layout framework into OpenSCAD (e.g. Pango).

Yes.  The first step would be to export text metrics; that would allow
the user to implement flowing.

OpenSCAD itself could implement flowing, but it seems like it would be
very far down the priority list, mostly because it can turn into an
enormously complex topic.

-> There's no need to query geometry for this feature,
what's needed is to query font data. Similar functions
for DXF already exist (dxf_cross(), dxf_dim()). This
could be provided by means of a data structure returned
from text() in function context (data = text("Hello");).
The object-literals PR is initial work to implement the
core feature making that possible.

Yes.

  1. Can we generate a model that fits the text bounding box?

-> Yes, Ronaldo pointed to a nice script on the Tips&Tricks
page:

http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28707.html
https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks

That does still not allow to get the actual values, so
it might not cover all scenarios but it does allow to
generate geometry that fits around the text.

Yes.  But that's not what the OP was looking for.  (Note that the OP
wants to specify the text and the size of a box to fit it into, and
talks about "multiline text".)

  1. Can we query the geometry to get the values of the
    bounding box?

-> No, probably not anytime soon as it's not fitting well
with the declarative nature of OpenSCAD

Who knows, maybe it will happen at some point (I hope it
does). But it will require some extra work to fit into
the existing architecture.

Right.  Painful.

We are on the same page.  Minor comments below. On 3/28/2020 11:03 AM, Torsten Paul wrote: > 1) Can we automatically wrap text into a given area? > -> Yes, but this needs additional data extracted from > the fonts separately as OpenSCAD currently does not > provide this data via a built-in command. > Better support would need to include some kind of > layout framework into OpenSCAD (e.g. Pango). Yes.  The first step would be to export text metrics; that would allow the user to implement flowing. OpenSCAD itself could implement flowing, but it seems like it would be very far down the priority list, mostly because it can turn into an enormously complex topic. > -> There's no need to query geometry for this feature, > what's needed is to query font data. Similar functions > for DXF already exist (dxf_cross(), dxf_dim()). This > could be provided by means of a data structure returned > from text() in function context (data = text("Hello");). > The object-literals PR is initial work to implement the > core feature making that possible. Yes. > 2) Can we generate a model that fits the text bounding box? > > -> Yes, Ronaldo pointed to a nice script on the Tips&Tricks > page: > > http://forum.openscad.org/Is-multiline-text-in-bounding-box-possible-tp28690p28707.html > https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks > > That does still not allow to get the actual values, so > it might not cover all scenarios but it does allow to > generate geometry that fits around the text. Yes.  But that's not what the OP was looking for.  (Note that the OP wants to specify the text and the size of a box to fit it into, and talks about "multiline text".) > 3) Can we query the geometry to get the values of the > bounding box? > > -> No, probably not anytime soon as it's not fitting well > with the declarative nature of OpenSCAD > > Who knows, maybe it will happen at some point (I hope it > does). But it will require some extra work to fit into > the existing architecture. Right.  Painful.