You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: llms-full.txt
+76-6Lines changed: 76 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -4899,11 +4899,6 @@ Fonts added to your project are automatically converted into a texture format th
4899
4899
- Bitmap
4900
4900
- Distance field
4901
4901
4902
-
<div class='sidenote' markdown='1'>
4903
-
It is possible to [generate font glyphs at runtime](/extension-fontgen) from a bundled TrueType font instead of generating and including a font texture in the application bundle. This approach can greatly reduce the download size and runtime memory consumption of a Defold game.
4904
-
</div>
4905
-
4906
-
4907
4902
## Creating a font
4908
4903
4909
4904
To create a font for use in Defold, create a new Font file by selecting <kbd>File ▸ New...</kbd> from the menu, then select <kbd>Font</kbd>. You can also <kbd>right click</kbd> a location in the *Assets* browser and select <kbd>New... ▸ Font</kbd>.
@@ -4980,7 +4975,7 @@ space ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E
4980
4975
*Cache Width/Height*
4981
4976
: Constrains the size of the glyph cache bitmap. When the engine renders text, it looks up the glyph from the cache bitmap. If it does not exist there, it will be added to the cache before rendering. If the cache bitmap is too small to contain all the glyphs the engine is asked to render, an error is signalled (`ERROR:RENDER: Out of available cache cells! Consider increasing cache_width or cache_height for the font.`).
4982
4977
4983
-
If set to 0 the cache size is set automatically.
4978
+
If set to 0 the cache size is set automatically, and will grow to 2048x4096 max.
4984
4979
4985
4980
## Distance field fonts
4986
4981
@@ -5051,6 +5046,81 @@ For example - to generate a gradient in a shader fragment, simply write:
5051
5046
5052
5047
For more information about shader uniforms, see the [Shader manual](#manuals:shader).
5053
5048
5049
+
## Runtime generation
5050
+
5051
+
It is possible to use runtime generation for SDF type fonts, when using TrueType (.ttf) fonts.
5052
+
This approach can greatly reduce the download size and runtime memory consumption of a Defold game.
5053
+
The small downside is a very small delay for each glyph generated at runtime.
5054
+
5055
+
Enable the feature by setting `font.runtime_generation` in game.project.
5056
+
5057
+
<div class='sidenote' markdown='1'>
5058
+
This feature is currently experimental, but with the intention to be used as the default workflow in the future.
5059
+
</div>
5060
+
5061
+
<div class='important' markdown='1'>
5062
+
This setting affects all .ttf fonts in the project.
5063
+
</div>
5064
+
5065
+
### Prewarming glyph cache
5066
+
5067
+
In order to make the runtime fonts easier to use, they support prewarming of the glyph cache.
5068
+
This means the font will generate the glyphs listed in *Characters* in the font.
5069
+
5070
+
<div class='sidenote' markdown='1'>
5071
+
If `All Chars` is selected, there will be no prewarming as it defeats the purpose of not having to generate all glyphs at the same time.
5072
+
</div>
5073
+
5074
+
### Font Scripting
5075
+
5076
+
For runtime fonts, it's possible to add or removed sub fonts.
5077
+
This is useful when a large font has been split up into multiple files for different character sets (e.g. CJK)
5078
+
5079
+
<div class='important' markdown='1'>
5080
+
Adding a subfont doesn't automatically load or render all the glyphs.
5081
+
</div>
5082
+
5083
+
```lua
5084
+
-- Add the range A-Z to the .fontc
5085
+
local font_hash = hash("/assets/fonts/roboto.fontc")
5086
+
local ttf_hash = hash("/assets/fonts/Roboto/Roboto-Bold.ttf")
Copy file name to clipboardExpand all lines: manuals/font.md
+80-7Lines changed: 80 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,9 @@ toc:
12
12
- Bitmap BMFonts
13
13
- Artifacts and best practices
14
14
- Font Cache
15
+
- Runtime generation
16
+
- Prewarming glyph cache
17
+
- Font Scripting
15
18
---
16
19
17
20
# Font files
@@ -27,11 +30,6 @@ Fonts added to your project are automatically converted into a texture format th
27
30
- Bitmap
28
31
- Distance field
29
32
30
-
<divclass='sidenote'markdown='1'>
31
-
It is possible to [generate font glyphs at runtime](/extension-fontgen) from a bundled TrueType font instead of generating and including a font texture in the application bundle. This approach can greatly reduce the download size and runtime memory consumption of a Defold game.
32
-
</div>
33
-
34
-
35
33
## Creating a font
36
34
37
35
To create a font for use in Defold, create a new Font file by selecting <kbd>File ▸ New...</kbd> from the menu, then select <kbd>Font</kbd>. You can also <kbd>right click</kbd> a location in the *Assets* browser and select <kbd>New... ▸ Font</kbd>.
@@ -108,7 +106,7 @@ space ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E
108
106
*Cache Width/Height*
109
107
: Constrains the size of the glyph cache bitmap. When the engine renders text, it looks up the glyph from the cache bitmap. If it does not exist there, it will be added to the cache before rendering. If the cache bitmap is too small to contain all the glyphs the engine is asked to render, an error is signalled (`ERROR:RENDER: Out of available cache cells! Consider increasing cache_width or cache_height for the font.`).
110
108
111
-
If set to 0 the cache size is set automatically.
109
+
If set to 0 the cache size is set automatically, and will grow to 2048x4096 max.
112
110
113
111
## Distance field fonts
114
112
@@ -177,4 +175,79 @@ For example - to generate a gradient in a shader fragment, simply write:
0 commit comments