mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-10 19:35:55 +08:00
fix rgba
some letters disappear
This commit is contained in:
@ -81,25 +81,14 @@ int CFontStream::CreateFromFile(const std::wstring& strFileName, BYTE* pDataUse)
|
||||
return true;
|
||||
}
|
||||
|
||||
int CFontStream::CreateFromMemory(BYTE* pData, LONG lSize, BYTE* pDataUse)
|
||||
int CFontStream::CreateFromMemory(BYTE* pData, LONG lSize)
|
||||
{
|
||||
m_pData = pData;
|
||||
m_lSize = lSize;
|
||||
|
||||
if (NULL == pDataUse)
|
||||
m_pData = new BYTE[m_lSize];
|
||||
else
|
||||
{
|
||||
m_bIsAttach = true;
|
||||
m_pData = pDataUse;
|
||||
}
|
||||
|
||||
memcpy(m_pData, pData, m_lSize);
|
||||
m_bIsAttach = true;
|
||||
|
||||
if (!m_pData)
|
||||
{
|
||||
if (!m_bIsAttach)
|
||||
RELEASEARRAYOBJECTS(m_pData);
|
||||
|
||||
m_lSize = 0;
|
||||
return FALSE;
|
||||
}
|
||||
@ -143,8 +132,11 @@ void CApplicationFontStreams::CheckStreams(std::map<std::wstring,bool> &mapFiles
|
||||
|
||||
if (mapFiles.find(iter->first) != mapFiles.end())
|
||||
{
|
||||
if (m_pMemoryStorage)
|
||||
m_pMemoryStorage->Remove(U_TO_UTF8(iter->first));
|
||||
else
|
||||
RELEASEINTERFACE(pFile);
|
||||
iter = m_mapStreams.erase(iter);
|
||||
RELEASEINTERFACE(pFile);
|
||||
}
|
||||
else
|
||||
iter++;
|
||||
@ -155,8 +147,13 @@ void CApplicationFontStreams::Clear()
|
||||
{
|
||||
for (std::map<std::wstring, CFontStream*>::iterator iter = m_mapStreams.begin(); iter != m_mapStreams.end(); ++iter)
|
||||
{
|
||||
CFontStream* pFile = iter->second;
|
||||
RELEASEINTERFACE(pFile);
|
||||
if (m_pMemoryStorage)
|
||||
m_pMemoryStorage->Remove(U_TO_UTF8(iter->first));
|
||||
else
|
||||
{
|
||||
CFontStream* pFile = iter->second;
|
||||
RELEASEINTERFACE(pFile);
|
||||
}
|
||||
}
|
||||
m_mapStreams.clear();
|
||||
}
|
||||
|
||||
@ -49,13 +49,23 @@ public:
|
||||
|
||||
public:
|
||||
virtual int CreateFromFile(const std::wstring& strFileName, BYTE* pDataUse = NULL);
|
||||
virtual int CreateFromMemory(BYTE* pData, LONG lSize, BYTE* pDataUse = NULL);
|
||||
virtual int CreateFromMemory(BYTE* pData, LONG lSize);
|
||||
};
|
||||
|
||||
class CGlobalFontsMemoryStorage
|
||||
{
|
||||
private:
|
||||
std::map<std::string, CFontStream*> m_mapStreams;
|
||||
|
||||
void string_replaceA(std::string& text, const std::string& replaceFrom, const std::string& replaceTo)
|
||||
{
|
||||
size_t posn = 0;
|
||||
while (std::string::npos != (posn = text.find(replaceFrom, posn)))
|
||||
{
|
||||
text.replace(posn, replaceFrom.length(), replaceTo);
|
||||
posn += replaceTo.length();
|
||||
}
|
||||
}
|
||||
public:
|
||||
CGlobalFontsMemoryStorage(){}
|
||||
~CGlobalFontsMemoryStorage()
|
||||
@ -67,17 +77,21 @@ public:
|
||||
|
||||
void Add(const std::string& id, BYTE* data, LONG size)
|
||||
{
|
||||
std::map<std::string, CFontStream*>::iterator it = m_mapStreams.find(id);
|
||||
std::string sFileA = id;
|
||||
string_replaceA(sFileA, "\\", "/");
|
||||
std::map<std::string, CFontStream*>::iterator it = m_mapStreams.find(sFileA);
|
||||
if (it == m_mapStreams.end())
|
||||
{
|
||||
CFontStream* pStream = (CFontStream*)NSFonts::NSStream::Create();
|
||||
pStream->CreateFromMemory(data, size);
|
||||
m_mapStreams.insert({id, pStream});
|
||||
m_mapStreams.insert({sFileA, pStream});
|
||||
}
|
||||
}
|
||||
void Remove(const std::string& id)
|
||||
{
|
||||
std::map<std::string, CFontStream*>::iterator it = m_mapStreams.find(id);
|
||||
std::string sFileA = id;
|
||||
string_replaceA(sFileA, "\\", "/");
|
||||
std::map<std::string, CFontStream*>::iterator it = m_mapStreams.find(sFileA);
|
||||
if (it != m_mapStreams.end())
|
||||
{
|
||||
RELEASEOBJECT(it->second);
|
||||
@ -88,6 +102,7 @@ public:
|
||||
CFontStream* Get(const std::wstring& sFile)
|
||||
{
|
||||
std::string sFileA = U_TO_UTF8(sFile);
|
||||
string_replaceA(sFileA, "\\", "/");
|
||||
std::map<std::string, CFontStream*>::iterator it = m_mapStreams.find(sFileA);
|
||||
return it != m_mapStreams.end() ? it->second : NULL;
|
||||
}
|
||||
@ -96,8 +111,8 @@ public:
|
||||
class CApplicationFontStreams : public NSFonts::IApplicationFontStreams
|
||||
{
|
||||
private:
|
||||
// этот мап нужно периодически опрашивать и удалять неиспользуемые стримы
|
||||
std::map<std::wstring, CFontStream*> m_mapStreams;
|
||||
// этот мап нужно периодически опрашивать и удалять неиспользуемые стримы
|
||||
std::map<std::wstring, CFontStream*> m_mapStreams;
|
||||
public:
|
||||
static CGlobalFontsMemoryStorage* m_pMemoryStorage;
|
||||
|
||||
|
||||
@ -426,7 +426,7 @@ namespace NSFonts
|
||||
|
||||
public:
|
||||
virtual int CreateFromFile(const std::wstring& strFileName, unsigned char* pDataUse = NULL) = 0;
|
||||
virtual int CreateFromMemory(BYTE* pData, LONG lSize, unsigned char* pDataUse = NULL) = 0;
|
||||
virtual int CreateFromMemory(BYTE* pData, LONG lSize) = 0;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL IApplicationFontStreams : public NSBase::CBaseRefCounter
|
||||
|
||||
@ -117,7 +117,7 @@ for item in input_xml_sources:
|
||||
for item in input_pdf_sources:
|
||||
sources.append(libPdf_src_path + item)
|
||||
sources.append("raster.o")
|
||||
sources.append("wasm/src/graphics.cpp")
|
||||
sources.append("wasm/src/wasmgraphics.cpp")
|
||||
|
||||
compiler_flags.append("-I../../../agg-2.4/include -I../../../cximage/jasper/include -I../../../cximage/jpeg -I../../../cximage/png -I../../../freetype-2.10.4/include -I../../../freetype-2.10.4/include/freetype -I../../../../OfficeUtils/src/zlib-1.2.11 -I../../../../Common/3dParty/icu/icu/source/common -I../../../xml/libxml2/include -I../../../xml/build/qt -I../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip -I../../../../OfficeUtils/src/zlib-1.2.11")
|
||||
compiler_flags.append("-D__linux__ -D_LINUX -DFT2_BUILD_LIBRARY -DHAVE_FCNTL_H -DFT_CONFIG_OPTION_SYSTEM_ZLIB -DBUILDING_WASM_MODULE -DU_COMMON_IMPLEMENTATION")
|
||||
|
||||
@ -56,8 +56,8 @@
|
||||
canvasCtx.putImageData(canvasData, 0, 0);
|
||||
|
||||
Module["_Graphics_Free"](imageFileRawData);
|
||||
Module["_Fonts_Destroy"]();
|
||||
this.close();
|
||||
Module["_Fonts_Destroy"]();
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
||||
@ -667,7 +667,7 @@ int main()
|
||||
//void* test = Graphics_Create(265, 265, 70.1146, 70.1146);
|
||||
//void* test = Graphics_Create(211, 119, 55.8251, 31.2208);
|
||||
void* test = Graphics_Create();
|
||||
//void* fonts = Fonts_Create();
|
||||
void* fonts = Fonts_Create();
|
||||
|
||||
/*
|
||||
BYTE* pData = NULL;
|
||||
@ -682,16 +682,15 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
oFile.CloseFile();
|
||||
*/
|
||||
|
||||
//Fonts_Add(fonts, "Arial", pData, nBytesCount);
|
||||
*/
|
||||
|
||||
BYTE* pXpsData = NULL;
|
||||
DWORD nXpsBytesCount;
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.xps", &pXpsData, nXpsBytesCount))
|
||||
{
|
||||
//Fonts_Destroy();
|
||||
Fonts_Destroy();
|
||||
Graphics_Destroy(test);
|
||||
RELEASEARRAYOBJECTS(pXpsData);
|
||||
return 1;
|
||||
@ -712,11 +711,12 @@ int main()
|
||||
resFrame->put_Width(nWidth);
|
||||
resFrame->put_Height(nHeight);
|
||||
resFrame->put_Stride(-4 * nWidth);
|
||||
resFrame->put_IsRGBA(true);
|
||||
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
||||
resFrame->ClearNoAttack();
|
||||
|
||||
//Fonts_Destroy();
|
||||
Graphics_Destroy(test);
|
||||
Fonts_Destroy();
|
||||
RELEASEARRAYOBJECTS(pXpsData);
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
RELEASEOBJECT(resFrame);
|
||||
|
||||
@ -197,7 +197,7 @@ BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
||||
oFrame.put_Stride(-4 * nWidth);
|
||||
|
||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pRenderer->SetSwapRGB(false);
|
||||
pRenderer->SetSwapRGB(true);
|
||||
pRenderer->put_Width(dWidth);
|
||||
pRenderer->put_Height(dHeight);
|
||||
|
||||
|
||||
@ -464,10 +464,14 @@ namespace XPS
|
||||
IFolder::CBuffer* buffer = NULL;
|
||||
m_wsRootPath->read(wsFontPath, buffer);
|
||||
m_pFontList->Check(wsFontName, buffer->Buffer, buffer->Size);
|
||||
if (CApplicationFontStreams::m_pMemoryStorage)
|
||||
CApplicationFontStreams::m_pMemoryStorage->Add(U_TO_UTF8(wsFontPath), buffer->Buffer, buffer->Size);
|
||||
m_wsRootPath->write(wsFontPath, buffer->Buffer, buffer->Size);
|
||||
delete buffer;
|
||||
RELEASEOBJECT(buffer);
|
||||
if (CApplicationFontStreams::m_pMemoryStorage)
|
||||
{
|
||||
m_wsRootPath->read(wsFontPath, buffer);
|
||||
CApplicationFontStreams::m_pMemoryStorage->Add(U_TO_UTF8(wsFontPath), buffer->Buffer, buffer->Size);
|
||||
RELEASEOBJECT(buffer);
|
||||
}
|
||||
}
|
||||
wsFontPath = NormalizePath(wsFontPath);
|
||||
pRenderer->put_FontPath(wsFontPath);
|
||||
|
||||
Reference in New Issue
Block a user