Skip to content

Commit 9e2b4e6

Browse files
committed
Merge branch 'master' of https://github.com/defold/doc
2 parents 5d1c950 + 78dad26 commit 9e2b4e6

File tree

11 files changed

+394
-53
lines changed

11 files changed

+394
-53
lines changed

.wordlist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ cmd
7171
CocoaPods
7272
CodeAndWeb
7373
codebase
74+
CJK
7475
codesign
7576
collada
7677
collectionfactory
@@ -94,6 +95,7 @@ customizable
9495
customizations
9596
cutscene
9697
cutscenes
98+
dt
9799
dae
98100
deadzone
99101
debuggable
@@ -128,6 +130,7 @@ esc
128130
excitemike
129131
exe
130132
ffmpeg
133+
FCM
131134
Fi
132135
filesystem
133136
filetype
@@ -160,6 +163,7 @@ Git's
160163
github
161164
gitlab
162165
GL
166+
GLES
163167
glb
164168
GLFW
165169
globals
@@ -186,6 +190,7 @@ hxdefold
186190
IAM
187191
IAP
188192
ico
193+
icns
189194
ICOConvert
190195
iconified
191196
idfa
@@ -366,6 +371,7 @@ scroller
366371
SD
367372
SDK
368373
SDKs
374+
SDF
369375
Sergey
370376
sha
371377
shader

docs/en/manuals/camera.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,6 @@ function M.screen_to_world(camera, screen_x, screen_y, z)
229229
local projection = go.get(camera, "projection")
230230
local view = go.get(camera, "view")
231231
local w, h = window.get_size()
232-
-- The window.get_size() function will return the scaled window size,
233-
-- ie taking into account display scaling (Retina screens on macOS for
234-
-- instance). We need to adjust for display scaling in our calculation.
235-
local scale = window.get_display_scale()
236-
w = w / scale
237-
h = h / scale
238232

239233
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
240234
local inv = vmath.inv(projection * view)
@@ -246,7 +240,7 @@ function M.screen_to_world(camera, screen_x, screen_y, z)
246240
end
247241
```
248242

249-
Visit the [Examples page](https://defold.com/examples/render/screen_to_world/) to see screen to world coordinate conversion in action. There is also a [sample project](https://github.com/defold/sample-screen-to-world-coordinates/) showing how to do screen to world coordinate conversion.
243+
Keep in mind that the values `action.screen_x` and `action.screen_y` from `on_input()` should be used as arguments for this function. Visit the [Examples page](https://defold.com/examples/render/screen_to_world/) to see screen to world coordinate conversion in action. There is also a [sample project](https://github.com/defold/sample-screen-to-world-coordinates/) showing how to do screen to world coordinate conversion.
250244

251245
::: sidenote
252246
The [third-party camera solutions mentioned in this manual](/manuals/camera/#third-party-camera-solutions) provides functions for converting to and from screen coordinates.

docs/en/manuals/editor-scripts.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ You can interact with the editor using `editor` package that defines this API:
7171
- `editor.can_get(node_id, property)` — check if you can get this property so `editor.get()` won't throw an error.
7272
- `editor.can_set(node_id, property)` — check if `editor.tx.set()` transaction step with this property won't throw an error.
7373
- `editor.create_directory(resource_path)` — create a directory if it does not exist, and all non-existent parent directories.
74+
- `editor.create_resources(resources)` — create 1 or more resources, either from templates or with custom content
7475
- `editor.delete_directory(resource_path)` — delete a directory if it exists, and all existent child directories and files.
7576
- `editor.execute(cmd, [...args], [options])` — run a shell command, optionally capturing its output.
7677
- `editor.save()` — persist all unsaved changed to disk.
@@ -692,7 +693,7 @@ The editor script runtime uses 2 execution modes that are mostly transparent to
692693
Some of the functions that the editor scripts can use may take a lot of time to run. For example, `editor.execute("git", "status", {reload_resources=false, out="capture"})` can take up to a second on sufficiently large projects. To maintain editor responsiveness and performance, functions that may be time-consuming are not allowed in contexts where the editor needs an immediate response. Attempting to use such a function in an immediate context will result in an error: `Cannot use long-running editor function in immediate context`. To resolve this error, avoid using such functions in immediate contexts.
693694

694695
The following functions are considered long-running and cannot be used in immediate mode:
695-
- `editor.create_directory()`, `editor.delete_directory()`, `editor.save()`, `os.remove()` and `file:write()`: these functions modify the files on disc, causing the editor to synchronize its in-memory resource tree with the disc state, which can take seconds in large projects.
696+
- `editor.create_directory()`, `editor.create_resources()`, `editor.delete_directory()`, `editor.save()`, `os.remove()` and `file:write()`: these functions modify the files on disc, causing the editor to synchronize its in-memory resource tree with the disc state, which can take seconds in large projects.
696697
- `editor.execute()`: execution of shell commands can take an unpredictable amount of time.
697698
- `editor.transact()`: large transactions on widely-referenced nodes may take hundreds of milliseconds, which is too slow for UI responsiveness.
698699

docs/en/manuals/editor.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ You can also get access to editor logs while the editor is running if it is star
175175
$ > ./path/to/Defold.app/Contents/MacOS/Defold
176176
```
177177

178+
## Editor server
179+
180+
When the editor opens a project, it will start a web server on a random port. The server may be used to interact with the editor from other applications. Since 1.11.0, the port is written to the `.internal/editor.port` file.
181+
182+
Additionally, since 1.11.0 the editor executable has a command line option `--port` (or `-p`), which allows specifying the port during launch, e.g.::
183+
```shell
184+
# on Windows
185+
.\Defold.exe --port 8181
186+
187+
# on Linux:
188+
./Defold --port 8181
189+
190+
# on macOS:
191+
./Defold.app/Contents/MacOS/Defold --port 8181
192+
```
178193

179194
## FAQ
180195
:[Editor FAQ](../shared/editor-faq.md)

docs/en/manuals/font.md

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ Fonts added to your project are automatically converted into a texture format th
1616
- Bitmap
1717
- Distance field
1818

19-
::: sidenote
20-
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.
21-
:::
22-
23-
2419
## Creating a font
2520

2621
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>.
@@ -97,7 +92,7 @@ space ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E
9792
*Cache Width/Height*
9893
: 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.`).
9994

100-
If set to 0 the cache size is set automatically.
95+
If set to 0 the cache size is set automatically, and will grow to 2048x4096 max.
10196

10297
## Distance field fonts
10398

@@ -167,3 +162,79 @@ For example - to generate a gradient in a shader fragment, simply write:
167162
`float horizontal_gradient = fract(var_texcoord0.y / texture_size_recip.w);`
168163

169164
For more information about shader uniforms, see the [Shader manual](/manuals/shader).
165+
166+
## Runtime generation
167+
168+
It is possible to use runtime generation for SDF type fonts, when using TrueType (.ttf) fonts.
169+
This approach can greatly reduce the download size and runtime memory consumption of a Defold game.
170+
The small downside is a very small delay for each glyph generated at runtime.
171+
172+
Enable the feature by setting `font.runtime_generation` in game.project.
173+
174+
::: sidenote
175+
This feature is currently experimental, but with the intention to be used as the default workflow in the future.
176+
:::
177+
178+
::: important
179+
This setting affects all .ttf fonts in the project.
180+
:::
181+
182+
### Prewarming glyph cache
183+
184+
In order to make the runtime fonts easier to use, they support prewarming of the glyph cache.
185+
This means the font will generate the glyphs listed in *Characters* in the font.
186+
187+
::: sidenote
188+
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.
189+
:::
190+
191+
### Font Scripting
192+
193+
For runtime fonts, it's possible to add or removed sub fonts.
194+
This is useful when a large font has been split up into multiple files for different character sets (e.g. CJK)
195+
196+
::: important
197+
Adding a subfont doesn't automatically load or render all the glyphs.
198+
:::
199+
200+
```lua
201+
-- Add the range A-Z to the .fontc
202+
local font_hash = hash("/assets/fonts/roboto.fontc")
203+
local ttf_hash = hash("/assets/fonts/Roboto/Roboto-Bold.ttf")
204+
local codepoint_min = 0x00000041 -- A
205+
local codepoint_max = 0x0000005A -- Z
206+
font.add_source(font_hash, ttf_hash, codepoint_min, codepoint_max)
207+
```
208+
209+
```lua
210+
-- Remove the associated ttf resource
211+
local font_hash = hash("/assets/fonts/roboto.fontc")
212+
local ttf_hash = hash("/assets/fonts/Roboto/Roboto-Bold.ttf")
213+
font.remove_source(font_hash, ttf_hash)
214+
```
215+
216+
To load the glyphs to the font, you will need to call the `font.add_glyphs()`.
217+
It is an asynchronous operation, and once it's done, it's safe to progress to show any message containing the glyphs.
218+
219+
```lua
220+
local function add_glyph_callback(self, id, result, errmsg)
221+
if not result then
222+
print("Request " .. id .." finished with error:", errmsg)
223+
else
224+
msg.post(some_url, "show_dialog")
225+
end
226+
end
227+
228+
-- Load glyphs into the font
229+
local font_hash = hash("/assets/fonts/roboto.fontc")
230+
local glyphs = "Some text to be shown!" -- for optimal performance, make this a list of unique glyphs
231+
local request_id = font.add_glyphs(font_hash, ttf_hash, add_glyph_callback)
232+
```
233+
234+
And, once the characters aren't needed anymore, you can discard that memory:
235+
```lua
236+
-- Remove the associated ttf resource
237+
local font_hash = hash("/assets/fonts/roboto.fontc")
238+
font.remove_glyphs(font_hash, "All the characters in the set")
239+
```
240+
-12.8 KB
Loading

docs/en/manuals/live-update.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ There are currently two ways that Defold can store the resources. Choose the met
4848
`Zip`
4949
: This option tells Defold to create a Zip archive file with any excluded resources. The archive is saved at the location specified in the *Export path* setting.
5050

51+
`Folder`
52+
: This option tells Defold to create a folder with all the excluded resources. It works exactly the same way as Zip, but uses a directory instead of an archive. This may be useful in cases where you need to post-process files before uploading and plan to pack them into an archive yourself.
53+
5154
`Amazon`
5255
: This option tells Defold to automatically upload excluded resources to an Amazon Web Service (AWS) S3 bucket. Fill in your AWS *Credential profile* name, select the appropriate *Bucket* and provide a *Prefix* name. You can read more on how to setup an AWS account in this [aws guide](/manuals/live-update-aws)
5356

0 commit comments

Comments
 (0)