Repository navigation
OpenTypeFontPeer: implement canDisplay() and canDisplayUpTo() - #68
Merged
guillerodriguez merged 2 commits intoOct 29, 2026
Merged
Conversation
This was referenced Oct 14, 2026
duncanmcqueen
marked this pull request as ready for review
October 14, 2026 23:52
Both methods threw UnsupportedOperationException, so Font.canDisplay() failed for all OpenType fonts. A character can be displayed when the font maps it to a glyph other than the missing glyph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
duncanmcqueen
force-pushed
the
fix-opentype-candisplay
branch
from
October 15, 2026 13:51
c1ad239 to
ff5289b
Compare
guillerodriguez
requested changes
Oct 27, 2026
duncanmcqueen
added a commit
to duncanmcqueen/classpath
that referenced
this pull request
Oct 29, 2026
Combine a high surrogate and a following low surrogate before checking glyph support. Keep lookahead inside the requested limit, and return the high-surrogate index when a supplementary character is unsupported. Restore the iterator after an unsuccessful lookahead so the next character is still checked. Address guillerodriguez's review of PR ingelabs#68. Assisted-by: OpenAI gpt-6.1-sol via OpenCode
Combine a high surrogate and a following low surrogate before checking glyph support. Keep lookahead inside the requested limit, and return the high-surrogate index when a supplementary character is unsupported. Restore the iterator after an unsuccessful lookahead so the next character is still checked. Address guillerodriguez's review of PR ingelabs#68. Assisted-by: OpenAI gpt-6.1-sol via OpenCode Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
duncanmcqueen
force-pushed
the
fix-opentype-candisplay
branch
from
October 29, 2026 02:24
15a282a to
40d2dce
Compare
guillerodriguez
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #58.
Problem and fix
OpenTypeFontPeer.canDisplay()andcanDisplayUpTo()throwUnsupportedOperationException("Not yet implemented").Font.canDisplay()andFont.canDisplayUpTo()call them. Thus theseFontmethods fail with each toolkit that usesOpenTypeFontPeer, for example the X peer (gnu.java.awt.peer.x). The GTK peer usesGdkFontPeerand does not have this problem.Now a character can be displayed when the font maps it to a glyph that is not the missing glyph.
canDisplayUpTo()returns the index of the first character that cannot be displayed, or -1.How to reproduce
The test makes an
OpenTypeFontPeerdirectly, so it does not need a toolkit or a display. It needs the font file thatgnu/java/awt/font/fonts.propertiesgives forFreeSans:/usr/share/fonts/truetype/freefont/FreeSans.ttf. On Debian and Ubuntu, this file is in the packagefonts-freefont-ttf. My system does not have this file, so I put afonts.propertiesthat mapsFreeSans/pto DejaVu Sans beforeglibj.zip(-Xbootclasspath/p:).OpenTypeFontPeermaps the font file withFileChannel.map(). Ifconfiguredid not findmmap, the font does not load (see #62). In that case, use autoconf 2.71 or earlier, or apply #62.OpenTypeCanDisplay.javaResults
Linux x86_64, ingelabs/classpath
master(0406074), JamVMmaster,javacfrom JDK 8, autoconf 2.73, automake 1.19, theconfigureoptions of the CI Linux job, out-of-tree build. "Before" ismaster. "After" ismasterwith this commit.Platforms
Not specific to Haiku. The problem occurs with all toolkits that use
OpenTypeFontPeer. The Haiku toolkit (#61) also uses it.AI assistance
An AI model (Claude Code, by Anthropic) wrote this change, the test and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.
🤖 Generated with Claude Code