Try again, not sure what failed in Windows tests (cannot repro).

This commit is contained in:
Martín Lucas Golini
2025-11-16 11:02:42 -03:00
parent 276c481f00
commit 24e8ec447b
2 changed files with 27 additions and 27 deletions

View File

@@ -225,20 +225,20 @@ class EE_API FontTrueType : public Font {
mutable PageTable mPages; ///< Table containing the glyphs pages by character size
mutable std::vector<Uint8>
mPixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture
bool mBoldAdvanceSameAsRegular : 1 { false };
bool mIsColorEmojiFont : 1 { false };
bool mIsEmojiFont : 1 { false };
bool mHasSvgGlyphs : 1 { false };
bool mHasColrGlyphs : 1 { false };
mutable bool mIsMonospace : 1 { false };
mutable bool mIsMonospaceComplete : 1 { false };
mutable bool mUsingFallback : 1 { false };
bool mEnableEmojiFallback : 1 { true };
bool mEnableFallbackFont : 1 { true };
bool mEnableDynamicMonospace : 1 { false };
bool mIsBold : 1 { false };
bool mIsItalic : 1 { false };
mutable bool mIsMonospaceCompletePending : 1 { false };
bool mBoldAdvanceSameAsRegular{ false };
bool mIsColorEmojiFont{ false };
bool mIsEmojiFont{ false };
bool mHasSvgGlyphs{ false };
bool mHasColrGlyphs{ false };
mutable bool mIsMonospace{ false };
mutable bool mIsMonospaceComplete{ false };
mutable bool mUsingFallback{ false };
bool mEnableEmojiFallback{ true };
bool mEnableFallbackFont{ true };
bool mEnableDynamicMonospace{ false };
bool mIsBold{ false };
bool mIsItalic{ false };
mutable bool mIsMonospaceCompletePending{ false };
mutable UnorderedMap<unsigned int, unsigned int> mClosestCharacterSize;
mutable UnorderedMap<Uint32, Uint32> mCodePointIndexCache;
mutable UnorderedMap<Uint32, std::tuple<Uint32, Uint32, bool>> mKeyCache;

View File

@@ -306,8 +306,6 @@ bool FontTrueType::loadFromFile( const std::string& filename ) {
}
mLibrary = library;
FT_Property_Set( static_cast<FT_Library>( mLibrary ), "ot-svg", "svg-hooks", &svg_hooks );
// Load the new font face from the specified file
FT_Face face;
if ( FT_New_Face( static_cast<FT_Library>( mLibrary ), filename.c_str(), 0, &face ) != 0 ) {
@@ -342,8 +340,6 @@ bool FontTrueType::loadFromMemory( const void* data, std::size_t sizeInBytes, bo
}
mLibrary = library;
FT_Property_Set( static_cast<FT_Library>( mLibrary ), "ot-svg", "svg-hooks", &svg_hooks );
// Load the new font face from the specified file
FT_Face face;
if ( FT_New_Memory_Face( static_cast<FT_Library>( mLibrary ),
@@ -368,8 +364,6 @@ bool FontTrueType::loadFromStream( IOStream& stream ) {
}
mLibrary = library;
FT_Property_Set( static_cast<FT_Library>( mLibrary ), "ot-svg", "svg-hooks", &svg_hooks );
// Make sure that the stream's reading position is at the beginning
stream.seek( 0 );
@@ -435,6 +429,9 @@ bool FontTrueType::setFontFace( void* _face ) {
mIsBold = face->style_flags & FT_STYLE_FLAG_BOLD;
mIsItalic = face->style_flags & FT_STYLE_FLAG_ITALIC;
if ( mHasSvgGlyphs )
FT_Property_Set( static_cast<FT_Library>( mLibrary ), "ot-svg", "svg-hooks", &svg_hooks );
if ( ( mIsColorEmojiFont || mHasSvgGlyphs || mHasColrGlyphs ) &&
FontManager::instance()->getColorEmojiFont() == nullptr )
FontManager::instance()->setColorEmojiFont( this );
@@ -1030,10 +1027,14 @@ static int fontSetLoadOptions( FontAntialiasing antialiasing, FontHinting hintin
return load_target | hint;
}
static constexpr FT_Render_Mode
fontSetRenderOptions( FT_Library library, FontAntialiasing antialiasing, FontHinting hinting ) {
static constexpr FT_Render_Mode fontSetRenderOptions( FT_Library library,
FontAntialiasing antialiasing,
FontHinting hinting,
FT_Glyph_Format glyphFormat ) {
if ( antialiasing == FontAntialiasing::None )
return FT_RENDER_MODE_MONO;
if ( glyphFormat == FT_GLYPH_FORMAT_SVG )
return FT_RENDER_MODE_NORMAL;
if ( antialiasing == FontAntialiasing::Subpixel ) {
unsigned char weights[] = { 0x10, 0x40, 0x70, 0x40, 0x10 };
switch ( hinting ) {
@@ -1086,6 +1087,8 @@ Glyph FontTrueType::loadGlyphByIndex( Uint32 index, unsigned int characterSize,
FT_Error err = 0;
auto loadOptions = fontSetLoadOptions( mAntialiasing, mHinting );
if ( mIsColorEmojiFont || mHasSvgGlyphs )
loadOptions = FT_LOAD_TARGET_NORMAL;
// Load the glyph corresponding to the code point
FT_Int32 flags = loadOptions | FT_LOAD_COLOR;
@@ -1126,11 +1129,8 @@ Glyph FontTrueType::loadGlyphByIndex( Uint32 index, unsigned int characterSize,
}
}
FT_Render_Mode finalRenderMode = FT_RENDER_MODE_NORMAL;
if ( glyphDesc->format != FT_GLYPH_FORMAT_SVG ) {
finalRenderMode =
fontSetRenderOptions( static_cast<FT_Library>( mLibrary ), mAntialiasing, mHinting );
}
FT_Render_Mode finalRenderMode = fontSetRenderOptions(
static_cast<FT_Library>( mLibrary ), mAntialiasing, mHinting, glyphDesc->format );
// Convert the glyph to a bitmap (i.e. rasterize it)
FT_Glyph_To_Bitmap( &glyphDesc, finalRenderMode, 0, 1 );