Windows and Linux: Physical font does not have fallback fonts.
林kurn
linkuntju at gmail.com
Fri Jan 12 12:56:19 UTC 2024
Hi everyone,
I am doing GUI development based on Java on Ubuntu, and I find some
problems in it.
Would it be possible for me to discuss with you?
1. There is no fallback font on Windows and Linux when using physical fonts.
The FileFont class does not implements FontSubstitution interface, so there
are no substituting glyphs from another font at render time(in
GlyphLayout::layout).
For example, when "jTextField.setFont(new Font("Ubuntu Mono", Font.PLAIN,
20))" on Ubuntu, all the CJK characters will show as tofu in this
jTextField. Almost every font does not contain all possible inputs, adding
some fallbacks font may help those who don't just use one language.
2. The fonts that JDK does not found are mapped to the “Dialog” font.
As
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#%3Cinit%3E(java.lang.String,int,int)
shows, If the name parameter represents something other than a logical
font, i.e. is interpreted as a physical font face or family, and this
cannot be mapped by the implementation to a physical font or a compatible
alternative, then the font system will map the Font instance to "Dialog".
On Linux, get map fonts by fontconfig may be more flexible, more
configurable.
For the two questions above, I have a preliminary patch.
I added a new fallback form “FONTCONFIGURATION_FALLBACK” and implemented it
for Linux system, it creates a composite font by obtaining map fonts info
for the specified name and style through fontconfig.
And I make the FileFont class implement the FontSubstitution interface,
reuse the FONTCONFIGURATION_FALLBACK code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240112/faa71b6f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Optimizes-how-information-is-retrieved-from-fontconf.patch
Type: application/octet-stream
Size: 10989 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240112/faa71b6f/0001-Optimizes-how-information-is-retrieved-from-fontconf-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Adds-a-new-fallback-form-FONTCONFIGURATION_FALLBACK.patch
Type: application/octet-stream
Size: 2837 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240112/faa71b6f/0002-Adds-a-new-fallback-form-FONTCONFIGURATION_FALLBACK-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Enables-glyphs-fallback-for-FileFont.patch
Type: application/octet-stream
Size: 2260 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240112/faa71b6f/0004-Enables-glyphs-fallback-for-FileFont-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Implements-the-FONTCONFIGURATION_FALLBACK-on-Linux.patch
Type: application/octet-stream
Size: 8946 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240112/faa71b6f/0003-Implements-the-FONTCONFIGURATION_FALLBACK-on-Linux-0001.patch>
More information about the client-libs-dev
mailing list