Should fix unit-tests.

This commit is contained in:
Martín Lucas Golini
2026-07-26 00:04:03 -03:00
parent 9f4ae9e83c
commit 521e2af2e2
5 changed files with 17 additions and 3 deletions
+1
View File
@@ -2064,6 +2064,7 @@ FontTrueType::Page::~Page() {
}
void FontTrueType::clearCache() {
sendEvent( Event::CacheClear );
mPages.clear();
mClosestCharacterSize.clear();
mCodePointIndexCache.clear();
+3 -1
View File
@@ -65,7 +65,9 @@ UIGlyphIcon::UIGlyphIcon( const std::string& name, FontTrueType* font, const Uin
UIIcon( name ), mFont( font ), mCodePoint( codePoint ) {
eeASSERT( mFont );
mCloseCb = mFont->pushFontEventCallback( [this]( Uint32, Font::Event event, Font* ) {
if ( event == Font::Event::Unload )
if ( event == Font::Event::CacheClear )
mSizes.clear();
else if ( event == Font::Event::Unload )
mFont = nullptr;
} );
}
@@ -23,6 +23,7 @@
#include <eepp/ui/doc/syntaxdefinitionmanager.hpp>
#include <eepp/ui/uiapplication.hpp>
#include <eepp/ui/uicodeeditor.hpp>
#include <eepp/ui/uiicon.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uitextview.hpp>
@@ -87,10 +88,20 @@ UTEST( FontRendering, subpixelCoverageCompositesPerChannel ) {
const Float grayscaleLAdvance = font->getGlyphAdvance( 'l', 28 );
const Float grayscaleDAdvance = font->getGlyphAdvance( 'd', 28 );
const Float grayscaleKerning = font->getKerning( 'i', 'd', 28, false, false );
UIIconPtr icon = UIGlyphIcon::New( "glyph-cache-test", font.get(), 'S' );
const DrawablePtr grayscaleIcon = icon->getSource( 28 );
ASSERT_TRUE( grayscaleIcon );
ASSERT_EQ( GlyphRenderMode::Mask,
static_cast<GlyphDrawable*>( grayscaleIcon.get() )->getGlyphRenderMode() );
font->setAntialiasing( FontAntialiasing::Subpixel );
EXPECT_EQ( grayscaleLAdvance, font->getGlyphAdvance( 'l', 28 ) );
EXPECT_EQ( grayscaleDAdvance, font->getGlyphAdvance( 'd', 28 ) );
EXPECT_EQ( grayscaleKerning, font->getKerning( 'i', 'd', 28, false, false ) );
const DrawablePtr subpixelIcon = icon->getSource( 28 );
ASSERT_TRUE( subpixelIcon );
EXPECT_NE( grayscaleIcon.get(), subpixelIcon.get() );
EXPECT_EQ( GlyphRenderMode::Subpixel,
static_cast<GlyphDrawable*>( subpixelIcon.get() )->getGlyphRenderMode() );
GlyphDrawable* drawable = font->getGlyphDrawable( 'S', 28 );
ASSERT_TRUE( drawable );