The spacing is very accurate. Before the #.textwidth() command was created in SPL version 19, the only way to get the correct second x value was by trial and error! Remember to use text size commands right after you define the text, before you make any changes to the font name, type or size.
Code: Select all
''
Text Width by rbytes
September 2017
Adapted from Font Type, posted recently
The main difference is that the second drawtext on each line has
its x position calculated by the #.textwidth command, rather than
choosing a value by trial and error. The word spacing is not always
what I prefer, but at least #.textwidth() gets close enough that only
small correction values are needed.
''
#.fontsize(30)
a = #.normal
b = #.bold
c = #.italic
c1 = "Some helpful "
c2 = "advice ..."
d = "Keep on "
e = "smiling."
f = "It does your face "
g = "good!"
#.drawtext(100,25,"You can use bold and/or italic text to highlight important words.")
#.drawcolor(.4,.4,1)
#.fontsize(60)
#.drawtext(100,75,c1) ' Some helpful
w = #.textwidth(c1) ' returns width w of text c1
#.fonttype(c)
#.drawtext(100 + w,75,c2) ' advice
#.drawcolor(1,0,1)
#.fonttype(a)
#.drawtext(100,150,d) ' Keep on
w = #.textwidth(d) ' returns width w of text d.
#.fonttype(b)
#.drawtext(100 + w,150,e) ' smiling
#.drawcolor(0,.6,.6)
#.fonttype(a)
#.drawtext(100,225,f) ' It does your face
w = #.textwidth(f) ' returns width w of text f.
#.fonttype(b,c)
#.drawtext(100 + w,225,g) ' good!
#.fonttype(a)
#.fontsize(30)
#.drawcolor(0,0,0)
#.drawtext(100,365,"But some specialty fonts may not show the results you expect")
#.fontname("Ranchers")
#.fontsize(60)
#.drawcolor(.4,.4,1)
#.drawtext(100,425,c1) ' Some helpful
w = #.textwidth(c1) ' returns width w of text c1.
#.fonttype(c)
#.drawtext(100 + w,425,c2) ' advice
#.drawcolor(1,0,1)
#.fonttype(a)
#.drawtext(100,510,d) ' Keep on
w = #.textwidth(d) ' returns width w of text d.
#.fonttype(b)
#.drawtext(100 + w,510,e) ' smiling
#.drawcolor(0,.6,.6)
#.fonttype(a)
#.drawtext(100,595,f) ' It does your face
w = #.textwidth(f) ' returns width w of text f.
#.fonttype(b,c)
#.drawtext(100 + w,595,g) ' good!
#.fonttype(a)
#.fontname("default")
#.fontsize(30)
#.drawcolor(0,0,0)
#.drawtext(100,690,"Ranchers always looks bold, so using the bold command changes little.")