On Sat, 24 Oct 2026 18:02:45 GMT, Marius Hanl <[email protected]> wrote:

>> No it can't - needs the real `PrismLayout`.
>
> Did you check the link even? `onlyReuseRuns` can be tested, which I did. This 
> is what this comment is about.

Just gave it a shot, this is what I meant:


    @Test
    public void testTextLayoutWithTabsIsNotCached() {
        Font font = Font.font("Amble", 11);
        Object nativeFont = FontHelper.getNativeFont(font);

        AtomicInteger glyphLayoutCreationCounter = new AtomicInteger();

        StubTextLayout textLayout = new StubTextLayout(256) {
            @Override
            protected GlyphLayout glyphLayout() {
                glyphLayoutCreationCounter.addAndGet(1);
                return super.glyphLayout();
            }
        };
        setTextLayout(textLayout, "TEXT\tTAB", nativeFont, 
TextLayout.BOUNDS_CENTER);
        assertEquals(1, glyphLayoutCreationCounter.get());

        // We set the same text again, but still expect a cache miss as the 
text contains tabs.
        setTextLayout(textLayout, "TEXT\tTAB", nativeFont, 
TextLayout.BOUNDS_CENTER);
        assertEquals(2, glyphLayoutCreationCounter.get());
    }


Note that this does not mean your system test is obsolete -- it is perfectly 
valid and needed. But as you probably also know, there are many bugs in font / 
text code, and every headless tests makes catching regressions easier.
So I'm very strongly in favor of one. Feel free to just copy mine.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2352#discussion_r4368102104

Reply via email to