Replace global oversampling with overrideable per-viewport oversampling.

This commit is contained in:
Pāvels Nadtočajevs 2025-03-30 14:20:25 +03:00
parent 215acd52e8
commit 4afeca3bcf
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
38 changed files with 1235 additions and 557 deletions

View file

@ -77,6 +77,12 @@
Removes all font sizes from the cache entry.
</description>
</method>
<method name="font_clear_system_fallback_cache">
<return type="void" />
<description>
Frees all automatically loaded system fonts.
</description>
</method>
<method name="font_clear_textures">
<return type="void" />
<param index="0" name="font_rid" type="RID" />
@ -94,8 +100,9 @@
<param index="3" name="pos" type="Vector2" />
<param index="4" name="index" type="int" />
<param index="5" name="color" type="Color" default="Color(1, 1, 1, 1)" />
<param index="6" name="oversampling" type="float" default="0.0" />
<description>
Draws single glyph into a canvas item at the position, using [param font_rid] at the size [param size].
Draws single glyph into a canvas item at the position, using [param font_rid] at the size [param size]. If [param oversampling] is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
</description>
@ -109,8 +116,9 @@
<param index="4" name="pos" type="Vector2" />
<param index="5" name="index" type="int" />
<param index="6" name="color" type="Color" default="Color(1, 1, 1, 1)" />
<param index="7" name="oversampling" type="float" default="0.0" />
<description>
Draws single glyph outline of size [param outline_size] into a canvas item at the position, using [param font_rid] at the size [param size].
Draws single glyph outline of size [param outline_size] into a canvas item at the position, using [param font_rid] at the size [param size]. If [param oversampling] is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
</description>
@ -203,10 +211,10 @@
Returns [code]true[/code] if font texture mipmap generation is enabled.
</description>
</method>
<method name="font_get_global_oversampling" qualifiers="const">
<method name="font_get_global_oversampling" qualifiers="const" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<return type="float" />
<description>
Returns the font oversampling factor, shared by all fonts in the TextServer.
Deprecated. This method always returns [code]1.0[/code].
</description>
</method>
<method name="font_get_glyph_advance" qualifiers="const">
@ -391,11 +399,11 @@
Returns [Dictionary] with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
</description>
</method>
<method name="font_get_oversampling" qualifiers="const">
<method name="font_get_oversampling" qualifiers="const" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<return type="float" />
<param index="0" name="font_rid" type="RID" />
<description>
Returns font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Deprecated. This method always returns [code]1.0[/code].
</description>
</method>
<method name="font_get_scale" qualifiers="const">
@ -421,6 +429,13 @@
Returns list of script support overrides.
</description>
</method>
<method name="font_get_size_cache_info" qualifiers="const">
<return type="Dictionary[]" />
<param index="0" name="font_rid" type="RID" />
<description>
Returns font cache information, each entry contains the following fields: [code]Vector2i size_px[/code] - font size in pixels, [code]float viewport_oversampling[/code] - viewport oversampling factor, [code]int glyphs[/code] - number of rendered glyphs, [code]int textures[/code] - number of used textures, [code]int textures_size[/code] - size of texture data in bytes.
</description>
</method>
<method name="font_get_size_cache_list" qualifiers="const">
<return type="Vector2i[]" />
<param index="0" name="font_rid" type="RID" />
@ -771,12 +786,11 @@
If set to [code]true[/code] font texture mipmap generation is enabled.
</description>
</method>
<method name="font_set_global_oversampling">
<method name="font_set_global_oversampling" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<return type="void" />
<param index="0" name="oversampling" type="float" />
<description>
Sets oversampling factor, shared by all font in the TextServer.
[b]Note:[/b] This value can be automatically changed by display server.
Deprecated. This method does nothing.
</description>
</method>
<method name="font_set_glyph_advance">
@ -914,12 +928,12 @@
Sets font OpenType feature set override.
</description>
</method>
<method name="font_set_oversampling">
<method name="font_set_oversampling" deprecated="Use [Viewport] oversampling, or the [code skip-lint]oversampling[/code] argument of the [code skip-lint]draw_*[/code] methods instead.">
<return type="void" />
<param index="0" name="font_rid" type="RID" />
<param index="1" name="oversampling" type="float" />
<description>
Sets font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Deprecated. This method does nothing.
</description>
</method>
<method name="font_set_scale">
@ -1383,8 +1397,9 @@
<param index="3" name="clip_l" type="float" default="-1" />
<param index="4" name="clip_r" type="float" default="-1" />
<param index="5" name="color" type="Color" default="Color(1, 1, 1, 1)" />
<param index="6" name="oversampling" type="float" default="0.0" />
<description>
Draw shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
Draw shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). If [param oversampling] is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
</description>
</method>
<method name="shaped_text_draw_outline" qualifiers="const">
@ -1396,8 +1411,9 @@
<param index="4" name="clip_r" type="float" default="-1" />
<param index="5" name="outline_size" type="int" default="1" />
<param index="6" name="color" type="Color" default="Color(1, 1, 1, 1)" />
<param index="7" name="oversampling" type="float" default="0.0" />
<description>
Draw the outline of the shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
Draw the outline of the shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). If [param oversampling] is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
</description>
</method>
<method name="shaped_text_fit_to_width">