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
You may want to display [[Text]] in your game, this can be achieved with the [[Text]], [[Font]], and [[SpriteFont]].
8
11
9
12
## Text
@@ -53,6 +56,8 @@ const label = new ex.Label({
53
56
});
54
57
```
55
58
59
+
60
+
56
61
## Font
57
62
58
63
A [[Font]] is a traditional system or loaded web font.
@@ -98,9 +103,36 @@ var text = new ex.Text({
98
103
});
99
104
```
100
105
106
+
<PlaygroundEmbed
107
+
title="Font"
108
+
code={FontLabel}
109
+
mount="visible"
110
+
/>
111
+
112
+
### Loading External Fonts
113
+
114
+
101
115
It is recommended you load any font important to your game and not rely on any pre-installed system fonts, those will be different from computer to computer.
102
116
103
-
For example the [google fonts](https://fonts.google.com/) loader is a common way to do this.
One potential issue with using web fonts is they won't render correctly until loaded see [article for details](https://erikonarheim.com/posts/dont-test-fonts/).
154
+
One potential issue with using web fonts from google is they won't render correctly until loaded see [article for details](https://erikonarheim.com/posts/dont-test-fonts/).
@@ -147,6 +179,25 @@ const game = new ex.Engine({...})
147
179
awaitgame.start();
148
180
```
149
181
182
+
## Text Quality
183
+
184
+
Depending on your game you may run into a situation where you have blurry looking text, this can be caused by a few reasons and fixed by adjusting a few settings.
185
+
186
+
Most of the strategies involve artificially giving the text more pixels to work with to render a more crisp result.
187
+
188
+
1. Increase the `quality` (default 2), this works by upscaling the bitmap the text is drawn to internally, more pixels can yield higher fidelity.
189
+
2. Increase the "resolution" of your game using the `pixelRatio`, this is especially necessary if you have a very low resolutions (less than 500x500).
190
+
3. If you cannot upscale (or don't want to) you need to line up your font glyphs to align with pixels in the canvas.
191
+
4. Reach for a sprite font tailored for the resolution you're working in (often this is useful in low res situations)>
192
+
193
+
194
+
<PlaygroundEmbed
195
+
title="FontQuality"
196
+
code={FontQuality}
197
+
mount="visible"
198
+
/>
199
+
200
+
150
201
## SpriteFont
151
202
152
203
Sometimes you want to use a custom font based on your [spritesheet](#spritesheet) of character glyphs
0 commit comments