Often times when you are trying to make a new object you will do an internet search and see if someone has already made something, or if you like to make your own things with OpenSCAD you will try options that don't always work like you want them to and you get stuck and reach out for help. Knowing how "helpful" some people on the internet are I will usually figure it out on my own, but often you will see a post where someone has a great idea and a whole bunch of people chime in with non solutions or say that OpenSCAD can't do this or can't do that, and some that are really helpful and have no problem sharing their knowledge and experience.
A while back I read this post: https://3dprinting.stackexchange.com/questions/19380/can-openscad-bend-text-project-it-on-curved-surface
I want to give full credit to the original poster because I used some parts of their code and then added some improvements and customizable features.
Here is the code:
/*[Bend Text]*/
Input_text="";
Font_style="";
bend=90;//[5:.01:360]
steps=100;//[3:1:200]
text_size=10;//[2:1:60]
text_spacing=1;//[.1:.01:10]
text_extrude=.5;//[.1:.01:3]
/*[Clip Box]*/
show_clip_box=false;
clip_height=9;//[1:.1:50]
clip_width=40;//[5:1:400]
dh=clip_height/steps;
r=clip_height/(bend*PI/180);
h0=-clip_height/2;
module bend_text(){
translate([0,0,-r])
rotate([bend/2,0,0])
for(i=[0:.7:steps]){
rotate([-i*bend/steps,0,0])
translate([0,-(dh*i+h0),r])
intersection() {
linear_extrude(text_extrude)
text(Input_text,font=Font_style,spacing=text_spacing,size=text_size,valign="center",halign="center",$fn=50);
translate([0,dh*i+h0,0])
cube([clip_width,dh,clip_width],center=true);
}}}
//color("white")
bend_text();
//rotate([180,90,0])
//translate([5,0,-50])
//cylinder(h=100,r=5,$fn=100);
if(show_clip_box)
%square([clip_width,clip_height],center=true);
There is still a bit of work to do, like bend the text in any direction. I have used the same code to bend an svg around a cylinder which will be super handy.
One of the quirks of intersection is the two objects must overlap properly or there will be a Vec out of range error:
Update: shortly after I made this post I downloaded the latest development build and the "vec out of range" error is gone, I was unaware that the version I was using was from 2023 and there has been a ton of improvements since then, I highly recommend downloading the latest development version and giving it a try:
This is the version I am now using. I tried all sorts of options and it renders now without any issues.
I also added some steps to the for loop to get rid of the gaps and make the text appear to be much smoother.
And a way to change the font style:
(remove the quotes("") from each end when you paste the copied font into the font box)
Maybe a 3d printed page binder?