Text Drawing
In order to draw text, you’ll have to create its object, configure its properties, and then draw it.
Creating and configuring fonts
Section titled “Creating and configuring fonts”The first thing to do is creating the font that will be used to draw the text. You can create a font with the following expression:
set {_font} to new font named "Arial" with size 20Adding font styles
Section titled “Adding font styles”You can add a style to the font by using the following expression:
set {_font} to new font named "Arial" and style "XXX" with size 20You can replace the XXX with the following styles:
bolditalicplainbold italic
Using custom fonts
Section titled “Using custom fonts”You must load the font before using it. It’s best to put the following effect inside a on load or on skript load event:
register text font from file "path/to/font.ttf" # single fileregister text font from file "path/to/fonts/" # folder (all files inside will be loaded)Supported formats are .ttf, .otf and .ttc.
Creating and drawing text
Section titled “Creating and drawing text”Now that you have a font, you can create the text object:
set {_text} to new text with font {_font} and text "Hello world!"SkImage uses a powerful ‘text format’ system, therefore you can easily change the text’s color by using Minecraft’s colors, for example:
set {_txt} to new text "$cHello $6world! $##00FF00This is green!%nl%$3works on multiple lines!" with font {_font} vert align horiz align
As you can see here, you can use $ to change the color of the text (using Minecraft’s color codes, or HEX codes), and %nl% to create a new line. Also, you can specify either the vertical or horizontal alignment of the text.
You can now draw the text as when you draw a shape:
draw {_text} on {_graphics} at 0, 0Supported Color Codes
Section titled “Supported Color Codes”Minecraft codes
Section titled “Minecraft codes”$0- Black$1- Dark Blue$2- Dark Green$3- Dark Aqua$4- Dark Red$5- Dark Purple$6- Gold$7- Gray$8- Dark Gray$9- Blue$a- Green$b- Aqua$c- Red$d- Light Purple$e- Yellow$f- White
HEX Code
Section titled “HEX Code”The format is $#000000 where 000000 is the HEX code.