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

Allow specifying font name in fontSources config #19269

Open
danielhjacobs opened this issue Jan 18, 2025 · 2 comments
Open

Allow specifying font name in fontSources config #19269

danielhjacobs opened this issue Jan 18, 2025 · 2 comments
Labels
A-web Area: Web & Extensions enhancement New feature or request text Issues relating to text rendering/input

Comments

@danielhjacobs
Copy link
Contributor

danielhjacobs commented Jan 18, 2025

Describe the feature
Provide a clear and concise description of your feature request. Why would this feature be useful? Does the feature involve the desktop build, the web build, or both?

When using a TTF file as a font source, can there be a way to specify the name (and maybe also boldness and italicness) of the font for which to use that TTF file? Right now, it's based on the font name defined within the TTF file or falls back to the URL if no font name exists within the TTF file, but if you didn't create the TTF file and don't have the ability to edit the SWF file the font name in the TTF file may not match the font name requested by the SWF.

ruffle/web/src/builder.rs

Lines 422 to 433 in 41e373c

let full_name = face
.names()
.into_iter()
.find(|name| name.name_id == ttf_parser::name_id::FULL_NAME)
.and_then(|name| name.to_string());
let name = if let Some(full_name) = full_name {
full_name
} else {
tracing::warn!("Font {url} at index {index} has no full name, using URL as font name");
url.to_string()
};

@danielhjacobs danielhjacobs added A-web Area: Web & Extensions enhancement New feature or request extension Related to the Ruffle WebExtension text Issues relating to text rendering/input and removed extension Related to the Ruffle WebExtension labels Jan 18, 2025
@danielhjacobs
Copy link
Contributor Author

Side note: It's pretty useless that it falls back to the as-is URL. It may be at least slightly useful if it fell back to the URL slug sans file extension.

@danielhjacobs
Copy link
Contributor Author

danielhjacobs commented Jan 18, 2025

Also note, because fontSources is defined as an array of strings currently, support for this may require letting fontSources be an array of strings or a structure like this and doing different logic depending which it is:

fontSources: [
    "fonts/Noto-Sans-Bold.swf": {
        "name": "Noto Sans",
        "bold": true,
        "italics": false
     }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions enhancement New feature or request text Issues relating to text rendering/input
Projects
None yet
Development

No branches or pull requests

1 participant