discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

text getting wonky

BS
brian s
Fri, Nov 26, 2021 1:40 PM

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

[image: image.png]

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

--
Thank You

Brian V Schaule Jr
bschaulejr@gmail.com
443-243-1779

I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time. I am trying to write text partially around a cylinder. I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached. [image: image.png] Thank You *Brian V Schaule Jr* bschaulejr@gmail.com -- Thank You *Brian V Schaule Jr* bschaulejr@gmail.com 443-243-1779
T
Terry
Fri, Nov 26, 2021 2:46 PM

On Fri, 26 Nov 2021 08:40:59 -0500, you wrote:

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

[image: image.png]

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

Hi Brian,

I'm an OpenScad novice but, until one of the many resident experts comes along,
see if this helps. At a brief look it seems that you could edit 'Brian' in an
image editor to follow a circle of the specified diam (I use PaintShop Pro) and
convert it with the suggested script.

https://www.thingiverse.com/thing:1668883

Terry

On Fri, 26 Nov 2021 08:40:59 -0500, you wrote: >I am new to openscad, so if this is an obvious error I apologize for >wasting anyone's time. I am trying to write text partially around a >cylinder. I thought I worked through the code to do it, but some of the >letters are not sitting on the cylinder, and also the letter spacing is >inconsistent. Here is the code and screenshot of what I see. Code is >attached. > > >[image: image.png] > > > > >Thank You > >*Brian V Schaule Jr* >bschaulejr@gmail.com Hi Brian, I'm an OpenScad novice but, until one of the many resident experts comes along, see if this helps. At a brief look it seems that you could edit 'Brian' in an image editor to follow a circle of the specified diam (I use PaintShop Pro) and convert it with the suggested script. https://www.thingiverse.com/thing:1668883 Terry
AM
Adrian Mariano
Fri, Nov 26, 2021 2:48 PM

You have set valign to "center", so each letter is centered
vertically.  You should use the default (don't set it) or set it to
"baseline".  Note that you'll still have problems with letter spacing.
You need to either use the experimental textmetrics feature in a
recent dev snapshot or you need to use a monospaced font, or you need
to hand tune the spacing of each ltter.  As far as I know, there's no
way to predict the spacing you need even in a monospaced font, so
without textmetrics is all going to be trial and error to get a good
looking letter spacing.

Note that there's an implementation of text on arbitrary paths in BOSL2:

https://github.com/revarbat/BOSL2/wiki/shapes3d.scad#module-path_text

And if you install the dev version you can use textmetrics with the
BOSL2 function to wrap text with proper spacing for arbitrary fonts.
(Hmmm.  It probably fails for fonts that aren't left to right---don't
know how to test that.  Can anybody supply a test case?)

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time.  I am trying to write text partially around a cylinder.  I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

--
Thank You

Brian V Schaule Jr
bschaulejr@gmail.com
443-243-1779


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You have set valign to "center", so each letter is centered vertically. You should use the default (don't set it) or set it to "baseline". Note that you'll still have problems with letter spacing. You need to either use the experimental textmetrics feature in a recent dev snapshot or you need to use a monospaced font, or you need to hand tune the spacing of each ltter. As far as I know, there's no way to predict the spacing you need even in a monospaced font, so without textmetrics is all going to be trial and error to get a good looking letter spacing. Note that there's an implementation of text on arbitrary paths in BOSL2: https://github.com/revarbat/BOSL2/wiki/shapes3d.scad#module-path_text And if you install the dev version you can use textmetrics with the BOSL2 function to wrap text with proper spacing for arbitrary fonts. (Hmmm. It probably fails for fonts that aren't left to right---don't know how to test that. Can anybody supply a test case?) On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: > > > > I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time. I am trying to write text partially around a cylinder. I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached. > > > > > > > > Thank You > > Brian V Schaule Jr > bschaulejr@gmail.com > > -- > Thank You > > Brian V Schaule Jr > bschaulejr@gmail.com > 443-243-1779 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
PC
Patrick Callahan
Fri, Nov 26, 2021 3:19 PM

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See
attached.

Centering vertically first is probably not what you want to do.  It centers
each individual letter, regardless of the letter's actual size. Then by
rotating to move the letter to its final place, you are moving the center,
and that's not going to work.

I think rather than rotating the letters into position, you want to rotate
first, then move the bottom center of each letter outward by the required
distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character is
different.  You may want to take that into account somehow when
incrementing the angle, currently fixed at 14 degree intervals.

On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: > > > I am new to openscad, so if this is an obvious error I apologize for > wasting anyone's time. I am trying to write text partially around a > cylinder. I thought I worked through the code to do it, but some of the > letters are not sitting on the cylinder, and also the letter spacing is > inconsistent. Here is the code and screenshot of what I see. Code is > attached. > > > <snip> > Typography! Always a fun thing to do. To see what's going on, try the output in a few different ways. See attached. Centering vertically first is probably not what you want to do. It centers each individual letter, regardless of the letter's actual size. Then by rotating to move the letter to its final place, you are moving the center, and that's not going to work. I think rather than rotating the letters into position, you want to rotate first, then move the bottom center of each letter outward by the required distance. for(i = [0 : chars_len - 1]) { translate([sin(i*14)*radius,cos(i*14)*radius,0]) rotate([0,0,-(i*14)]) linear_extrude(height = 3){text( name[i], font = "Arial", size = font_size, halign = "center"); Note that arial is a proportional font, so the width of each character is different. You may want to take that into account somehow when incrementing the angle, currently fixed at 14 degree intervals.
BS
brian s
Fri, Nov 26, 2021 3:59 PM

Thanks guys,
Adrian,the valign correction got me on the right path.  I was viewing the
spacing and v-alignment as a single issue, once it was pointed out that
they were separate, I made my way onto the same thought path as Patrick but
the maths eluded me.  Thank you Patrick.  Im going to play around with
fonts or possibly see if I can work up (or find) a table for letter
adjustments and work from there.  Thanks again guys.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan pat.callahan1@gmail.com
wrote:

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See
attached.

Centering vertically first is probably not what you want to do.  It
centers each individual letter, regardless of the letter's actual size.
Then by rotating to move the letter to its final place, you are moving the
center, and that's not going to work.

I think rather than rotating the letters into position, you want to
rotate first, then move the bottom center of each letter outward by the
required distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character is
different.  You may want to take that into account somehow when
incrementing the angle, currently fixed at 14 degree intervals.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks guys, Adrian,the valign correction got me on the right path. I was viewing the spacing and v-alignment as a single issue, once it was pointed out that they were separate, I made my way onto the same thought path as Patrick but the maths eluded me. Thank you Patrick. Im going to play around with fonts or possibly see if I can work up (or find) a table for letter adjustments and work from there. Thanks again guys. Thank You *Brian V Schaule Jr* bschaulejr@gmail.com On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan <pat.callahan1@gmail.com> wrote: > > > On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: > >> >> >> I am new to openscad, so if this is an obvious error I apologize for >> wasting anyone's time. I am trying to write text partially around a >> cylinder. I thought I worked through the code to do it, but some of the >> letters are not sitting on the cylinder, and also the letter spacing is >> inconsistent. Here is the code and screenshot of what I see. Code is >> attached. >> >> > > >> <snip> >> > Typography! Always a fun thing to do. > > To see what's going on, try the output in a few different ways. See > attached. > > Centering vertically first is probably not what you want to do. It > centers each individual letter, regardless of the letter's actual size. > Then by rotating to move the letter to its final place, you are moving the > center, and that's not going to work. > > I think rather than rotating the letters into position, you want to > rotate first, then move the bottom center of each letter outward by the > required distance. > > for(i = [0 : chars_len - 1]) { > translate([sin(i*14)*radius,cos(i*14)*radius,0]) > rotate([0,0,-(i*14)]) > linear_extrude(height = 3){text( > name[i], > font = "Arial", > size = font_size, > halign = "center"); > > Note that arial is a proportional font, so the width of each character is > different. You may want to take that into account somehow when > incrementing the angle, currently fixed at 14 degree intervals. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Fri, Nov 26, 2021 4:12 PM

This might give you some ideas too.
https://www.thingiverse.com/thing:4886196

I wince a little bit looking at it because I think I did some things the
hard way, but it might help spark some ideas for you.

On Fri, Nov 26, 2021 at 10:01 AM brian s bschaulejr@gmail.com wrote:

Thanks guys,
Adrian,the valign correction got me on the right path.  I was viewing the
spacing and v-alignment as a single issue, once it was pointed out that
they were separate, I made my way onto the same thought path as Patrick but
the maths eluded me.  Thank you Patrick.  Im going to play around with
fonts or possibly see if I can work up (or find) a table for letter
adjustments and work from there.  Thanks again guys.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan pat.callahan1@gmail.com
wrote:

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See
attached.

Centering vertically first is probably not what you want to do.  It
centers each individual letter, regardless of the letter's actual size.
Then by rotating to move the letter to its final place, you are moving the
center, and that's not going to work.

I think rather than rotating the letters into position, you want to
rotate first, then move the bottom center of each letter outward by the
required distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character is
different.  You may want to take that into account somehow when
incrementing the angle, currently fixed at 14 degree intervals.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

This might give you some ideas too. https://www.thingiverse.com/thing:4886196 I wince a little bit looking at it because I think I did some things the hard way, but it might help spark some ideas for you. On Fri, Nov 26, 2021 at 10:01 AM brian s <bschaulejr@gmail.com> wrote: > Thanks guys, > Adrian,the valign correction got me on the right path. I was viewing the > spacing and v-alignment as a single issue, once it was pointed out that > they were separate, I made my way onto the same thought path as Patrick but > the maths eluded me. Thank you Patrick. Im going to play around with > fonts or possibly see if I can work up (or find) a table for letter > adjustments and work from there. Thanks again guys. > > > > > Thank You > > *Brian V Schaule Jr* > bschaulejr@gmail.com > > > > On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan <pat.callahan1@gmail.com> > wrote: > >> >> >> On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: >> >>> >>> >>> I am new to openscad, so if this is an obvious error I apologize for >>> wasting anyone's time. I am trying to write text partially around a >>> cylinder. I thought I worked through the code to do it, but some of the >>> letters are not sitting on the cylinder, and also the letter spacing is >>> inconsistent. Here is the code and screenshot of what I see. Code is >>> attached. >>> >>> >> >> >>> <snip> >>> >> Typography! Always a fun thing to do. >> >> To see what's going on, try the output in a few different ways. See >> attached. >> >> Centering vertically first is probably not what you want to do. It >> centers each individual letter, regardless of the letter's actual size. >> Then by rotating to move the letter to its final place, you are moving the >> center, and that's not going to work. >> >> I think rather than rotating the letters into position, you want to >> rotate first, then move the bottom center of each letter outward by the >> required distance. >> >> for(i = [0 : chars_len - 1]) { >> translate([sin(i*14)*radius,cos(i*14)*radius,0]) >> rotate([0,0,-(i*14)]) >> linear_extrude(height = 3){text( >> name[i], >> font = "Arial", >> size = font_size, >> halign = "center"); >> >> Note that arial is a proportional font, so the width of each character is >> different. You may want to take that into account somehow when >> incrementing the angle, currently fixed at 14 degree intervals. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Fri, Nov 26, 2021 4:14 PM

I don't think that there's anything better about Patrick's method
compared to your original method.  Basically both can work and produce
the same result.  I believe that somewhere on thingiverse there's a
package that has huge tables of text sizes if you want to go that
route.  (Is this mailing list archived somewhere?  It was mentioned a
few months ago.)  But fundamentally using textmetrics is the only way
to be robust, because that's using the data from your actual font.

On Fri, Nov 26, 2021 at 11:01 AM brian s bschaulejr@gmail.com wrote:

Thanks guys,
Adrian,the valign correction got me on the right path.  I was viewing the spacing and v-alignment as a single issue, once it was pointed out that they were separate, I made my way onto the same thought path as Patrick but the maths eluded me.  Thank you Patrick.  Im going to play around with fonts or possibly see if I can work up (or find) a table for letter adjustments and work from there.  Thanks again guys.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan pat.callahan1@gmail.com wrote:

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time.  I am trying to write text partially around a cylinder.  I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See attached.

Centering vertically first is probably not what you want to do.  It centers each individual letter, regardless of the letter's actual size. Then by rotating to move the letter to its final place, you are moving the center, and that's not going to work.

I think rather than rotating the letters into position, you want to rotate first, then move the bottom center of each letter outward by the required distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character is different.  You may want to take that into account somehow when incrementing the angle, currently fixed at 14 degree intervals.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I don't think that there's anything better about Patrick's method compared to your original method. Basically both can work and produce the same result. I believe that somewhere on thingiverse there's a package that has huge tables of text sizes if you want to go that route. (Is this mailing list archived somewhere? It was mentioned a few months ago.) But fundamentally using textmetrics is the only way to be robust, because that's using the data from your actual font. On Fri, Nov 26, 2021 at 11:01 AM brian s <bschaulejr@gmail.com> wrote: > > Thanks guys, > Adrian,the valign correction got me on the right path. I was viewing the spacing and v-alignment as a single issue, once it was pointed out that they were separate, I made my way onto the same thought path as Patrick but the maths eluded me. Thank you Patrick. Im going to play around with fonts or possibly see if I can work up (or find) a table for letter adjustments and work from there. Thanks again guys. > > > > > Thank You > > Brian V Schaule Jr > bschaulejr@gmail.com > > > > On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan <pat.callahan1@gmail.com> wrote: >> >> >> >> On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: >>> >>> >>> >>> I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time. I am trying to write text partially around a cylinder. I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached. >>> >> >> >>> >>> <snip> >> >> Typography! Always a fun thing to do. >> >> To see what's going on, try the output in a few different ways. See attached. >> >> Centering vertically first is probably not what you want to do. It centers each individual letter, regardless of the letter's actual size. Then by rotating to move the letter to its final place, you are moving the center, and that's not going to work. >> >> I think rather than rotating the letters into position, you want to rotate first, then move the bottom center of each letter outward by the required distance. >> >> for(i = [0 : chars_len - 1]) { >> translate([sin(i*14)*radius,cos(i*14)*radius,0]) >> rotate([0,0,-(i*14)]) >> linear_extrude(height = 3){text( >> name[i], >> font = "Arial", >> size = font_size, >> halign = "center"); >> >> Note that arial is a proportional font, so the width of each character is different. You may want to take that into account somehow when incrementing the angle, currently fixed at 14 degree intervals. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
PC
Patrick Callahan
Fri, Nov 26, 2021 5:41 PM

You can use textmetrics() if you install the OpenSCAD nightlies.

a=textmetrics(name[i],
font = "Arial",
size = font_size,
halign = "center"))
a.size[0] will represent the width of the character.
but now we want to position each character at an angle that depends on the
width of the character plus the angle calculated for all the
previous characters.

Is some kind of recursion the only answer here or can it be done inline?

-Pat

On Fri, Nov 26, 2021 at 11:15 AM Adrian Mariano avm4@cornell.edu wrote:

I don't think that there's anything better about Patrick's method
compared to your original method.  Basically both can work and produce
the same result.  I believe that somewhere on thingiverse there's a
package that has huge tables of text sizes if you want to go that
route.  (Is this mailing list archived somewhere?  It was mentioned a
few months ago.)  But fundamentally using textmetrics is the only way
to be robust, because that's using the data from your actual font.

On Fri, Nov 26, 2021 at 11:01 AM brian s bschaulejr@gmail.com wrote:

Thanks guys,
Adrian,the valign correction got me on the right path.  I was viewing

the spacing and v-alignment as a single issue, once it was pointed out that
they were separate, I made my way onto the same thought path as Patrick but
the maths eluded me.  Thank you Patrick.  Im going to play around with
fonts or possibly see if I can work up (or find) a table for letter
adjustments and work from there.  Thanks again guys.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan <

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for

wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of the
letters are not sitting on the cylinder, and also the letter spacing is
inconsistent. Here is the code and screenshot of what I see. Code is
attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See

attached.

Centering vertically first is probably not what you want to do.  It

centers each individual letter, regardless of the letter's actual size.
Then by rotating to move the letter to its final place, you are moving the
center, and that's not going to work.

I think rather than rotating the letters into position, you want to

rotate first, then move the bottom center of each letter outward by the
required distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character

is different.  You may want to take that into account somehow when
incrementing the angle, currently fixed at 14 degree intervals.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You can use textmetrics() if you install the OpenSCAD nightlies. a=textmetrics(name[i], font = "Arial", size = font_size, halign = "center")) a.size[0] will represent the width of the character. but now we want to position each character at an angle that depends on the width of the character plus the angle calculated for all the previous characters. Is some kind of recursion the only answer here or can it be done inline? -Pat On Fri, Nov 26, 2021 at 11:15 AM Adrian Mariano <avm4@cornell.edu> wrote: > I don't think that there's anything better about Patrick's method > compared to your original method. Basically both can work and produce > the same result. I believe that somewhere on thingiverse there's a > package that has huge tables of text sizes if you want to go that > route. (Is this mailing list archived somewhere? It was mentioned a > few months ago.) But fundamentally using textmetrics is the only way > to be robust, because that's using the data from your actual font. > > On Fri, Nov 26, 2021 at 11:01 AM brian s <bschaulejr@gmail.com> wrote: > > > > Thanks guys, > > Adrian,the valign correction got me on the right path. I was viewing > the spacing and v-alignment as a single issue, once it was pointed out that > they were separate, I made my way onto the same thought path as Patrick but > the maths eluded me. Thank you Patrick. Im going to play around with > fonts or possibly see if I can work up (or find) a table for letter > adjustments and work from there. Thanks again guys. > > > > > > > > > > Thank You > > > > Brian V Schaule Jr > > bschaulejr@gmail.com > > > > > > > > On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan < > pat.callahan1@gmail.com> wrote: > >> > >> > >> > >> On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: > >>> > >>> > >>> > >>> I am new to openscad, so if this is an obvious error I apologize for > wasting anyone's time. I am trying to write text partially around a > cylinder. I thought I worked through the code to do it, but some of the > letters are not sitting on the cylinder, and also the letter spacing is > inconsistent. Here is the code and screenshot of what I see. Code is > attached. > >>> > >> > >> > >>> > >>> <snip> > >> > >> Typography! Always a fun thing to do. > >> > >> To see what's going on, try the output in a few different ways. See > attached. > >> > >> Centering vertically first is probably not what you want to do. It > centers each individual letter, regardless of the letter's actual size. > Then by rotating to move the letter to its final place, you are moving the > center, and that's not going to work. > >> > >> I think rather than rotating the letters into position, you want to > rotate first, then move the bottom center of each letter outward by the > required distance. > >> > >> for(i = [0 : chars_len - 1]) { > >> translate([sin(i*14)*radius,cos(i*14)*radius,0]) > >> rotate([0,0,-(i*14)]) > >> linear_extrude(height = 3){text( > >> name[i], > >> font = "Arial", > >> size = font_size, > >> halign = "center"); > >> > >> Note that arial is a proportional font, so the width of each character > is different. You may want to take that into account somehow when > incrementing the angle, currently fixed at 14 degree intervals. > >> > >> _______________________________________________ > >> OpenSCAD mailing list > >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Fri, Nov 26, 2021 6:25 PM

Yes, you're getting closer to how the BOSL2 path_text() function works
if you enable the text metrics.  You want to use the "advance" value
returned by text metrics, not "size".  I would argue that it's better
to think in terms of arc length instead of angle.  That approach can
generalize to any path instead of just circles.  In order to position
each character you need to know the position of the previous
character, which requires a cumulative sum.  This cannot be done with
a list comprehension "inline" as you say.  It should be done using
recursion to write a cumulative sum function.

On Fri, Nov 26, 2021 at 12:42 PM Patrick Callahan
pat.callahan1@gmail.com wrote:

You can use textmetrics() if you install the OpenSCAD nightlies.

a=textmetrics(name[i],
font = "Arial",
size = font_size,
halign = "center"))
a.size[0] will represent the width of the character.
but now we want to position each character at an angle that depends on the width of the character plus the angle calculated for all the previous characters.

Is some kind of recursion the only answer here or can it be done inline?

-Pat

On Fri, Nov 26, 2021 at 11:15 AM Adrian Mariano avm4@cornell.edu wrote:

I don't think that there's anything better about Patrick's method
compared to your original method.  Basically both can work and produce
the same result.  I believe that somewhere on thingiverse there's a
package that has huge tables of text sizes if you want to go that
route.  (Is this mailing list archived somewhere?  It was mentioned a
few months ago.)  But fundamentally using textmetrics is the only way
to be robust, because that's using the data from your actual font.

On Fri, Nov 26, 2021 at 11:01 AM brian s bschaulejr@gmail.com wrote:

Thanks guys,
Adrian,the valign correction got me on the right path.  I was viewing the spacing and v-alignment as a single issue, once it was pointed out that they were separate, I made my way onto the same thought path as Patrick but the maths eluded me.  Thank you Patrick.  Im going to play around with fonts or possibly see if I can work up (or find) a table for letter adjustments and work from there.  Thanks again guys.

Thank You

Brian V Schaule Jr
bschaulejr@gmail.com

On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan pat.callahan1@gmail.com wrote:

On Fri, Nov 26, 2021 at 8:41 AM brian s bschaulejr@gmail.com wrote:

I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time.  I am trying to write text partially around a cylinder.  I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached.

<snip>

Typography! Always a fun thing to do.

To see what's going on, try the output in a few different ways. See attached.

Centering vertically first is probably not what you want to do.  It centers each individual letter, regardless of the letter's actual size. Then by rotating to move the letter to its final place, you are moving the center, and that's not going to work.

I think rather than rotating the letters into position, you want to rotate first, then move the bottom center of each letter outward by the required distance.

for(i = [0 : chars_len - 1]) {
translate([sin(i*14)radius,cos(i14)radius,0])
rotate([0,0,-(i
14)])
linear_extrude(height = 3){text(
name[i],
font = "Arial",
size = font_size,
halign = "center");

Note that arial is a proportional font, so the width of each character is different.  You may want to take that into account somehow when incrementing the angle, currently fixed at 14 degree intervals.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Yes, you're getting closer to how the BOSL2 path_text() function works if you enable the text metrics. You want to use the "advance" value returned by text metrics, not "size". I would argue that it's better to think in terms of arc length instead of angle. That approach can generalize to any path instead of just circles. In order to position each character you need to know the position of the previous character, which requires a cumulative sum. This cannot be done with a list comprehension "inline" as you say. It should be done using recursion to write a cumulative sum function. On Fri, Nov 26, 2021 at 12:42 PM Patrick Callahan <pat.callahan1@gmail.com> wrote: > > You can use textmetrics() if you install the OpenSCAD nightlies. > > a=textmetrics(name[i], > font = "Arial", > size = font_size, > halign = "center")) > a.size[0] will represent the width of the character. > but now we want to position each character at an angle that depends on the width of the character plus the angle calculated for all the previous characters. > > Is some kind of recursion the only answer here or can it be done inline? > > -Pat > > > On Fri, Nov 26, 2021 at 11:15 AM Adrian Mariano <avm4@cornell.edu> wrote: >> >> I don't think that there's anything better about Patrick's method >> compared to your original method. Basically both can work and produce >> the same result. I believe that somewhere on thingiverse there's a >> package that has huge tables of text sizes if you want to go that >> route. (Is this mailing list archived somewhere? It was mentioned a >> few months ago.) But fundamentally using textmetrics is the only way >> to be robust, because that's using the data from your actual font. >> >> On Fri, Nov 26, 2021 at 11:01 AM brian s <bschaulejr@gmail.com> wrote: >> > >> > Thanks guys, >> > Adrian,the valign correction got me on the right path. I was viewing the spacing and v-alignment as a single issue, once it was pointed out that they were separate, I made my way onto the same thought path as Patrick but the maths eluded me. Thank you Patrick. Im going to play around with fonts or possibly see if I can work up (or find) a table for letter adjustments and work from there. Thanks again guys. >> > >> > >> > >> > >> > Thank You >> > >> > Brian V Schaule Jr >> > bschaulejr@gmail.com >> > >> > >> > >> > On Fri, Nov 26, 2021 at 10:19 AM Patrick Callahan <pat.callahan1@gmail.com> wrote: >> >> >> >> >> >> >> >> On Fri, Nov 26, 2021 at 8:41 AM brian s <bschaulejr@gmail.com> wrote: >> >>> >> >>> >> >>> >> >>> I am new to openscad, so if this is an obvious error I apologize for wasting anyone's time. I am trying to write text partially around a cylinder. I thought I worked through the code to do it, but some of the letters are not sitting on the cylinder, and also the letter spacing is inconsistent. Here is the code and screenshot of what I see. Code is attached. >> >>> >> >> >> >> >> >>> >> >>> <snip> >> >> >> >> Typography! Always a fun thing to do. >> >> >> >> To see what's going on, try the output in a few different ways. See attached. >> >> >> >> Centering vertically first is probably not what you want to do. It centers each individual letter, regardless of the letter's actual size. Then by rotating to move the letter to its final place, you are moving the center, and that's not going to work. >> >> >> >> I think rather than rotating the letters into position, you want to rotate first, then move the bottom center of each letter outward by the required distance. >> >> >> >> for(i = [0 : chars_len - 1]) { >> >> translate([sin(i*14)*radius,cos(i*14)*radius,0]) >> >> rotate([0,0,-(i*14)]) >> >> linear_extrude(height = 3){text( >> >> name[i], >> >> font = "Arial", >> >> size = font_size, >> >> halign = "center"); >> >> >> >> Note that arial is a proportional font, so the width of each character is different. You may want to take that into account somehow when incrementing the angle, currently fixed at 14 degree intervals. >> >> >> >> _______________________________________________ >> >> OpenSCAD mailing list >> >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > >> > _______________________________________________ >> > OpenSCAD mailing list >> > To unsubscribe send an email to discuss-leave@lists.openscad.org >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
CM
Curt McDowell
Sun, Nov 28, 2021 7:31 AM

I solved the radial text problem using Alexander Pruss's
fontmetrics.scad workaround (already alluded to in this thread) and got
beautiful letter spacing. My code (as well as the aforementioned
library) is available in this Thing:

Beer/Soda Can Insulating Sleeve by fishlet - Thingiverse
https://www.thingiverse.com/thing:5041806

The OpenSCAD code prints radial text on the bottom of a soda can holder
(see the 3rd picture).

Needless to say, I'm looking forward to the upcoming textmetrics feature.

Regards,
Curt

On 11/26/2021 5:40 AM, brian s wrote:

I am new to openscad, so if this is an obvious error I apologize for
wasting anyone's time.  I am trying to write text partially around a
cylinder.  I thought I worked through the code to do it, but some of
the letters are not sitting on the cylinder, and also the letter
spacing is inconsistent. Here is the code and screenshot of what I
see. Code is attached.

image.png

Thank You
Brian V Schaule Jr
bschaulejr@gmail.com

--
Thank You
Brian V Schaule Jr
bschaulejr@gmail.com
443-243-1779


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

I solved the radial text problem using Alexander Pruss's fontmetrics.scad workaround (already alluded to in this thread) and got beautiful letter spacing. My code (as well as the aforementioned library) is available in this Thing: Beer/Soda Can Insulating Sleeve by fishlet - Thingiverse <https://www.thingiverse.com/thing:5041806> The OpenSCAD code prints radial text on the bottom of a soda can holder (see the 3rd picture). Needless to say, I'm looking forward to the upcoming textmetrics feature. Regards, Curt On 11/26/2021 5:40 AM, brian s wrote: > > > I am new to openscad, so if this is an obvious error I apologize for > wasting anyone's time.  I am trying to write text partially around a > cylinder.  I thought I worked through the code to do it, but some of > the letters are not sitting on the cylinder, and also the letter > spacing is inconsistent. Here is the code and screenshot of what I > see. Code is attached. > > > image.png > > > > > Thank You > *Brian V Schaule Jr* > bschaulejr@gmail.com > > -- > Thank You > *Brian V Schaule Jr* > bschaulejr@gmail.com > 443-243-1779 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org