discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Curved text in an oval plaque?

K
Ken
Sat, Aug 10, 2024 9:58 PM

I'm trying to do an oval plaque for the 50th anniversary of the
miniature locomotive club I am in, and am having the devil of a job
getting the curved text to conform to the oval. I've got it close, but
it is still not quite right, and the text spacing is a bit strange also.

I have reached the limit of my (limited) knowledge of openscad, so am
now asking for help. Is there a relatively straight-forward way to get
the curved text to follow the curve of the oval more accurately and be
spaced a little better- especially between the I and V of anniversary?


include <BOSL2/std.scad>
$fa = 1;
$fs = 0.4;

radius = 260;
chars = "HMSLS 50th ANNIVERSARY ";

module revolve_text(radius, chars) {
    PI = 3.14159;
    circumference = 4 * PI * radius;
    chars_len = len(chars);
     font_size = 8;
    step_angle =4; //180/ chars_len;
    for(i = [0 : chars_len - 1]) {
        rotate(-i * step_angle)
             translate([3, radius / 2, 0])
                text(
                    chars[i],
                    font ="Liberation Sans:style=Bold",
                    size = font_size,
                );
    }
}

module 3mm_countersunk_hole()
{
$fn = 128;
  translate([0,0,7.99])
   cylinder(8, d=8);
  translate([0,0,6])
    cylinder(2, d1=3.2, d2=8);
   translate([0,0,0])
   cylinder(7, d=3.2);
}

module place_text(ht, txt, fnt, siz)
{
  linear_extrude(height = ht)
  text(txt, font = fnt, size = siz);
}

rotate([0,0,-136])
translate([-60,-6,0])
revolve_text(radius, chars);
rotate([180,0,0])
translate([40,20,0])
{
difference()
{
scale ([1, 0.678]) cylinder (2, 130,130);
translate([0,0,-1])
scale ([1, 0.678]) cylinder (2, 120,120);
rotate([180,0,0])
translate([-100,0,-8])
3mm_countersunk_hole();
rotate([180,0,0])
translate([100,0,-8])
3mm_countersunk_hole();
}
}

rotate([0,0,180])
translate([-73.4, -52.8,-2.0])
place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9);


--
Cheers, Ken
bats059@gmail.com
https://vk7krj.com
https://vk7krj.com/running.html

A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!

I'm trying to do an oval plaque for the 50th anniversary of the miniature locomotive club I am in, and am having the devil of a job getting the curved text to conform to the oval. I've got it close, but it is still not quite right, and the text spacing is a bit strange also. I have reached the limit of my (limited) knowledge of openscad, so am now asking for help. Is there a relatively straight-forward way to get the curved text to follow the curve of the oval more accurately and be spaced a little better- especially between the I and V of anniversary? ************************************* include <BOSL2/std.scad> $fa = 1; $fs = 0.4; radius = 260; chars = "HMSLS 50th ANNIVERSARY "; module revolve_text(radius, chars) {     PI = 3.14159;     circumference = 4 * PI * radius;     chars_len = len(chars);      font_size = 8;     step_angle =4; //180/ chars_len;     for(i = [0 : chars_len - 1]) {         rotate(-i * step_angle)              translate([3, radius / 2, 0])                 text(                     chars[i],                     font ="Liberation Sans:style=Bold",                     size = font_size,                 );     } } module 3mm_countersunk_hole() { $fn = 128;   translate([0,0,7.99])    cylinder(8, d=8);   translate([0,0,6])     cylinder(2, d1=3.2, d2=8);    translate([0,0,0])    cylinder(7, d=3.2); } module place_text(ht, txt, fnt, siz) {   linear_extrude(height = ht)   text(txt, font = fnt, size = siz); } rotate([0,0,-136]) translate([-60,-6,0]) revolve_text(radius, chars); rotate([180,0,0]) translate([40,20,0]) { difference() { scale ([1, 0.678]) cylinder (2, 130,130); translate([0,0,-1]) scale ([1, 0.678]) cylinder (2, 120,120); rotate([180,0,0]) translate([-100,0,-8]) 3mm_countersunk_hole(); rotate([180,0,0]) translate([100,0,-8]) 3mm_countersunk_hole(); } } rotate([0,0,180]) translate([-73.4, -52.8,-2.0]) place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9); **************************************************** -- Cheers, Ken bats059@gmail.com https://vk7krj.com https://vk7krj.com/running.html ---------------------------------------- A baby can be defined as an ego with a noise at one end and a smell at the other. Your job as parents is to teach them to control all three. My job as a grandad is to tell you how you are doing it all wrong!
AM
Adrian Mariano
Sat, Aug 10, 2024 11:17 PM

I didn't dig into your example, but is there a reason you can't do this
directly with the path_text() module?  Assuming you use a dev version and
enable textmetrics, you will get proper text spacing (but no ligatures).

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

On Sat, Aug 10, 2024 at 5:59 PM Ken via Discuss discuss@lists.openscad.org
wrote:

I'm trying to do an oval plaque for the 50th anniversary of the miniature
locomotive club I am in, and am having the devil of a job getting the
curved text to conform to the oval. I've got it close, but it is still not
quite right, and the text spacing is a bit strange also.

I have reached the limit of my (limited) knowledge of openscad, so am now
asking for help. Is there a relatively straight-forward way to get the
curved text to follow the curve of the oval more accurately and be spaced a
little better- especially between the I and V of anniversary?


include <BOSL2/std.scad>
$fa = 1;
$fs = 0.4;

radius = 260;
chars = "HMSLS 50th ANNIVERSARY ";

module revolve_text(radius, chars) {
PI = 3.14159;
circumference = 4 * PI * radius;
chars_len = len(chars);
font_size = 8;
step_angle =4; //180/ chars_len;
for(i = [0 : chars_len - 1]) {
rotate(-i * step_angle)
translate([3, radius / 2, 0])
text(
chars[i],
font ="Liberation Sans:style=Bold",
size = font_size,
);
}
}

module 3mm_countersunk_hole()
{
$fn = 128;
translate([0,0,7.99])
cylinder(8, d=8);
translate([0,0,6])
cylinder(2, d1=3.2, d2=8);
translate([0,0,0])
cylinder(7, d=3.2);
}

module place_text(ht, txt, fnt, siz)
{
linear_extrude(height = ht)
text(txt, font = fnt, size = siz);
}

rotate([0,0,-136])
translate([-60,-6,0])
revolve_text(radius, chars);
rotate([180,0,0])
translate([40,20,0])
{
difference()
{
scale ([1, 0.678]) cylinder (2, 130,130);
translate([0,0,-1])
scale ([1, 0.678]) cylinder (2, 120,120);
rotate([180,0,0])
translate([-100,0,-8])
3mm_countersunk_hole();
rotate([180,0,0])
translate([100,0,-8])
3mm_countersunk_hole();
}
}

rotate([0,0,180])
translate([-73.4, -52.8,-2.0])
place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9);


--
Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html

A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!


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

I didn't dig into your example, but is there a reason you can't do this directly with the path_text() module? Assuming you use a dev version and enable textmetrics, you will get proper text spacing (but no ligatures). https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-path_text On Sat, Aug 10, 2024 at 5:59 PM Ken via Discuss <discuss@lists.openscad.org> wrote: > I'm trying to do an oval plaque for the 50th anniversary of the miniature > locomotive club I am in, and am having the devil of a job getting the > curved text to conform to the oval. I've got it close, but it is still not > quite right, and the text spacing is a bit strange also. > > I have reached the limit of my (limited) knowledge of openscad, so am now > asking for help. Is there a relatively straight-forward way to get the > curved text to follow the curve of the oval more accurately and be spaced a > little better- especially between the I and V of anniversary? > > ************************************* > > include <BOSL2/std.scad> > $fa = 1; > $fs = 0.4; > > radius = 260; > chars = "HMSLS 50th ANNIVERSARY "; > > module revolve_text(radius, chars) { > PI = 3.14159; > circumference = 4 * PI * radius; > chars_len = len(chars); > font_size = 8; > step_angle =4; //180/ chars_len; > for(i = [0 : chars_len - 1]) { > rotate(-i * step_angle) > translate([3, radius / 2, 0]) > text( > chars[i], > font ="Liberation Sans:style=Bold", > size = font_size, > ); > } > } > > module 3mm_countersunk_hole() > { > $fn = 128; > translate([0,0,7.99]) > cylinder(8, d=8); > translate([0,0,6]) > cylinder(2, d1=3.2, d2=8); > translate([0,0,0]) > cylinder(7, d=3.2); > } > > module place_text(ht, txt, fnt, siz) > { > linear_extrude(height = ht) > text(txt, font = fnt, size = siz); > } > > > rotate([0,0,-136]) > translate([-60,-6,0]) > revolve_text(radius, chars); > rotate([180,0,0]) > translate([40,20,0]) > { > difference() > { > scale ([1, 0.678]) cylinder (2, 130,130); > translate([0,0,-1]) > scale ([1, 0.678]) cylinder (2, 120,120); > rotate([180,0,0]) > translate([-100,0,-8]) > 3mm_countersunk_hole(); > rotate([180,0,0]) > translate([100,0,-8]) > 3mm_countersunk_hole(); > } > } > > rotate([0,0,180]) > translate([-73.4, -52.8,-2.0]) > place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9); > > **************************************************** > > -- > Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html > ---------------------------------------- > A baby can be defined as an ego with a noise at one end and a smell at the other. > Your job as parents is to teach them to control all three. > My job as a grandad is to tell you how you are doing it all wrong! > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Sun, Aug 11, 2024 12:03 AM

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

On Sat, Aug 10, 2024 at 6:18 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

I didn't dig into your example, but is there a reason you can't do this
directly with the path_text() module?  Assuming you use a dev version and
enable textmetrics, you will get proper text spacing (but no ligatures).

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

On Sat, Aug 10, 2024 at 5:59 PM Ken via Discuss <
discuss@lists.openscad.org> wrote:

I'm trying to do an oval plaque for the 50th anniversary of the miniature
locomotive club I am in, and am having the devil of a job getting the
curved text to conform to the oval. I've got it close, but it is still not
quite right, and the text spacing is a bit strange also.

I have reached the limit of my (limited) knowledge of openscad, so am now
asking for help. Is there a relatively straight-forward way to get the
curved text to follow the curve of the oval more accurately and be spaced a
little better- especially between the I and V of anniversary?


include <BOSL2/std.scad>
$fa = 1;
$fs = 0.4;

radius = 260;
chars = "HMSLS 50th ANNIVERSARY ";

module revolve_text(radius, chars) {
PI = 3.14159;
circumference = 4 * PI * radius;
chars_len = len(chars);
font_size = 8;
step_angle =4; //180/ chars_len;
for(i = [0 : chars_len - 1]) {
rotate(-i * step_angle)
translate([3, radius / 2, 0])
text(
chars[i],
font ="Liberation Sans:style=Bold",
size = font_size,
);
}
}

module 3mm_countersunk_hole()
{
$fn = 128;
translate([0,0,7.99])
cylinder(8, d=8);
translate([0,0,6])
cylinder(2, d1=3.2, d2=8);
translate([0,0,0])
cylinder(7, d=3.2);
}

module place_text(ht, txt, fnt, siz)
{
linear_extrude(height = ht)
text(txt, font = fnt, size = siz);
}

rotate([0,0,-136])
translate([-60,-6,0])
revolve_text(radius, chars);
rotate([180,0,0])
translate([40,20,0])
{
difference()
{
scale ([1, 0.678]) cylinder (2, 130,130);
translate([0,0,-1])
scale ([1, 0.678]) cylinder (2, 120,120);
rotate([180,0,0])
translate([-100,0,-8])
3mm_countersunk_hole();
rotate([180,0,0])
translate([100,0,-8])
3mm_countersunk_hole();
}
}

rotate([0,0,180])
translate([-73.4, -52.8,-2.0])
place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9);


--
Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html

A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!


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

https://www.thingiverse.com/thing:4886196 On Sat, Aug 10, 2024 at 6:18 PM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > I didn't dig into your example, but is there a reason you can't do this > directly with the path_text() module? Assuming you use a dev version and > enable textmetrics, you will get proper text spacing (but no ligatures). > > https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-path_text > > On Sat, Aug 10, 2024 at 5:59 PM Ken via Discuss < > discuss@lists.openscad.org> wrote: > >> I'm trying to do an oval plaque for the 50th anniversary of the miniature >> locomotive club I am in, and am having the devil of a job getting the >> curved text to conform to the oval. I've got it close, but it is still not >> quite right, and the text spacing is a bit strange also. >> >> I have reached the limit of my (limited) knowledge of openscad, so am now >> asking for help. Is there a relatively straight-forward way to get the >> curved text to follow the curve of the oval more accurately and be spaced a >> little better- especially between the I and V of anniversary? >> >> ************************************* >> >> include <BOSL2/std.scad> >> $fa = 1; >> $fs = 0.4; >> >> radius = 260; >> chars = "HMSLS 50th ANNIVERSARY "; >> >> module revolve_text(radius, chars) { >> PI = 3.14159; >> circumference = 4 * PI * radius; >> chars_len = len(chars); >> font_size = 8; >> step_angle =4; //180/ chars_len; >> for(i = [0 : chars_len - 1]) { >> rotate(-i * step_angle) >> translate([3, radius / 2, 0]) >> text( >> chars[i], >> font ="Liberation Sans:style=Bold", >> size = font_size, >> ); >> } >> } >> >> module 3mm_countersunk_hole() >> { >> $fn = 128; >> translate([0,0,7.99]) >> cylinder(8, d=8); >> translate([0,0,6]) >> cylinder(2, d1=3.2, d2=8); >> translate([0,0,0]) >> cylinder(7, d=3.2); >> } >> >> module place_text(ht, txt, fnt, siz) >> { >> linear_extrude(height = ht) >> text(txt, font = fnt, size = siz); >> } >> >> >> rotate([0,0,-136]) >> translate([-60,-6,0]) >> revolve_text(radius, chars); >> rotate([180,0,0]) >> translate([40,20,0]) >> { >> difference() >> { >> scale ([1, 0.678]) cylinder (2, 130,130); >> translate([0,0,-1]) >> scale ([1, 0.678]) cylinder (2, 120,120); >> rotate([180,0,0]) >> translate([-100,0,-8]) >> 3mm_countersunk_hole(); >> rotate([180,0,0]) >> translate([100,0,-8]) >> 3mm_countersunk_hole(); >> } >> } >> >> rotate([0,0,180]) >> translate([-73.4, -52.8,-2.0]) >> place_text(2,"1974 - 2024","Liberation Sans:style=Bold",9); >> >> **************************************************** >> >> -- >> Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html >> ---------------------------------------- >> A baby can be defined as an ego with a noise at one end and a smell at the other. >> Your job as parents is to teach them to control all three. >> My job as a grandad is to tell you how you are doing it all wrong! >> >> _______________________________________________ >> 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 >
JB
Jordan Brown
Sun, Aug 11, 2024 10:28 AM



I didn't dig into your example, but is there a reason you can't do this directly with the path_text() module?  Assuming you use a dev version and enable textmetrics, you will get proper text spacing (but no ligatures).

Probably also no kerning, which might be the source of the IV complaint.

For those not familiar with typography, ligatures are the substitution of certain sequences with single glyphs - for instance, replacing f f i with a single glyph that connects the three. Kerning is the related technique of adjusting spacing to account for the different shapes of the glyphs (vs a simple box model) - for instance, pulling AV together, possibly even overlapping their boxes, to avoid putting the white space at the top right of the A next to the white space at the bottom left of the V.

The easy way to lay out text does neither of these things.

Forming the text to a curve makes the picture more complicated - I didn’t look at the OP’s example, but IV at the bottom of a curve will put the bottoms of the two letters way far apart.

Quite possibly the only practical remedy is to manually adjust the spacing until it looks right.

 > I didn't dig into your example, but is there a reason you can't do this directly with the path_text() module? Assuming you use a dev version and enable textmetrics, you will get proper text spacing (but no ligatures). Probably also no kerning, which might be the source of the IV complaint. For those not familiar with typography, ligatures are the substitution of certain sequences with single glyphs - for instance, replacing f f i with a single glyph that connects the three. Kerning is the related technique of adjusting spacing to account for the different shapes of the glyphs (vs a simple box model) - for instance, pulling AV together, possibly even overlapping their boxes, to avoid putting the white space at the top right of the A next to the white space at the bottom left of the V. The easy way to lay out text does neither of these things. Forming the text to a curve makes the picture more complicated - I didn’t look at the OP’s example, but IV at the bottom of a curve will put the bottoms of the two letters way far apart. Quite possibly the only practical remedy is to manually adjust the spacing until it looks right.
RW
Raymond West
Sun, Aug 11, 2024 11:29 AM

As Jordan said, best to individually place the characters, as the quick
and dirty example below shows, which just puts them at a fixed angle.
The for loop could be replaced, calculating the angle from the relative
'width' of each character. If that is the only text involved, then it
should not be too tedious. If the oval is near enough a circle, the
difference in size and shape of the letters will most likely be not
noticeable.

On 11/08/2024 11:28, Jordan Brown via Discuss wrote:



I didn't dig into your example, but is there a reason you can't do this directly with the path_text() module?  Assuming you use a dev version and enable textmetrics, you will get proper text spacing (but no ligatures).

Probably also no kerning, which might be the source of the IV complaint.

For those not familiar with typography, ligatures are the substitution of certain sequences with single glyphs - for instance, replacing f f i with a single glyph that connects the three. Kerning is the related technique of adjusting spacing to account for the different shapes of the glyphs (vs a simple box model) - for instance, pulling AV together, possibly even overlapping their boxes, to avoid putting the white space at the top right of the A next to the white space at the bottom left of the V.

The easy way to lay out text does neither of these things.

Forming the text to a curve makes the picture more complicated - I didn’t look at the OP’s example, but IV at the bottom of a curve will put the bottoms of the two letters way far apart.

Quite possibly the only practical remedy is to manually adjust the spacing until it looks right.


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

As Jordan said, best to individually place the characters, as the quick and dirty example below shows, which just puts them at a fixed angle. The for loop could be replaced, calculating the angle from the relative 'width' of each character. If that is the only text involved, then it should not be too tedious. If the oval is near enough a circle, the difference in size and shape of the letters will most likely be not noticeable. On 11/08/2024 11:28, Jordan Brown via Discuss wrote: >  >> I didn't dig into your example, but is there a reason you can't do this directly with the path_text() module? Assuming you use a dev version and enable textmetrics, you will get proper text spacing (but no ligatures). > Probably also no kerning, which might be the source of the IV complaint. > > For those not familiar with typography, ligatures are the substitution of certain sequences with single glyphs - for instance, replacing f f i with a single glyph that connects the three. Kerning is the related technique of adjusting spacing to account for the different shapes of the glyphs (vs a simple box model) - for instance, pulling AV together, possibly even overlapping their boxes, to avoid putting the white space at the top right of the A next to the white space at the bottom left of the V. > > The easy way to lay out text does neither of these things. > > Forming the text to a curve makes the picture more complicated - I didn’t look at the OP’s example, but IV at the bottom of a curve will put the bottoms of the two letters way far apart. > > Quite possibly the only practical remedy is to manually adjust the spacing until it looks right. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
JB
Jordan Brown
Sun, Aug 11, 2024 5:48 PM

I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look at the program in detail.

The problem is lack of proportional spacing. A sans-serif I is very thin, so giving it the same amount of space as other characters looks very wrong. With the development snapshot you can use textmetrics() to get actual dimensions - you probably want the “advance” value - but it will be less than totally fun to use that to position the characters. Probably you want to call textmetrics() on each individual character to get its dimensions, put those in an array, convert that into a running-sum array, and use that for positioning.

I believe Adrian pointed at a BOSL2 function that will do that grunge work for you; that’s probably easiest.

That will probably address your problem.

I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look at the program in detail. The problem is lack of proportional spacing. A sans-serif I is very thin, so giving it the same amount of space as other characters looks very wrong. With the development snapshot you can use textmetrics() to get actual dimensions - you probably want the “advance” value - but it will be less than totally fun to use that to position the characters. Probably you want to call textmetrics() on each individual character to get its dimensions, put those in an array, convert that into a running-sum array, and use *that* for positioning. I believe Adrian pointed at a BOSL2 function that will do that grunge work for you; that’s probably easiest. That will probably address your problem.
AM
Adrian Mariano
Sun, Aug 11, 2024 6:48 PM

Yes, the point of path_text is that it consults the text metrics to space
the letters as well as possible and it also does the necessary
interpolation along the curve you provide to find the correct letter
positions and computes the normal to the curve so it can produce the proper
letter orientation.

Kerning is making tiny adjustments for specific combinations of letters
like perhaps adjusting AV so that the two letters are closer together
because their shapes enable them to fit together more tightly than their
bounding boxes would suggest. Only people who are very attuned to
typography are going to notice that kerning is missing.  I wonder if I
could get kerning data out of textmetrics by asking for the metrics on
pairs of letters and then also singleton letters and looking at how they
differ.  Would that work, Jordan?  Like if the advance of "AV" is 2 and
the advance of A and V separately is 2.2 then would that mean that the
advance of A should be reduced by 0.2 before placing the V to get the
kerning?  Of course, the weakness of doing this is that ligatures would
mess it up.

On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look
at the program in detail.

The problem is lack of proportional spacing. A sans-serif I is very thin,
so giving it the same amount of space as other characters looks very wrong.
With the development snapshot you can use textmetrics() to get actual
dimensions - you probably want the “advance” value - but it will be less
than totally fun to use that to position the characters. Probably you want
to call textmetrics() on each individual character to get its dimensions,
put those in an array, convert that into a running-sum array, and use
that for positioning.

I believe Adrian pointed at a BOSL2 function that will do that grunge work
for you; that’s probably easiest.

That will probably address your problem.


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

Yes, the point of path_text is that it consults the text metrics to space the letters as well as possible and it also does the necessary interpolation along the curve you provide to find the correct letter positions and computes the normal to the curve so it can produce the proper letter orientation. Kerning is making tiny adjustments for specific combinations of letters like perhaps adjusting AV so that the two letters are closer together because their shapes enable them to fit together more tightly than their bounding boxes would suggest. Only people who are very attuned to typography are going to notice that kerning is missing. I wonder if I could get kerning data out of textmetrics by asking for the metrics on pairs of letters and then also singleton letters and looking at how they differ. Would that work, Jordan? Like if the advance of "AV" is 2 and the advance of A and V separately is 2.2 then would that mean that the advance of A should be reduced by 0.2 before placing the V to get the kerning? Of course, the weakness of doing this is that ligatures would mess it up. On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look > at the program in detail. > > The problem is lack of proportional spacing. A sans-serif I is very thin, > so giving it the same amount of space as other characters looks very wrong. > With the development snapshot you can use textmetrics() to get actual > dimensions - you probably want the “advance” value - but it will be less > than totally fun to use that to position the characters. Probably you want > to call textmetrics() on each individual character to get its dimensions, > put those in an array, convert that into a running-sum array, and use > *that* for positioning. > > I believe Adrian pointed at a BOSL2 function that will do that grunge work > for you; that’s probably easiest. > > That will probably address your problem. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Aug 11, 2024 8:47 PM

I wonder if I could get kerning data out of textmetrics by asking for the metrics on pairs of letters and then also singleton letters and looking at how they differ.  Would that work, Jordan?  Like if the advance of "AV" is 2 and the advance of A and V separately is 2.2 then would that mean that the advance of A should be reduced by 0.2 before placing the V to get the kerning?  Of course, the weakness of doing this is that ligatures would mess it up.

Yeah, ligatures would be a problem. I don’t know whether there could be an option to not do ligature processing; I would have to research. OpenSCAD itself doesn’t do the ligature and kerning processing; it uses a library called Harfbuzz and it’s largely a black box. (This is why you get silly results if you try to use the “spacing” parameter with a ligature-capable font.)

> I wonder if I could get kerning data out of textmetrics by asking for the metrics on pairs of letters and then also singleton letters and looking at how they differ. Would that work, Jordan? Like if the advance of "AV" is 2 and the advance of A and V separately is 2.2 then would that mean that the advance of A should be reduced by 0.2 before placing the V to get the kerning? Of course, the weakness of doing this is that ligatures would mess it up. Yeah, ligatures would be a problem. I don’t know whether there could be an option to not do ligature processing; I would have to research. OpenSCAD itself doesn’t do the ligature and kerning processing; it uses a library called Harfbuzz and it’s largely a black box. (This is why you get silly results if you try to use the “spacing” parameter with a ligature-capable font.)
RW
Raymond West
Sun, Aug 11, 2024 8:49 PM

The idea of kerning, is such that viewed from a distance (apart from
blank lines/paragraphs and the like), the page looks a uniform shade of
grey. It needs to be different for each character combination. In
straight line text, as you've mentioned, it is achievable to a lesser or
greater extent, but on curved lines, then that becomes a separate issue.
Manual typesetters, in the old lead font days had furniture pieces to
get the correct spacing. It depends very much on the type of font, as to
how easy it to achieve 'correctness', and if the font is bold or italic,
you will need to start over. It is perfectly doable, for 30 or so
characters, to manually specify, say, the bottom lh corner, and the
angle for each character. Openscad responds quickly enough that it can
be tested as you position each character. The result will be most likely
far superior to any mathematically automatically generated solution
based on preconceived values, in an attempt to cover every situation.
Still, use comic sans, and the necessity for kerning disappears.

Usually, a 'W' is the widest character, so if it is, say, 10mm wide,
then perhaps initially allow a spacing of 12 mm between characters.
Space the the other characters at 12 mm spacing, see how it looks, and
decrease the spacing as required so that it 'looks right'. a module with
character, xy, and angle parameters would speed the process (for some
regular paths, the angle could be calculated from the xy values). Of
course, it depends on 'how good your eye is', but that also depends on
whoever designs some mathematical solutions, and I've seen some not so
good TrueType fonts, and others.

On 11/08/2024 19:48, Adrian Mariano via Discuss wrote:

Yes, the point of path_text is that it consults the text metrics to
space the letters as well as possible and it also does the necessary
interpolation along the curve you provide to find the correct letter
positions and computes the normal to the curve so it can produce the
proper letter orientation.

Kerning is making tiny adjustments for specific combinations of
letters like perhaps adjusting AV so that the two letters are closer
together because their shapes enable them to fit together more tightly
than their bounding boxes would suggest. Only people who are very
attuned to typography are going to notice that kerning is missing.  I
wonder if I could get kerning data out of textmetrics by asking for
the metrics on pairs of letters and then also singleton letters and
looking at how they differ.   Would that work, Jordan? Like if the
advance of "AV" is 2 and the advance of A and V separately is 2.2 then
would that mean that the advance of A should be reduced by 0.2 before
placing the V to get the kerning?   Of course, the weakness of doing
this is that ligatures would mess it up.

On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss
discuss@lists.openscad.org wrote:

 I’m on my iPad and so can’t experiment, and (bad me) didn’t
 actually look at the program in detail.

 The problem is lack of proportional spacing. A sans-serif I is
 very thin, so giving it the same amount of space as other
 characters looks very wrong. With the development snapshot you can
 use textmetrics() to get actual dimensions - you probably want the
 “advance” value - but it will be less than totally fun to use that
 to position the characters. Probably you want to call
 textmetrics() on each individual character to get its dimensions,
 put those in an array, convert that into a running-sum array, and
 use *that* for positioning.

 I believe Adrian pointed at a BOSL2 function that will do that
 grunge work for you; that’s probably easiest.

 That will probably address your problem.
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

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

The idea of kerning, is such that viewed from a distance (apart from blank lines/paragraphs and the like), the page looks a uniform shade of grey. It needs to be different for each character combination. In straight line text, as you've mentioned, it is achievable to a lesser or greater extent, but on curved lines, then that becomes a separate issue. Manual typesetters, in the old lead font days had furniture pieces to get the correct spacing. It depends very much on the type of font, as to how easy it to achieve 'correctness', and if the font is bold or italic, you will need to start over. It is perfectly doable, for 30 or so characters, to manually specify, say, the bottom lh corner, and the angle for each character. Openscad responds quickly enough that it can be tested as you position each character. The result will be most likely far superior to any mathematically automatically generated solution based on preconceived values, in an attempt to cover every situation. Still, use comic sans, and the necessity for kerning disappears. Usually, a 'W' is the widest character, so if it is, say, 10mm wide, then perhaps initially allow a spacing of 12 mm between characters. Space the the other characters at 12 mm spacing, see how it looks, and decrease the spacing as required so that it 'looks right'. a module with character, xy, and angle parameters would speed the process (for some regular paths, the angle could be calculated from the xy values). Of course, it depends on 'how good your eye is', but that also depends on whoever designs some mathematical solutions, and I've seen some not so good TrueType fonts, and others. On 11/08/2024 19:48, Adrian Mariano via Discuss wrote: > Yes, the point of path_text is that it consults the text metrics to > space the letters as well as possible and it also does the necessary > interpolation along the curve you provide to find the correct letter > positions and computes the normal to the curve so it can produce the > proper letter orientation. > > Kerning is making tiny adjustments for specific combinations of > letters like perhaps adjusting AV so that the two letters are closer > together because their shapes enable them to fit together more tightly > than their bounding boxes would suggest. Only people who are very > attuned to typography are going to notice that kerning is missing.  I > wonder if I could get kerning data out of textmetrics by asking for > the metrics on pairs of letters and then also singleton letters and > looking at how they differ.   Would that work, Jordan? Like if the > advance of "AV" is 2 and the advance of A and V separately is 2.2 then > would that mean that the advance of A should be reduced by 0.2 before > placing the V to get the kerning?   Of course, the weakness of doing > this is that ligatures would mess it up. > > On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss > <discuss@lists.openscad.org> wrote: > > I’m on my iPad and so can’t experiment, and (bad me) didn’t > actually look at the program in detail. > > The problem is lack of proportional spacing. A sans-serif I is > very thin, so giving it the same amount of space as other > characters looks very wrong. With the development snapshot you can > use textmetrics() to get actual dimensions - you probably want the > “advance” value - but it will be less than totally fun to use that > to position the characters. Probably you want to call > textmetrics() on each individual character to get its dimensions, > put those in an array, convert that into a running-sum array, and > use *that* for positioning. > > I believe Adrian pointed at a BOSL2 function that will do that > grunge work for you; that’s probably easiest. > > That will probably address your problem. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
AM
Adrian Mariano
Sun, Aug 11, 2024 9:50 PM

Why would you base your text spacing on the widest character?  That would
look ridiculous.  You base your initial spacing on the actual width of the
letters.  For most letter pairs, no adjustment is needed beyond that.  But
the way that this is suboptimal is that it doesn't account for cases where
the bounding boxes of the characters should overlap.  From what Jordan
says, it sounds like OpenSCAD doesn't even do fine kerning when you
directly ask it for text.  I don't know what you are talking about with
"furniture pieces".  The way kerning was accomplished in the days of lead
type was that the type wasn't a rectangle but actually had overhanging
sections that could be positioned into the notional bounding box of the
adjacent letter.  Unless you're a typography expert, it's likely that your
notion of what "looks right" for kerning will be underdeveloped.

On Sun, Aug 11, 2024 at 4:50 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

The idea of kerning, is such that viewed from a distance (apart from blank
lines/paragraphs and the like), the page looks a uniform shade of grey. It
needs to be different for each character combination. In straight line
text, as you've mentioned, it is achievable to a lesser or greater extent,
but on curved lines, then that becomes a separate issue. Manual
typesetters, in the old lead font days had furniture pieces to get the
correct spacing. It depends very much on the type of font, as to how easy
it to achieve 'correctness', and if the font is bold or italic, you will
need to start over. It is perfectly doable, for 30 or so characters, to
manually specify, say, the bottom lh corner, and the angle for each
character. Openscad responds quickly enough that it can be tested as you
position each character. The result will be most likely far superior to any
mathematically automatically generated solution based on preconceived
values, in an attempt to cover every situation. Still, use comic sans, and
the necessity for kerning disappears.

Usually, a 'W' is the widest character, so if it is, say, 10mm wide, then
perhaps initially allow a spacing of 12 mm between characters. Space the
the other characters at 12 mm spacing, see how it looks, and decrease the
spacing as required so that it 'looks right'. a module with character, xy,
and angle parameters would speed the process (for some regular paths, the
angle could be calculated from the xy values). Of course, it depends on
'how good your eye is', but that also depends on whoever designs some
mathematical solutions, and I've seen some not so good TrueType fonts, and
others.
On 11/08/2024 19:48, Adrian Mariano via Discuss wrote:

Yes, the point of path_text is that it consults the text metrics to space
the letters as well as possible and it also does the necessary
interpolation along the curve you provide to find the correct letter
positions and computes the normal to the curve so it can produce the proper
letter orientation.

Kerning is making tiny adjustments for specific combinations of letters
like perhaps adjusting AV so that the two letters are closer together
because their shapes enable them to fit together more tightly than their
bounding boxes would suggest. Only people who are very attuned to
typography are going to notice that kerning is missing.  I wonder if I
could get kerning data out of textmetrics by asking for the metrics on
pairs of letters and then also singleton letters and looking at how they
differ.  Would that work, Jordan?  Like if the advance of "AV" is 2 and
the advance of A and V separately is 2.2 then would that mean that the
advance of A should be reduced by 0.2 before placing the V to get the
kerning?  Of course, the weakness of doing this is that ligatures would
mess it up.

On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look
at the program in detail.

The problem is lack of proportional spacing. A sans-serif I is very thin,
so giving it the same amount of space as other characters looks very wrong.
With the development snapshot you can use textmetrics() to get actual
dimensions - you probably want the “advance” value - but it will be less
than totally fun to use that to position the characters. Probably you want
to call textmetrics() on each individual character to get its dimensions,
put those in an array, convert that into a running-sum array, and use
that for positioning.

I believe Adrian pointed at a BOSL2 function that will do that grunge
work for you; that’s probably easiest.

That will probably address your problem.


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

Why would you base your text spacing on the widest character? That would look ridiculous. You base your initial spacing on the actual width of the letters. For most letter pairs, no adjustment is needed beyond that. But the way that this is suboptimal is that it doesn't account for cases where the bounding boxes of the characters should overlap. From what Jordan says, it sounds like OpenSCAD doesn't even do fine kerning when you directly ask it for text. I don't know what you are talking about with "furniture pieces". The way kerning was accomplished in the days of lead type was that the type wasn't a rectangle but actually had overhanging sections that could be positioned into the notional bounding box of the adjacent letter. Unless you're a typography expert, it's likely that your notion of what "looks right" for kerning will be underdeveloped. On Sun, Aug 11, 2024 at 4:50 PM Raymond West via Discuss < discuss@lists.openscad.org> wrote: > The idea of kerning, is such that viewed from a distance (apart from blank > lines/paragraphs and the like), the page looks a uniform shade of grey. It > needs to be different for each character combination. In straight line > text, as you've mentioned, it is achievable to a lesser or greater extent, > but on curved lines, then that becomes a separate issue. Manual > typesetters, in the old lead font days had furniture pieces to get the > correct spacing. It depends very much on the type of font, as to how easy > it to achieve 'correctness', and if the font is bold or italic, you will > need to start over. It is perfectly doable, for 30 or so characters, to > manually specify, say, the bottom lh corner, and the angle for each > character. Openscad responds quickly enough that it can be tested as you > position each character. The result will be most likely far superior to any > mathematically automatically generated solution based on preconceived > values, in an attempt to cover every situation. Still, use comic sans, and > the necessity for kerning disappears. > > Usually, a 'W' is the widest character, so if it is, say, 10mm wide, then > perhaps initially allow a spacing of 12 mm between characters. Space the > the other characters at 12 mm spacing, see how it looks, and decrease the > spacing as required so that it 'looks right'. a module with character, xy, > and angle parameters would speed the process (for some regular paths, the > angle could be calculated from the xy values). Of course, it depends on > 'how good your eye is', but that also depends on whoever designs some > mathematical solutions, and I've seen some not so good TrueType fonts, and > others. > On 11/08/2024 19:48, Adrian Mariano via Discuss wrote: > > Yes, the point of path_text is that it consults the text metrics to space > the letters as well as possible and it also does the necessary > interpolation along the curve you provide to find the correct letter > positions and computes the normal to the curve so it can produce the proper > letter orientation. > > Kerning is making tiny adjustments for specific combinations of letters > like perhaps adjusting AV so that the two letters are closer together > because their shapes enable them to fit together more tightly than their > bounding boxes would suggest. Only people who are very attuned to > typography are going to notice that kerning is missing. I wonder if I > could get kerning data out of textmetrics by asking for the metrics on > pairs of letters and then also singleton letters and looking at how they > differ. Would that work, Jordan? Like if the advance of "AV" is 2 and > the advance of A and V separately is 2.2 then would that mean that the > advance of A should be reduced by 0.2 before placing the V to get the > kerning? Of course, the weakness of doing this is that ligatures would > mess it up. > > On Sun, Aug 11, 2024 at 1:48 PM Jordan Brown via Discuss < > discuss@lists.openscad.org> wrote: > >> I’m on my iPad and so can’t experiment, and (bad me) didn’t actually look >> at the program in detail. >> >> The problem is lack of proportional spacing. A sans-serif I is very thin, >> so giving it the same amount of space as other characters looks very wrong. >> With the development snapshot you can use textmetrics() to get actual >> dimensions - you probably want the “advance” value - but it will be less >> than totally fun to use that to position the characters. Probably you want >> to call textmetrics() on each individual character to get its dimensions, >> put those in an array, convert that into a running-sum array, and use >> *that* for positioning. >> >> I believe Adrian pointed at a BOSL2 function that will do that grunge >> work for you; that’s probably easiest. >> >> That will probably address your problem. >> _______________________________________________ >> 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 >