Ticket #106: font.patch

File font.patch, 4.7 kB (added by odole, 1 year ago)

fix a potential leak in font

  • BAL/ChangeLog

    old new  
     12008-01-07  Olivier Dole <odole@sand-labs.org> 
     2 
     3        Reviewed by NOBODY (OOPS!). 
     4                Tiny improvement in fonts. 
     5                Remove some potential leaks. 
     6 
     7        * Implementations/Fonts/Embedded/FontPlatformDataEmbedded.cpp: 
     8        (BAL::BTFontPlatformData::operator==): 
     9                Add another check for embedded fonts 
     10        * Implementations/Fonts/FreeType/BCFontPlatformDataPrivateFreeType.cpp: 
     11        (BAL::BCFontPlatformDataPrivateFreeType::~BCFontPlatformDataPrivateFreeType): 
     12                De-initialize fontconfig with FcFini() 
     13        (BAL::BCFontPlatformDataPrivateFreeType::configureFontconfig): 
     14                Move FcConfigDestroy() => remove a possible leak 
     15        * Implementations/Fonts/FreeType/FontDataFreeType.cpp: 
     16        (BAL::BTFontData::platformInit): 
     17                Use space glyph to compute m_spaceWidth 
     18        (BAL::BTFontData::platformDestroy): 
     19                Use FcPatternDestroy() when necessary 
     20        (BAL::BTFontData::smallCapsFontData): 
     21        * Implementations/Fonts/FreeType/FontPlatformDataFreeType.cpp: 
     22        (BAL::BTFontPlatformData::operator==): 
     23                Coding style 
     24 
    1252008-01-04  Olivier Dole <odole@sand-labs.org> 
    226 
    327        Reviewed by Sebastien Roret. 
  • BAL/Implementations/Fonts/Embedded/FontPlatformDataEmbedded.cpp

    old new  
    6161{ 
    6262    if (!d && !other.d) 
    6363        return true; 
     64    if (!d || !other.d) 
     65        return false; 
    6466    return (d->isEqual(other.d)); 
    6567} 
    6668 
  • BAL/Implementations/Fonts/FreeType/BCFontPlatformDataPrivateFreeType.cpp

    old new  
    6464    m_isInitialized--; 
    6565    DBGML(MODULE_FONTS, LEVEL_INFO, "BCFontPlatformDataPrivateFreeType::~BCFontPlatformDataPrivateFreeType(): m_isInitialized=%d\n", m_isInitialized); 
    6666    if (!m_isInitialized && m_library) { 
     67        FcFini(); 
    6768        FT_Done_FreeType(m_library); 
    6869        m_library = 0; 
    6970    } 
     
    146147    if (!m_pattern) 
    147148        goto freePattern; 
    148149 
    149     FcConfigDestroy(config); 
    150  
    151150freePattern: 
    152151    FcPatternDestroy(pattern); 
     152    FcConfigDestroy(config); 
    153153} 
    154154 
    155155void BCFontPlatformDataPrivateFreeType::configureFreetype(const FontDescription& fontDescription) 
  • BAL/Implementations/Fonts/FreeType/FontDataFreeType.cpp

    old new  
    5656 
    5757        FT_Load_Char(face, 'x', FT_LOAD_DEFAULT); 
    5858        m_xHeight = DOUBLE_FROM_26_6(face->glyph->metrics.height); 
     59        FT_Load_Char(face, ' ', FT_LOAD_DEFAULT); 
    5960        m_spaceWidth = DOUBLE_FROM_26_6(face->glyph->metrics.horiAdvance); 
    6061        m_lineGap = m_lineSpacing - m_ascent + m_descent; 
    6162    } 
     
    6869 
    6970void BTFontData::platformDestroy() 
    7071{ 
     72    FcPattern *pattern = static_cast<BCFontPlatformDataPrivateFreeType *> (m_font.impl())->fcPattern(); 
     73    if (pattern && (FcPattern*)-1 != pattern) 
     74        FcPatternDestroy(pattern); 
    7175    if (m_smallCapsFontData) 
    7276        delete m_smallCapsFontData; 
    7377    m_smallCapsFontData = NULL; 
     
    7983        FontDescription desc = FontDescription(fontDescription); 
    8084        desc.setSpecifiedSize(0.70f*fontDescription.computedSize()); 
    8185        const FontPlatformData* pdata = new FontPlatformData(desc, desc.family().family()); 
    82         m_smallCapsFontData = new FontData(*pdata); 
     86        m_smallCapsFontData = new FontData(*pdata, true, false); 
    8387    } 
    8488    return m_smallCapsFontData; 
    8589} 
  • BAL/Implementations/Fonts/FreeType/FontPlatformDataFreeType.cpp

    old new  
    6363    if (!d && !other.d) 
    6464        return true; 
    6565    if (!d || !other.d) 
    66             return false; 
     66        return false; 
    6767    return (d->isEqual(other.d)); 
    6868} 
    6969