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

Fix fonts loading #9888

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Fix fonts loading #9888

wants to merge 10 commits into from

Conversation

dawoodkhan82
Copy link
Collaborator

@dawoodkhan82 dawoodkhan82 commented Nov 1, 2024

Description

Fixes system fonts not loading properly
Screenshot 2024-12-04 at 1 23 51 PM

Closes: #(issue)

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Nov 1, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/6d890c3dcad56e67d9d84dc5a35c23fd15db377f/gradio-5.8.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@6d890c3dcad56e67d9d84dc5a35c23fd15db377f#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/6d890c3dcad56e67d9d84dc5a35c23fd15db377f/gradio-client-1.8.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/6d890c3dcad56e67d9d84dc5a35c23fd15db377f/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Nov 1, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fix fonts loading

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@dawoodkhan82 dawoodkhan82 marked this pull request as ready for review December 4, 2024 12:52
@abidlabs abidlabs added the v: patch A change that requires a patch release label Dec 4, 2024
@abidlabs abidlabs requested a review from aliabid94 December 4, 2024 18:27
@aliabid94
Copy link
Collaborator

This did not work for me. Try

import gradio as gr

with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
    name = gr.Textbox(label="Name")
    greet_btn = gr.Button("Greet")

if __name__ == "__main__":
    demo.launch(ssr_mode=True)

and then also with ssr_mode=False and you'll see the fonts don't load when ssr_mode=True

@dawoodkhan82
Copy link
Collaborator Author

@aliabid94 Where are you seeing that the fonts don't load? i don't see any console errors, and the fonts look the same to me in both ssr and non-ssr modes. (Although I only see the fonts load in front end built mode, not dev mode)

@anirbanbasu
Copy link
Contributor

@aliabid94 Where are you seeing that the fonts don't load? i don't see any console errors, and the fonts look the same to me in both ssr and non-ssr modes. (Although I only see the fonts load in front end built mode, not dev mode)

@dawoodkhan82
You won't see any errors in the output of the Gradio app. However, if you inspect the element in the web browser's console, here's how it would look like.

Screenshot 2024-12-06 at 6 58 00

Clearly, the computed CSS is asking to load the correct font but the browser is rendering with a different font.

@anirbanbasu
Copy link
Contributor

@abidlabs, as an aside but related to ssr_mode, the environment variable GRADIO_SSR_MODE is not documented in https://www.gradio.app/guides/environment-variables but referenced on these two lines:

else os.getenv("GRADIO_SSR_MODE", "False").lower() == "true"
and
else os.getenv("GRADIO_SSR_MODE", "False").lower() == "true"
.

As yet another aside, the once SSR mode is enabled, a node server is started along with the Gradio server. However, at least on macOS (15.1.1), if I press Ctrl+C to stop the Gradio server, it keeps on waiting indefinitely to terminate the node process (with a message Stopping Node.js server...) and keeps waiting.

These should be addressed as separate issues, I guess.

@anirbanbasu
Copy link
Contributor

These should be addressed as separate issues, I guess.

Opened issues #10138 and #10139

@pngwn pngwn added the t: fix A change that implements a fix label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: fix A change that implements a fix v: patch A change that requires a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants