diff --git a/Assets/Text-Styling/example_font_hello_10_dark.svg b/Assets/Text-Styling/example_font_hello_10_dark.svg new file mode 100644 index 0000000..74facd3 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_10_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_10_light.svg b/Assets/Text-Styling/example_font_hello_10_light.svg new file mode 100644 index 0000000..ee717f6 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_10_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_1_dark.svg b/Assets/Text-Styling/example_font_hello_1_dark.svg new file mode 100644 index 0000000..484cd17 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_1_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_1_light.svg b/Assets/Text-Styling/example_font_hello_1_light.svg new file mode 100644 index 0000000..2805aa9 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_1_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_2_dark.svg b/Assets/Text-Styling/example_font_hello_2_dark.svg new file mode 100644 index 0000000..d450ec5 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_2_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_2_light.svg b/Assets/Text-Styling/example_font_hello_2_light.svg new file mode 100644 index 0000000..c4dbcf8 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_2_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_3_dark.svg b/Assets/Text-Styling/example_font_hello_3_dark.svg new file mode 100644 index 0000000..68c7637 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_3_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_3_light.svg b/Assets/Text-Styling/example_font_hello_3_light.svg new file mode 100644 index 0000000..db781c7 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_3_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_4_dark.svg b/Assets/Text-Styling/example_font_hello_4_dark.svg new file mode 100644 index 0000000..22c3a5c --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_4_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_4_light.svg b/Assets/Text-Styling/example_font_hello_4_light.svg new file mode 100644 index 0000000..bfcdbcb --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_4_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_5_dark.svg b/Assets/Text-Styling/example_font_hello_5_dark.svg new file mode 100644 index 0000000..ebc0e27 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_5_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_5_light.svg b/Assets/Text-Styling/example_font_hello_5_light.svg new file mode 100644 index 0000000..7dca8c5 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_5_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_6_dark.svg b/Assets/Text-Styling/example_font_hello_6_dark.svg new file mode 100644 index 0000000..248e95b --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_6_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_6_light.svg b/Assets/Text-Styling/example_font_hello_6_light.svg new file mode 100644 index 0000000..083dac3 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_6_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_7_dark.svg b/Assets/Text-Styling/example_font_hello_7_dark.svg new file mode 100644 index 0000000..ec91179 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_7_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_7_light.svg b/Assets/Text-Styling/example_font_hello_7_light.svg new file mode 100644 index 0000000..ee86b2a --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_7_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_8_dark.svg b/Assets/Text-Styling/example_font_hello_8_dark.svg new file mode 100644 index 0000000..deb74d2 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_8_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_8_light.svg b/Assets/Text-Styling/example_font_hello_8_light.svg new file mode 100644 index 0000000..5b5d13b --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_8_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_9_dark.svg b/Assets/Text-Styling/example_font_hello_9_dark.svg new file mode 100644 index 0000000..b4468c0 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_9_dark.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/Assets/Text-Styling/example_font_hello_9_light.svg b/Assets/Text-Styling/example_font_hello_9_light.svg new file mode 100644 index 0000000..e239d84 --- /dev/null +++ b/Assets/Text-Styling/example_font_hello_9_light.svg @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/SMODS.Font.md b/SMODS.Font.md new file mode 100644 index 0000000..5c5572d --- /dev/null +++ b/SMODS.Font.md @@ -0,0 +1,50 @@ +# API Documentation: `SMODS.Font` +This class allows you to use custom Fonts. Your mod must be located in its own subdirectory of the `Mods` folder. To make sure your font works, you have to put it in a `fonts` subdirectory inside `assets` The file structure should look something like this: +```bash +Mods +└──FontMod + ├── main.lua + └── assets + └── fonts + └── HelveticaNeue.ttf + +``` + +- **Required parameters:** + - `key`: The key used to indentify your font (e.g. `'HelveticaNeue` *(`modname_HelveticaNeue`)*) + - `path`: The font's name, including the extension (e.g. `'HelveticaNeue.ttf'`). + +- **Optional parameters** *(defaults)*: + - `render_scale`: Sets the font size. This is generally better as a higher value so it can be scaled down. The default value is `200`. + - `FONTSCALE` : Multiplier to scale down the font to the intended display size. Multiplies `render_scale` so that it renders at a proper size. The default value is `0.1`. + - `DESCSCALE` : Determines how big the description text should be in relation to normal text. Keep in mind that mobile UI makes this 1.5x bigger. The default font's value is `1`. + - `squish` : Determines horizontal width of each character. The default value is `1`. + - `TEXT_HEIGHT_SCALE` : Determines line spacing. The default value is `0.83`. + - `TEXT_OFFSET`(table) : Determines the offset that the font is rendered. You might need to adjust this if the font renders in unexpected places. The default value is `{x=0, y=0}`. + +- **Example Code** +```lua +SMODS.Font{ + key = "HelveticaNeue", + path = "HelveticaNeue.ttf", + render_scale = 200, + TEXT_HEIGHT_SCALE = 0.83, + TEXT_OFFSET = {x=0,y=0}, + FONTSCALE = 0.1, + squish = 1, + DESCSCALE = 1 +} +``` + +## Applying fonts to text +For your font to show up in game, you can assign it to formatted text using the *style modifier code* `f:` Example: +```lua +j_modname_example = { + name = "{f:modname_HelveticaNeue}Example", + text = { + { + "{C:chips,f:modname_HelveticaNeue}+#1#{} Chips", + }, + }, +}, +``` diff --git a/Text-Styling.md b/Text-Styling.md index 40f3097..a3829a1 100644 --- a/Text-Styling.md +++ b/Text-Styling.md @@ -111,6 +111,14 @@ Valid style modifiers are as follows:
{s:scale}
{f:font}
+ {f:font} changes the font of the text.
+
+*`font`* is a f value ranging from `1` to `9` in vanilla, to add [custom fonts](https://github.com/Steamodded/smods/wiki/SMODS.Font) you need to set the value as the font's full key (`modname_font`).
+
+### Examples
+| Text string | +Font Name | +Assigned Language | +Result | +
| + + ```pas +{f:1}Hello{} +``` + | +m6x11 plus | +Default | +
+ |
+
| + + ```pas +{f:2}Hello, 你好{} +``` + | +Noto Sans SC Bold | +Simplified Chinese | +
+ |
+
| + + ```pas +{f:3}Hello, 您好{} +``` + | +Noto Sans TC Bold | +Traditional Chinese | +
+ |
+
| + + ```pas +{f:4}Hello, 안녕하세요{} +``` + | +Noto Sans KR Bold | +Korean | +
+ |
+
| + + ```pas +{f:5}こんにちは{} +``` + | +Noto Sans JP Bold | +Japanese | +
+ |
+
| + + ```pas +{f:6}Hello, Здравствуйте{} +``` + | +Noto Sans Bold | +Russian | +
+ |
+
| + + ```pas +{f:7}Hello{} +``` + | +m6x11 plus | +None* | +
+ |
+
| + + ```pas +{f:8}Hello{} +``` + | +Go Noto Current Bold | +All1** | +
+ |
+
| + + ```pas +{f:9}Hello{} +``` + | +Go Noto CJK Core | +All2** | +
+ |
+
| + + ```pas +{f:modname_fontkey}Hello{} +``` + | +Custom Font (example: Comic Sans MS) | +Custom | +
+ |
+