From 03d45c1a57dbb5bbce16cba95f472c2dd992bf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 8 Jul 2023 22:07:43 -0300 Subject: [PATCH] Minor clean up. --- bin/assets/colorschemes/colorschemes.conf | 42 ++++++++++++++++ include/eepp/graphics/fonttruetype.hpp | 1 - src/eepp/graphics/fonttruetype.cpp | 60 ++++++++--------------- 3 files changed, 63 insertions(+), 40 deletions(-) diff --git a/bin/assets/colorschemes/colorschemes.conf b/bin/assets/colorschemes/colorschemes.conf index bc9315a52..19b5a5914 100644 --- a/bin/assets/colorschemes/colorschemes.conf +++ b/bin/assets/colorschemes/colorschemes.conf @@ -40,6 +40,48 @@ function = #00dc7f,shadow link = #6ae0f9,shadow link_hover = transparent,shadow,underline +[spartan] +background = #201f1f +text = #cfcfcf +caret = #93DDFA +selection = #4e4e8f +line_highlight = #2d303d +line_number = #8b8bcd +line_number2 = #a7a7f5 +gutter_background = #201f1f +whitespace = #646482 +line_break_column = #54575b99 +matching_bracket = #FFFFFF33 +matching_selection = #3e596e +matching_search = #181b1e +suggestion = #cfcfcf,#1d1f27 +suggestion_selected = #ffffff,#222533 +suggestion_scrollbar = #3daee9 +error = red +warning = yellow +notice = #8abdff +selection_region = #4e4e8f77 +minimap_background = #201f1fAA +minimap_visible_area = #FFFFFF1A +minimap_current_line = #FFFFFF0A +minimap_hover = #FFFFFF1A +minimap_selection = #8abdff80 +minimap_highlight = #FFFF0080 + +normal = #cfcfcf +symbol = #cfcfcf +comment = #cd8b00 +keyword = #8a98ff,shadow +keyword2 = #8abdff,shadow +keyword3 = #cfcfcf,shadow +number = #f0ad6d +literal = #ffcd8b +string = #ffcd8b +operator = #cfbfad +function = #76c0d0,shadow +link = #5ccfcf +link_hover = transparent,shadow,underline + [onedark] background = #282c34 text = #e1e1e6 diff --git a/include/eepp/graphics/fonttruetype.hpp b/include/eepp/graphics/fonttruetype.hpp index 2c3c9c94f..3ff638079 100644 --- a/include/eepp/graphics/fonttruetype.hpp +++ b/include/eepp/graphics/fonttruetype.hpp @@ -162,7 +162,6 @@ class EE_API FontTrueType : public Font { ///< implementation details) void* mStroker; ///< Pointer to the stroker (it is typeless to avoid exposing implementation ///< details) - int* mRefCount; ///< Reference counter used by implicit sharing mutable ScopedBuffer mMemCopy; ///< If loaded from memory, this is the file copy in memory Font::Info mInfo; ///< Information about the font Uint32 mFontInternalId{ 0 }; diff --git a/src/eepp/graphics/fonttruetype.cpp b/src/eepp/graphics/fonttruetype.cpp index 507bcb589..c0e39c996 100644 --- a/src/eepp/graphics/fonttruetype.cpp +++ b/src/eepp/graphics/fonttruetype.cpp @@ -75,7 +75,6 @@ FontTrueType::FontTrueType( const std::string& FontName ) : mFace( NULL ), mStreamRec( NULL ), mStroker( NULL ), - mRefCount( NULL ), mInfo(), mBoldAdvanceSameAsRegular( false ), mHinting( FontManager::instance()->getHinting() ), @@ -109,7 +108,6 @@ bool FontTrueType::loadFromFile( const std::string& filename ) { // Cleanup the previous resources cleanup(); - mRefCount = new int( 1 ); // Initialize FreeType FT_Library library; @@ -184,7 +182,6 @@ bool FontTrueType::loadFromMemory( const void* data, std::size_t sizeInBytes, bo // Cleanup the previous resources cleanup(); - mRefCount = new int( 1 ); // Initialize FreeType FT_Library library; @@ -249,7 +246,6 @@ bool FontTrueType::loadFromMemory( const void* data, std::size_t sizeInBytes, bo bool FontTrueType::loadFromStream( IOStream& stream ) { // Cleanup the previous resources cleanup(); - mRefCount = new int( 1 ); // Initialize FreeType FT_Library library; @@ -655,7 +651,6 @@ FontTrueType& FontTrueType::operator=( const FontTrueType& right ) { std::swap( mFace, temp.mFace ); std::swap( mStreamRec, temp.mStreamRec ); std::swap( mStroker, temp.mStroker ); - std::swap( mRefCount, temp.mRefCount ); std::swap( mInfo, temp.mInfo ); std::swap( mPages, temp.mPages ); std::swap( mPixelBuffer, temp.mPixelBuffer ); @@ -671,40 +666,27 @@ void FontTrueType::cleanup() { mCallbacks.clear(); mNumCallBacks = 0; - // Check if we must destroy the FreeType pointers - if ( mRefCount ) { - // Decrease the reference counter - ( *mRefCount )--; + // Destroy the stroker + if ( mStroker ) + FT_Stroker_Done( static_cast( mStroker ) ); - // Free the resources only if we are the last owner - if ( *mRefCount == 0 ) { - // Delete the reference counter - delete mRefCount; + // Destroy the font face + if ( mFace ) + FT_Done_Face( static_cast( mFace ) ); - // Destroy the stroker - if ( mStroker ) - FT_Stroker_Done( static_cast( mStroker ) ); + // Destroy the stream rec instance, if any (must be done after FT_Done_Face!) + if ( mStreamRec ) + delete static_cast( mStreamRec ); - // Destroy the font face - if ( mFace ) - FT_Done_Face( static_cast( mFace ) ); - - // Destroy the stream rec instance, if any (must be done after FT_Done_Face!) - if ( mStreamRec ) - delete static_cast( mStreamRec ); - - // Close the library - if ( mLibrary ) - FT_Done_FreeType( static_cast( mLibrary ) ); - } - } + // Close the library + if ( mLibrary ) + FT_Done_FreeType( static_cast( mLibrary ) ); // Reset members mLibrary = NULL; mFace = NULL; mStroker = NULL; mStreamRec = NULL; - mRefCount = NULL; mPages.clear(); std::vector().swap( mPixelBuffer ); } @@ -789,7 +771,8 @@ Glyph FontTrueType::loadGlyph( Uint32 index, unsigned int characterSize, bool bo // Retrieve the glyph FT_Glyph glyphDesc; - if ( FT_Get_Glyph( face->glyph, &glyphDesc ) != 0 ) { + FT_GlyphSlot slot = face->glyph; + if ( FT_Get_Glyph( slot, &glyphDesc ) != 0 ) { Log::error( "FT_Get_Glyph failed for: codePoint %d characterSize: %d font: %s", index, characterSize, mFontName.c_str() ); return glyph; @@ -829,8 +812,7 @@ Glyph FontTrueType::loadGlyph( Uint32 index, unsigned int characterSize, bool bo } // Compute the glyph's advance offset - glyph.advance = - static_cast( face->glyph->metrics.horiAdvance ) / static_cast( 1 << 6 ); + glyph.advance = static_cast( slot->metrics.horiAdvance ) / static_cast( 1 << 6 ); if ( maxWidth > 0.f ) glyph.advance = maxWidth; @@ -838,8 +820,8 @@ Glyph FontTrueType::loadGlyph( Uint32 index, unsigned int characterSize, bool bo if ( bold && !mBoldAdvanceSameAsRegular ) glyph.advance += static_cast( weight ) / static_cast( 1 << 6 ); - glyph.lsbDelta = static_cast( face->glyph->lsb_delta ); - glyph.rsbDelta = static_cast( face->glyph->rsb_delta ); + glyph.lsbDelta = static_cast( slot->lsb_delta ); + glyph.rsbDelta = static_cast( slot->rsb_delta ); int width = bitmap.width; int height = bitmap.rows; @@ -876,14 +858,14 @@ Glyph FontTrueType::loadGlyph( Uint32 index, unsigned int characterSize, bool bo // Compute the glyph's bounding box glyph.bounds.Left = - static_cast( face->glyph->metrics.horiBearingX ) / static_cast( 1 << 6 ); + static_cast( slot->metrics.horiBearingX ) / static_cast( 1 << 6 ); glyph.bounds.Top = - -static_cast( face->glyph->metrics.horiBearingY ) / static_cast( 1 << 6 ); + -static_cast( slot->metrics.horiBearingY ) / static_cast( 1 << 6 ); glyph.bounds.Right = - static_cast( face->glyph->metrics.width ) / static_cast( 1 << 6 ) + + static_cast( slot->metrics.width ) / static_cast( 1 << 6 ) + outlineThickness * 2; glyph.bounds.Bottom = - static_cast( face->glyph->metrics.height ) / static_cast( 1 << 6 ) + + static_cast( slot->metrics.height ) / static_cast( 1 << 6 ) + outlineThickness * 2; // Resize the pixel buffer to the new size and fill it with transparent white pixels