Skip to content

GUI: Fix handling of app font change#4510

Merged
gzotti merged 13 commits intomasterfrom
GUI/font-reload
Sep 15, 2025
Merged

GUI: Fix handling of app font change#4510
gzotti merged 13 commits intomasterfrom
GUI/font-reload

Conversation

@gzotti
Copy link
Member

@gzotti gzotti commented Sep 11, 2025

Description

StelApp is the only element which ever accepts a font change.
Currently, several StelModules have their own fonts which may get initialized at startup, but then only size was changed.

When switching font, the font change should become effective immediately, not only after relaunch.

This is a first step to hopefully fix the font issues which appeared with Skycultures demands.

This branch should be used to

Screenshots (if appropriate):

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

How Has This Been Tested?

Test Configuration:

  • Operating system: Windows 11
  • Graphics Card: irrelevant

Checklist:

  • My code follows the code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (header file)
  • I have updated the respective chapter in the Stellarium User Guide
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@gzotti gzotti added this to the 25.3 milestone Sep 11, 2025
@gzotti gzotti self-assigned this Sep 11, 2025
@gzotti gzotti added enhancement Improve existing functionality importance: high Obvious error, very annoying, but no crash labels Sep 11, 2025
@gzotti gzotti added this to GUI Sep 11, 2025
@github-project-automation github-project-automation bot moved this to Backlog in GUI Sep 11, 2025
@github-actions github-actions bot requested review from 10110111 and alex-w September 11, 2025 18:29
@github-actions
Copy link

Hello @gzotti!

Thank you for the suggested improvement.

@gzotti
Copy link
Member Author

gzotti commented Sep 12, 2025

It seems at least the full strings are now again visible, and font change is immediately visible.

@gzotti
Copy link
Member Author

gzotti commented Sep 12, 2025

@10110111 @alex-w do you see Cuneiform even if you have set Noto Sans as app font? I must switch to Noto Sans Cuneiform, and then vertical spacing is weird.

The bounding box issues may depend on QString's append and handling of mixed LTR/RTL strings. Are you familiar with the problem? I would like to have the native string always on the left side.

@10110111
Copy link
Contributor

do you see Cuneiform even if you have set Noto Sans as app font?

Yes, I set Noto Sans in the rightmost combobox, and the cuneiforms are still visible. Not sure what the one on the left does, but it's set to Latin by default, and doesn't contain any cuneiform option.

The bounding box issues may depend on QString's append and handling of mixed LTR/RTL strings. Are you familiar with the problem? I would like to have the native string always on the left side.

I'm not familiar with the issue, but what I'd try is render the separate strings to separate surfaces, and then join them in the desired order physically (rather than typographically), separated by the width of a space character.

@gzotti
Copy link
Member Author

gzotti commented Sep 12, 2025

do you see Cuneiform even if you have set Noto Sans as app font?

Yes, I set Noto Sans in the rightmost combobox, and the cuneiforms are still visible.

Argh, this is different on Windows then. I was looking for optional OS features like "international support", but did not find anything relevant (aside from eastern Asian fonts of course)

Not sure what the one on the left does, but it's set to Latin by default, and doesn't contain any cuneiform option.

The left combo allows setting a font family, and then the right then provides the list which fonts contain the respective glyphs, with samples where applicable. Indeed, no Cuneiform family here, and the Noto Cuneiform also has no glyph samples. It seems that some font features are optional and missing.

The bounding box issues may depend on QString's append and handling of mixed LTR/RTL strings. Are you familiar with the problem? I would like to have the native string always on the left side.

I'm not familiar with the issue, but what I'd try is render the separate strings to separate surfaces, and then join them in the desired order physically (rather than typographically), separated by the width of a space character.

That was an option I see as last-resort, but sure, it's a way to go. Unless we want to keep "gravity" labels.

... Grmpf - Gravity labels don't work with Cuneiform! Just showing question mark roadsigns. OTOH, Arab strings are placed to the left where I want them. ... BUT character-reversed! OMG, new features, new nightmares...

EDIT:

Maybe this helps for label collation:

@alex-w
Copy link
Member

alex-w commented Sep 12, 2025

Qt5: error: cannot call member function ‘QStringList QFontDatabase::families(WritingSystem) const’ without object

@gzotti
Copy link
Member Author

gzotti commented Sep 13, 2025

Qt5: error: cannot call member function ‘QStringList QFontDatabase::families(WritingSystem) const’ without object

I am developing this for diagnostics. Not sure we will ever need it in the end, or it can just be encircled with ifdefs.

@10110111
Copy link
Contributor

10110111 commented Sep 13, 2025

Just checked on Windows 11 Home installation that has never been on the Internet, and Notepad shows cuneiform characters regardless of the font configured in its settings, even Times New Roman. OTOH, Stellarium shows empty rectangles instead of cuneiforms in all labels, info strings and input fields.

So the conclusion is that some cuneiform-enabled font is already present in the system (apparently, it's Segoe UI Historic), but Qt isn't able to pick it up. Maybe it needs some special configuration for this, I don't know.

@gzotti
Copy link
Member Author

gzotti commented Sep 13, 2025

Thanks for this. Seems we need to understand a few things around Qt's Unicode and font handling much better. :-(

@gzotti
Copy link
Member Author

gzotti commented Sep 14, 2025

This creates good labels and IMHO solves #4493. However, it may be better to do that FSI/PDI enclosing already when reading the culturalName from file, and change that from struct to object, with getters and setters that guarantees such embeddings. @alex-w , @10110111 opinions?

I have not started changing code around gravityLabels. Probably the complete label will have to be split on FSI/PDI regexps, and where applicable, the angular rendering handled in some yet-to-invent ways.

@gzotti gzotti marked this pull request as ready for review September 14, 2025 14:11
@github-actions github-actions bot requested a review from alex-w September 14, 2025 14:12
@gzotti
Copy link
Member Author

gzotti commented Sep 14, 2025

@10110111 's hint on QFontDatabase::addApplicationFallbackFontFamily() nailed it. No need for extra fonts, just set one as fallback. My previous question about when to place the Unicode isolation characters remains open. And again, GravityLabels are not fixed in this PR.

@10110111
Copy link
Contributor

Note that QFontDatabase::addApplicationFallbackFontFamily is only available since Qt 6.8. If we want to support older Qt versions, we need to add a version check. Of course, our official Qt6-based package then must use Qt 6.8+.

@gzotti
Copy link
Member Author

gzotti commented Sep 14, 2025

Uh, again thanks for that hint. I hope it is no problem to set the Windows CI to Qt6.8 also for Arm ( @alex-w ?) I will add the version check, and the feature will just not work nicely on Qt5 builds.

@alex-w
Copy link
Member

alex-w commented Sep 14, 2025

It's interesting - I see hieroglyphs and cuneiform on the mac when DejaVue Sans font selected :)

@alex-w
Copy link
Member

alex-w commented Sep 14, 2025

I hope it is no problem to set the Windows CI to Qt6.8 also for Arm ( @alex-w ?)

I tried use Qt6.8 for arm, but without success

@gzotti
Copy link
Member Author

gzotti commented Sep 14, 2025

It's interesting - I see hieroglyphs and cuneiform on the mac when DejaVue Sans font selected :)

Apparently just what Linuxians experience. Either your version of DejaVue Sans contains the glyphs, or a fallback handler becomes active. This is what the latest change did to Windows: declare which font to use to retrieve missing characters of a particular character class. Finally I can again set any font (decorative handwriting, blackletter, ... however ugly I want my UI to be), and the Cuneiform letters come from Segoe UI Historical.

@gzotti
Copy link
Member Author

gzotti commented Sep 14, 2025

I will rebase a bit before merging. But happy to have reached at least this stage in 25.3.

@alex-w alex-w moved this from Backlog to In review in GUI Sep 14, 2025
@github-actions github-actions bot added the has conflicts The pull request has conflicts label Sep 15, 2025
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the has conflicts The pull request has conflicts label Sep 15, 2025
@github-actions
Copy link

Conflicts have been resolved. A maintainer will review the pull request shortly.

@gzotti gzotti merged commit a6add20 into master Sep 15, 2025
30 of 31 checks passed
@gzotti gzotti deleted the GUI/font-reload branch September 15, 2025 08:54
@github-project-automation github-project-automation bot moved this from In review to Done in GUI Sep 15, 2025
@alex-w alex-w added the state: published The fix has been published for testing in weekly binary package label Sep 17, 2025
@github-actions
Copy link

Hello @gzotti!

Please check the fresh version (development snapshot) of Stellarium:
https://github.com/Stellarium/stellarium-data/releases/tag/weekly-snapshot

gzotti added a commit that referenced this pull request Sep 20, 2025
- also better align symbols with right edge
- but don't use 2-degree offset to avoid collision with symbols
- matter of taste...
@alex-w alex-w removed the state: published The fix has been published for testing in weekly binary package label Sep 29, 2025
@github-actions
Copy link

Hello @gzotti!

Please check the latest stable version of Stellarium:
https://github.com/Stellarium/stellarium/releases/latest

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

Labels

enhancement Improve existing functionality importance: high Obvious error, very annoying, but no crash

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Arabic Al-Sufi lunar mansions' names are shifted with respect to their sections Bab. SCs: add cuneiform in "Native" tags

3 participants