Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextServer / Font] Do not duplicate images to prevent unnecessary embedding. #87971

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Feb 5, 2024

Fixes #82254

Note: this only works if images were imported and loaded using load/preload, in other cases images are still embedded (there's no other way).

Images for the imported BMFonts are embedded as well, since it can be packed and require conversion before used (we probably should add ignore import option, and auto set it for the BMFont images).

e.g.,:

@tool
extends FontFile
class_name MyFont

const FONT_SIZE = Vector2i(16, 16)

func _init():
	clear_cache()
	
	var image = load("res://SuperWhite.png")
	set_texture_image(0, FONT_SIZE, 0, image)
[gd_resource type="FontFile" script_class="MyFont" load_steps=3 format=3 uid="uid://df8eka62scrfs"]

[ext_resource type="Image" uid="uid://d1bu5rv3qc5oe" path="res://SuperWhite.png" id="1_q7u5v"]
[ext_resource type="Script" path="res://my_font.gd" id="2_dlquq"]

[resource]
cache/0/16/16/textures/0/offsets = PackedInt32Array()
cache/0/16/16/textures/0/image = ExtResource("1_q7u5v")
cache/0/16/0/ascent = 0.0
cache/0/16/0/descent = 0.0
cache/0/16/0/underline_position = 0.0
cache/0/16/0/underline_thickness = 0.0
cache/0/16/0/scale = 1.0
cache/0/16/0/kerning_overrides/16/16 = Vector2(0, 0)
cache/0/16/0/kerning_overrides/16/0 = Vector2(0, 0)
script = ExtResource("2_dlquq")

@akien-mga akien-mga merged commit eac054f into godotengine:master Feb 15, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants