Skip to content

Instantly share code, notes, and snippets.

@stenson
Created November 8, 2022 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stenson/8ec792104ea68b7390be8433e4d82280 to your computer and use it in GitHub Desktop.
Save stenson/8ec792104ea68b7390be8433e4d82280 to your computer and use it in GitHub Desktop.
for use with new scripting tab in ST2
from coldtype import *
# make sure to select hobeaux borders otf
# in the ST2 font picker in Blender
# (or else this script won’t work)
styles = [ # the number in the text box in ST2
"Aa ", "B ", "Cc3", "Dd4", "Ee5",
"Ff6", "Gg ", "Hh8", "Ii9", "Jj0",
"Kk!", "Ll@", "Mm#", "Nn$", "Oo%",
"Pp^", "Qq&", "Rr ", "Ss(", "Tt)",
"Uu-", "Vv=", "Ww_", "Xx+", "Yy ",
]
def hobeauxBorder(r, text, font, fs=2):
b, c, m = [StSt(x, font, fs).pen() for x in text[:3]]
bw, cw = [e.ambit().w for e in (b, c)]
nh, nv = int(r.w/bw/2), int(r.h/bw/2)
bx = Rect(bw*nh*2+cw*2, bw*nv*2).align(r)
return (b.layer(
lambda p: p
.layer(nh)
.append(c)
.distribute()
.append(m)
.mirrorx()
.translate(*bx.pn)
.mirrory(bx.pc),
lambda p: p
.layer(nv)
.distribute()
.append(m.copy())
.rotate(90, point=(0, 0))
.translate(cw, 0)
.mirrory()
.translate(*bx.pw)
.mirrorx(bx.pc))
.pen()
.unframe())
def modify(st2:dict, kwargs:dict):
try:
txt = styles[int(st2.text)]
except:
txt = st2.text
w = kwargs.get("width", 4)
h = kwargs.get("height", w)
fs = kwargs.get("fontSize", 4)
return (hobeauxBorder(Rect(w, h), txt, st2.font_path, fs)
.centerZero())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment