mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-02 03:00:23 +03:00
Fix: UISceneNode::reevaluateFontStyle() now preserves an existing FontTrueType family when it already owns the requested bold, italic, or bold-italic variant.
This commit is contained in:
@@ -2418,6 +2418,15 @@ Font* UISceneNode::reevaluateFontStyle( Font* currentFont, Uint32 fontStyle,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto authorFamilyIt = mFontFaceFamilies.find( currentFont );
|
auto authorFamilyIt = mFontFaceFamilies.find( currentFont );
|
||||||
|
auto* currentTrueTypeFont = static_cast<FontTrueType*>( currentFont );
|
||||||
|
if ( authorFamilyIt == mFontFaceFamilies.end() ) {
|
||||||
|
const Uint32 weightStyle = fontStyle & ( Text::Bold | Text::Italic );
|
||||||
|
if ( ( weightStyle == Text::Bold && currentTrueTypeFont->getBoldFont() ) ||
|
||||||
|
( weightStyle == Text::Italic && currentTrueTypeFont->getItalicFont() ) ||
|
||||||
|
( weightStyle == ( Text::Bold | Text::Italic ) &&
|
||||||
|
currentTrueTypeFont->getBoldItalicFont() ) )
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if ( authorFamilyIt == mFontFaceFamilies.end() && !SystemFontResolver::isEnabled() )
|
if ( authorFamilyIt == mFontFaceFamilies.end() && !SystemFontResolver::isEnabled() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,26 @@ UTEST( FontRendering, loadingFontFamilyDoesNotCreateTexturePages ) {
|
|||||||
EXPECT_EQ( textureCount, textureFactory->getTextureCount() );
|
EXPECT_EQ( textureCount, textureFactory->getTextureCount() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UTEST( FontRendering, systemResolverPreservesRelatedBoldFont ) {
|
||||||
|
UIApplication app(
|
||||||
|
WindowSettings( 320, 240, "eepp - Preserve Related Bold Font", WindowStyle::Default,
|
||||||
|
WindowBackend::Default, 32 ),
|
||||||
|
UIApplication::Settings( Sys::getProcessPath() + ".." + FileSystem::getOSSlash(), 1 ) );
|
||||||
|
ResourceScope& scope = *app.getUI()->getResourceScope();
|
||||||
|
FontTrueTypePtr font = FontTrueType::New( "BundledNotoSans-Regular", scope );
|
||||||
|
ASSERT_TRUE(
|
||||||
|
font->loadFromFile( Sys::getProcessPath() + "../assets/fonts/NotoSans-Regular.ttf" ) );
|
||||||
|
FontFamily::loadFromRegular( font.get() );
|
||||||
|
ASSERT_TRUE( font->getBoldFont() );
|
||||||
|
FontTrueType* bundledBold = font->getBoldFont().get();
|
||||||
|
|
||||||
|
SystemFontResolver::setEnabled( true );
|
||||||
|
EXPECT_EQ( nullptr,
|
||||||
|
app.getUI()->reevaluateFontStyle( font.get(), Text::Bold, FontWeight::Bold ) );
|
||||||
|
EXPECT_EQ( bundledBold, font->getGlyph( 'A', 16, true, false ).font );
|
||||||
|
SystemFontResolver::setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
UTEST( FontRendering, regularFontOwnsRelatedFonts ) {
|
UTEST( FontRendering, regularFontOwnsRelatedFonts ) {
|
||||||
FontTrueTypePtr font = FontTrueType::New( "RelatedFonts-Regular" );
|
FontTrueTypePtr font = FontTrueType::New( "RelatedFonts-Regular" );
|
||||||
FontTrueTypePtr bold = FontTrueType::New( "RelatedFonts-Bold" );
|
FontTrueTypePtr bold = FontTrueType::New( "RelatedFonts-Bold" );
|
||||||
|
|||||||
Reference in New Issue
Block a user