Skip to content

Fix/amharic font rendering#30354

Open
gittare wants to merge 2 commits intotelegramdesktop:devfrom
gittare:fix/amharic-font-rendering
Open

Fix/amharic font rendering#30354
gittare wants to merge 2 commits intotelegramdesktop:devfrom
gittare:fix/amharic-font-rendering

Conversation

@gittare
Copy link

@gittare gittare commented Feb 28, 2026

No description provided.

@CLAassistant
Copy link

CLAassistant commented Feb 28, 2026

CLA assistant check
All committers have signed the CLA.

@ilya-fedin
Copy link
Contributor

I don't see the lib_ui part

Comment on lines 265 to 266
auto fontFamily = settings().customFontFamily();
style::SetCustomFont(fontFamily);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ensures that the user-configured font family is properly applied during application initialization.

In version 6.5.1, Amharic (Ethiopic) characters were not rendered because the font fallback chain was not being correctly initialized. As a result, the default font did not provide proper glyph coverage for the Ethiopic Unicode block, and fallback was not triggered correctly. This caused Ethiopic characters to be invisible while numbers, punctuation, and emojis remained visible.

By explicitly calling:

auto fontFamily = settings().customFontFamily();
style::SetCustomFont(fontFamily);

we ensure that:

The selected/custom font family is applied early.

The font engine initializes with correct fallback behavior.

Unicode blocks such as Ethiopic are properly resolved through DirectWrite font fallback.

Missing glyph substitution no longer results in invisible characters.

After this change:

Amharic text renders correctly.

Fallback to system fonts (e.g., Segoe UI / Noto fallback) works as expected.

The issue is reproducibly resolved on Windows 10 and Windows 11.

This does not affect rendering for other scripts, as it only restores the expected initialization behavior of the font subsystem.

Please let me know if further instrumentation or logging is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but this is absolute nonsense. Please revert it.

Comment on lines 46 to 47
.description = "Use the font engine from Linux instead of the system one. "
"May help with Amharic, Ethiopic and other complex script rendering.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is not needed with the lib_ui fix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the lib_ui fix applied, this additional description/update is no longer strictly necessary.
The original intention of this change was to clarify that switching to the Linux font engine could help in cases where the Windows system font/fallback handling failed for Ethiopic (Amharic) and other complex scripts.
However, since the lib_ui fix correctly restores proper font initialization and fallback behavior, the rendering issue is resolved without requiring the Linux font engine workaround.
I can remove this part to avoid redundancy and keep the change minimal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please remove it.

delete base::take(_mapLoading);

const auto token = _config.mapsToken.toUtf8();
const auto token = EscapeForScriptString(_config.mapsToken.toUtf8());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ensures that the mapsToken value is safely embedded into the generated JavaScript string.
Previously:
const auto token = _config.mapsToken.toUtf8();
If the token contains characters such as quotes (" / '), backslashes, or other special characters, it could break the JavaScript string literal or lead to malformed script injection inside the web view.
By changing it to:
const auto token = EscapeForScriptString(_config.mapsToken.toUtf8());
we ensure that:

  1. Special characters are properly escaped.
  2. The generated script remains syntactically valid.
  3. There is no risk of unintended JS string termination.
  4. Potential script injection edge cases are avoided.

This does not change behavior for normal tokens but makes the code robust and safe if the token contains special characters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the font problem?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the font problem?

It was an additional robustness fix I noticed while reviewing the code, since the token is embedded into a JavaScript string without escaping. However, it is unrelated to the Ethiopic font rendering problem addressed in this PR.

If you prefer, I can remove this change to keep the PR strictly focused on the font issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, remove please.

@gittare
Copy link
Author

gittare commented Feb 28, 2026

my result
image

@ilya-fedin
Copy link
Contributor

Please fix the problems and answer questions in the issue. Thanks.

@gittare
Copy link
Author

gittare commented Feb 28, 2026

Please fix the problems and answer questions in the issue. Thanks.

i hope answering all questions

@ilya-fedin
Copy link
Contributor

Sorry, no, the problems aren't solved, when I click on the lib_ui changes, GitHub still says "There isn’t anything to compare". The questions you answered led to new questions and requests for reverts/removes.
image

@gittare gittare force-pushed the fix/amharic-font-rendering branch from 7aa2bc0 to 3728cc6 Compare February 28, 2026 14:27
@ilya-fedin
Copy link
Contributor

You made it worse, the changes must be in lib_ui

@gittare gittare force-pushed the fix/amharic-font-rendering branch from 3728cc6 to 54acaeb Compare February 28, 2026 15:03
[submodule "Telegram/lib_ui"]
path = Telegram/lib_ui
url = https://github.com/desktop-app/lib_ui.git
url = https://github.com/gittare/lib_ui.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to open the URL but got "Page not found"

Image
README.md Outdated
* Range-v3 ([Boost License](https://github.com/ericniebler/range-v3/blob/master/LICENSE.txt))
* Open Sans font ([Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html))
* Vazirmatn font ([SIL Open Font License 1.1](https://github.com/rastikerdar/vazirmatn/blob/master/OFL.txt))
* Abyssinica SIL font ([SIL Open Font License 1.1](https://software.sil.org/abyssinica/)) — Ethiopic/Amharic (via lib_ui)
Copy link
Contributor

@ilya-fedin ilya-fedin Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Abyssinica SIL font ([SIL Open Font License 1.1](https://software.sil.org/abyssinica/)) — Ethiopic/Amharic (via lib_ui)
* Abyssinica SIL font ([SIL Open Font License 1.1](https://github.com/silnrsi/font-abyssinica/blob/master/OFL.txt))
- Bundle Abyssinica SIL font in Telegram/Resources/fonts/
- Load font and add substitutions in application.cpp (Windows only)
- Location picker: escape maps token before eval (security)
- Fixes telegramdesktop#30184, telegramdesktop#30230

Made-with: Cursor
@gittare gittare force-pushed the fix/amharic-font-rendering branch from 54acaeb to b2d6df3 Compare February 28, 2026 16:46
- lib_ui: Abyssinica SIL font, Windows fallback (Fixes telegramdesktop#30184, telegramdesktop#30230)
- scripts: create-lib-ui-fork-and-push.ps1 - run after 'gh auth login'

Made-with: Cursor
```
Or: `powershell -File create-lib-ui-fork-and-push.ps1`

3. After success, https://github.com/gittare/lib_ui will exist with the Amharic font fix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF? You was supposed to do what is said in this file as far as I understand, not push it to tdesktop

@ilya-fedin
Copy link
Contributor

Will you continue the work or could the PR be closed?

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

Labels

None yet

3 participants