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} + + + + Font + + + {f:font} + @@ -123,7 +131,7 @@ Valid style modifiers are as follows: > [!IMPORTANT] -> Modifiers are **case sensitive** – `{s:}` must be lowercase, while all other modifiers are UPPERCASE. +> Modifiers are **case sensitive** – `{s:}` and `{f:}` must be lowercase, while all other modifiers are UPPERCASE. --- @@ -546,13 +554,203 @@ Vanilla Balatro only uses `s:0.8`, `s:0.85` and `s:1.1` text scales. +## Text font modifier `{f:}` +> [!IMPORTANT] +> This modifier requires the **lowercase** `f`, unlike other modifiers which must be UPPERCASE. + +{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 stringFont NameAssigned LanguageResult
+ + ```pas +{f:1}Hello{} +``` + m6x11 plusDefault + + + Hello + +
+ + ```pas +{f:2}Hello, 你好{} +``` + Noto Sans SC BoldSimplified Chinese + + + Hello, 你好 + +
+ + ```pas +{f:3}Hello, 您好{} +``` + Noto Sans TC BoldTraditional Chinese + + + Hello, 您好 + +
+ + ```pas +{f:4}Hello, 안녕하세요{} +``` + Noto Sans KR BoldKorean + + + Hello, 안녕하세요 + +
+ + ```pas +{f:5}こんにちは{} +``` + Noto Sans JP BoldJapanese + + + こんにちは + +
+ + ```pas +{f:6}Hello, Здравствуйте{} +``` + Noto Sans BoldRussian + + + Hello, Здравствуйте + +
+ + ```pas +{f:7}Hello{} +``` + m6x11 plusNone* + + + Hello + +
+ + ```pas +{f:8}Hello{} +``` + Go Noto Current BoldAll1** + + + Hello + +
+ + ```pas +{f:9}Hello{} +``` +Go Noto CJK CoreAll2** + + + Hello + +
+ + ```pas +{f:modname_fontkey}Hello{} +``` + Custom Font (example: Comic Sans MS)Custom + + + Hello + +
+ +*It differs from the default font from the parameters `TEXT_HEIGHT_SCALE = 0.9` and `TEXT_OFFSET = {x=10,y=15}` +**These are the language names given in the original `game.lua` file. ## Combinations Some style codes can be combined within one set of curly braces, like `{X:mult,C:white}`. -- `{T:}` and `{s:}` are compatible with all other modifiers. +- `{T:}`, `{f:}` and `{s:}` are compatible with all other modifiers. - Background modifiers `{X:}` or `{B:}` can be used in conjunction with text colour modifiers `{C:}` or `{V:}`. @@ -1068,3 +1266,10 @@ Steamodded automatically adds additional entries to `LOC_COLOURS` for all custom which can be used as colour keys in the same way by `{C:}` and `{X:}`. When referring to custom Rarity, Gradient, Consumable or Suit colours added by SMODS, the key must be prefixed with the [mod prefix](https://github.com/Steamodded/smods/wiki/Mod-Metadata#metadata). + + + + + + +