Skip to content

Add missing UTF-8.zh fontconfig sequences for the Windows tray menu - #4381

Closed
Red51531 wants to merge 1 commit into
cryptomator:developfrom
Red51531:patch-1
Closed

Red51531 wants to merge 1 commit into
cryptomator:developfrom
Red51531:patch-1

Conversation

@Red51531

@Red51531 Red51531 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chinese text in the Windows tray menu renders as squares. OpenJDK's Windows fontconfig defines sequence.allfonts.UTF-8.{hi,ja,ko} but no UTF-8.zh. With file.encoding=UTF-8, WFontConfiguration finds no GB2312_CHARSET component font for the AWT PopupMenu and falls back to Arial,ANSI_CHARSET. Korean has its own UTF-8.ko entry, which likely explains why it could not be reproduced with a Korean locale in #1474.

This PR generates runtime/lib/fontconfig.properties from the bundled .src after jlink, adding UTF-8.zh (+ zh.TW, zh.HK). FontConfiguration.findImpl() loads .properties before .bfc. file.encoding stays UTF-8, so no WinFsp/FUSE side effects. The build fails if the anchor line is missing, so a future JDK change cannot silently drop the patch.

Tested: Windows 11 (zh-CN), Cryptomator 1.19.6-msi-6588: the file produced by this script, loaded via -Dsun.awt.fontconfig, fixes the tray menu; an equivalent patch was also verified on a second machine. I did not build the installer or run the test suite locally (build-script-only change). zh_TW / zh_HK are untested.

This may be superseded by the native tray work (@purejava's Shell_NotifyIconW POC); it is meant as a low-risk interim fix.

Related Issues

Fixes #4215
Related to #1474

Checklist

  • I have run the tests locally and they pass
  • I have used generative AI tools to create this contribution and fully understand, reviewed, and tested the result (see Use of Generative AI)
  • I agree to follow the Code of Conduct

Addresses cryptomator#1474 (tray menu shows squares for Chinese on Windows).

**Cause:** OpenJDK's Windows fontconfig defines `sequence.allfonts.UTF-8.{hi,ja,ko}` but no `UTF-8.zh`. With `file.encoding=UTF-8`, `WFontConfiguration` finds no `GB2312_CHARSET` component font for the AWT `PopupMenu` and falls back to `Arial,ANSI_CHARSET`, so Chinese renders as squares. Korean has its own `UTF-8.ko` entry, which likely explains why it could not be reproduced with a Korean locale.

**Change:** after jlink, generate `runtime/lib/fontconfig.properties` from the bundled `.src`, adding `UTF-8.zh` (+ `zh.TW`, `zh.HK`). `FontConfiguration.findImpl()` loads `.properties` before `.bfc`. `file.encoding` stays UTF-8, so no WinFsp/FUSE side effects. The build fails if the anchor line is missing, so a future JDK change cannot silently drop the patch.

**Tested:** Windows 11 (zh-CN), Cryptomator 1.19.6-msi-6588. The file produced by this script, loaded via `-Dsun.awt.fontconfig`, fixes the tray menu; an equivalent patch was also verified on a second machine. I did not build the installer locally. zh_TW / zh_HK are untested.

This may be superseded by the native tray work (@purejava's Shell_NotifyIconW POC); it is meant as a low-risk interim fix.
@CLAassistant

CLAassistant commented Nov 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Comment thread dist/win/build.ps1
Comment on lines +146 to +147
$fontConfigSrc = Join-Path $runtimeImagePath 'lib\fontconfig.properties.src'
$fontConfigDst = Join-Path (Resolve-Path $runtimeImagePath) 'lib\fontconfig.properties'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you explain the asymmetry regarding $runtimeImagePath vs Resolve-Path $runtimeImagePath?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The asymmetry comes from the two different APIs consuming these paths:

  • $fontConfigSrc is read via Get-Content, a PowerShell cmdlet, which resolves relative paths against the PowerShell location ($PWD).
  • $fontConfigDst is written via [System.IO.File]::WriteAllText, a .NET method, which resolves relative paths against the process working directory ([Environment]::CurrentDirectory). PowerShell does not keep these two in sync, so after a cd in an interactive session, .\runtime\... could point to a different location.

Resolve-Path is applied to $runtimeImagePath rather than to the full destination path because fontconfig.properties does not exist yet at that point, and Resolve-Path fails on non-existent paths.

In CI both directories are identical, so there is no practical difference there. If you prefer, I can make it symmetric by resolving the runtime path once and using it for both:

$runtimeImageFullPath = (Resolve-Path $runtimeImagePath).Path
$fontConfigSrc = Join-Path $runtimeImageFullPath 'lib\fontconfig.properties.src'
$fontConfigDst = Join-Path $runtimeImageFullPath 'lib\fontconfig.properties'

@infeo

infeo commented Nov 5, 2026

Copy link
Copy Markdown
Member

@Red51531 Thank you for the analysis and contribution. We'll take it from here in #4384. Of course your contribution we'll be mentioned in the release notes.

@infeo infeo closed this Nov 5, 2026
@infeo infeo self-assigned this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Tray menu characters are garbled on Windows until manually changing config to GBK

5 participants