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

improvement: add CJK fonts and set them as fallback in the font resources #688

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wolfy7
Copy link
Contributor

@Wolfy7 Wolfy7 commented Oct 3, 2022

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.

Related issue (if applicable): #497

What is the current behavior?

Add some Traditional Chinese text to an Label with for example font_documentation_bold.tres as font.

image

What is the new behavior?

image

@NathanLovato
Copy link
Contributor

NathanLovato commented Oct 4, 2022

Thanks much! The PR looks good, I just need to check something with my teammates.

@Xananax @Razoric480 do you know if we have a way to separate these fonts and download them only when needed (when changing the language to Chinese or Japanese, for example) in HTML5 builds? They're pretty big, 5-7mb a piece (and that's per font weight and style), and it's gonna get worse as we add languages (Cyrillic, Arabic, ...), I wouldn't want the initial download to be drastically slowed down ideally.

@Xananax
Copy link
Contributor

Xananax commented Oct 4, 2022

I will look into it, in theory we can add pcks and load them at will like addons, but I've never done it for web

@Xananax
Copy link
Contributor

Xananax commented Oct 4, 2022

Any idea how to author packages?

There's a recommended method: https://docs.godotengine.org/en/stable/tutorials/export/exporting_pcks.html

But I'm not sure how to extract the changed files as a package from the main project on authoring. Should the files be moved into a different project, then the package built? If there's no provision for this in Godot, should we do this ourselves?

I'll start by working on the loading part and verify it can work properly, we can then think about the authoring part.

If we agree, then I'll open a different issue to track progress.

@NathanLovato
Copy link
Contributor

I would ask François or other Godot contributors for insights, as I've never used this feature before. Not sure if we can... just make a custom export template, or if we need a separate project

@NathanLovato
Copy link
Contributor

And yeah sounds good to figure out authoring the pck after ensuring that loading in the browser works

@Xananax Xananax mentioned this pull request Oct 4, 2022
2 tasks
@Razoric480
Copy link
Contributor

Razoric480 commented Oct 4, 2022

The ideal would be Godot supporting being able to white list directories, but so long as you're careful about what files are referenced, you can set the export mode of a given preset to selected resources and dependencies and only highlight the ones you want (and dis-highlight the ones you don't want from your main PCK export)

You can use download to res:// using HTTPRequest, apparently:

func _ready():
    var client = HTTPRequest.new()
    client.connect('request_completed', self, '_request_completed')
    add_child(client)
    client.download_file = "res://name of your pck file.pck"
    client.request("http://link to your pck file")
    
func _request_completed(result, response_code, headers, body):
    if response_code == 200:
        ProjectSettings.load_resource_pack("res://name of your pck file.pck")
        get_tree().change_scene("res://name of your scene inside .pck file")

though I haven't tested it.

The other approach is to preload the file through javascript prior to startGame() which would require a custom export page.

engine.preloadFile('main.pck').then(() => {
engine.startGame({

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 10, 2022

So are these changes okay and the seperation of the fonts will be handled in #691 ?

@NathanLovato
Copy link
Contributor

No, after spending some hours doing research on this it appears this approach will not work. We're going to have to handle everything in code, and the process is going to be quite a bit different. Sorry for having you work on this, it's unfortunately the kind of thing you don't know until you see the problems arise.

@Wolfy7
Copy link
Contributor Author

Wolfy7 commented Oct 10, 2022

No, problem.
Do you already have an idea how you will handle it in code? If there is anything i can help with, let me now.

@NathanLovato
Copy link
Contributor

Yes we have a good idea but the scope is bigger and the feature more complex than expected. This requires hosting files somewhere, downloading them, having various error handling, changing the fonts at runtime, etc. My teammate @Xananax will lay the foundations when he's available as he's experienced with networking. But this may take a while as we have other priorities at the moment.

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

Successfully merging this pull request may close these issues.

None yet

4 participants