Yes, I made a custom font extension. Well, almost. This block doesn’t work -
This block is supposed to set an image to a string in a particular font.
Here is the code for that block -
//%block="set $output=variables_get(picture) to $input"
export function SetImage(output: Image, input: string) {
let heig = 0
let widt = 0
let curwidt = 0
for (let currentletter = 0; currentletter <= input.length; currentletter++) {
if (!(ligs.indexOf(input.charAt(currentletter)) == -1)) {
heig = Math.max(heig, ligages[(ligs.indexOf(input.charAt(currentletter)))].height)
}
}
for (let currentletter2 = 0; currentletter2 <= input.length; currentletter2++) {
if (!(ligs.indexOf(input.charAt(currentletter2)) == -1)) {
widt += ligages[(ligs.indexOf(input.charAt(currentletter2)))].width
} else if (input.charAt(currentletter2) == " ") {
widt += 3*letterspace
}
widt += 1
}
output = image.create(widt, heig)
for (let currentletter3 = 0; currentletter3 <= input.length; currentletter3++) {
if (!(ligs.indexOf(input.charAt(currentletter3)) == -1)) {
drawTransparentImage(ligages[(ligs.indexOf(input.charAt(currentletter3)))], output, curwidt, 3)
curwidt += letterspace
curwidt += ligages[(ligs.indexOf(input.charAt(currentletter3)))].width
}
}
}
Can someone explain why it doesn’t work? @richard, was it you who made the text sprite extension? I used some code from there, that might be where it went wrong.