CCtrlPage::~CCtrlPage() { CC_SAFE_RELEASE_NULL(m_backgroundSprite); CC_SAFE_RELEASE_NULL(m_pScrollView); ClearPages(); }
CFontGen::~CFontGen() { assert(!isWorking); ClearSubsets(); ClearPages(); ClearIconImages(); }
MuPDFDoc::~MuPDFDoc() { CoTaskMemFree(m_cts); if (m_outline) { fz_free_outline(m_context, m_outline); m_outline = nullptr; } if (m_document) { ClearPages(); fz_close_document(m_document); m_document = nullptr; } if (m_context) { fz_free_context(m_context); m_context = nullptr; } }
// Internal void CFontGen::InternalGeneratePages() { if( arePagesGenerated ) { status = 0; isWorking = false; return; } ClearPages(); bool didNotFit = false; memset(noFit, 0, sizeof(noFit)); if( stopWorking ) { status = 0; isWorking = false; return; } const int maxChars = useUnicode ? maxUnicodeChar+1 : 256; // Add the imported images to the character list for( int n = 0; n < (signed)iconImages.size(); n++ ) { int ch = iconImages[n]->id; chars[ch] = new CFontChar(); chars[ch]->CreateFromImage(n, iconImages[n]->image, iconImages[n]->xoffset, iconImages[n]->yoffset, iconImages[n]->advance); if( chars[ch]->m_height > 0 && chars[ch]->m_width > 0 ) { if( (chars[ch]->m_height + paddingUp + paddingDown) > outHeight-spacingVert || (chars[ch]->m_width + paddingRight + paddingLeft) > outWidth-spacingHoriz ) { didNotFit = true; noFit[ch] = true; // Delete the character again so that it isn't considered again delete chars[ch]; chars[ch] = 0; } } if( stopWorking ) { status = 0; isWorking = false; return; } } // Draw each of the chars into individual images HFONT font = CreateFont(0); for( int n = 0; n < maxChars; n++ ) { if( !disabled[n] && selected[n] ) { // Unless the image is taken by an imported icon // Draw the character in a separate image // Determine the dimensions of the character if( chars[n] == 0 ) { chars[n] = new CFontChar(); chars[n]->DrawChar(font, n, scaleH, aa, useUnicode, useSmoothing); if( outlineThickness ) chars[n]->AddOutline(outlineThickness); if( chars[n]->m_height > 0 && chars[n]->m_width > 0 ) { if( (chars[n]->m_height + paddingUp + paddingDown) > outHeight-spacingVert || (chars[n]->m_width + paddingRight + paddingLeft) > outWidth-spacingHoriz ) { didNotFit = true; noFit[n] = true; // Delete the character again so that it isn't considered again delete chars[n]; chars[n] = 0; } } } counter++; if( stopWorking ) { status = 0; isWorking = false; DeleteObject(font); return; } } } // Build a list of used characters status = 2; counter = 0; static CFontChar *ch[maxUnicodeChar+2]; int numChars = 0; for( int n = 0; n < maxChars; n++ ) { if( chars[n] ) ch[numChars++] = chars[n]; } // Add the invalid char glyph if( outputInvalidCharGlyph ) { invalidCharGlyph = new CFontChar(); invalidCharGlyph->DrawInvalidCharGlyph(font, scaleH, aa, useUnicode, useSmoothing); if( outlineThickness ) invalidCharGlyph->AddOutline(outlineThickness); if( (invalidCharGlyph->m_height + paddingUp + paddingDown) > outHeight-spacingVert || (invalidCharGlyph->m_width + paddingRight + paddingLeft) > outWidth-spacingHoriz ) { didNotFit = true; // Delete the character again so that it isn't considered again delete invalidCharGlyph; invalidCharGlyph = 0; } else ch[numChars++] = invalidCharGlyph; } DeleteObject(font); // Create pages until there are no more chars while( numChars > 0 ) { int page = CreatePage(); pages[page]->AddChars(ch, numChars); // Compact list for( int n = 0; n < numChars; n++ ) { if( ch[n] == 0 ) { // Find the last char for( numChars--; numChars > n; numChars-- ) { if( ch[numChars] ) { ch[n] = ch[numChars]; ch[numChars] = 0; break; } } } } if( stopWorking ) { status = 0; isWorking = false; return; } } status = 0; isWorking = false; arePagesGenerated = true; }