mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
general compilation and optimization glyphs
This commit is contained in:
@ -231,6 +231,8 @@ NSFonts::IFontFile* CFontsCache::LockFont(NSFonts::CLibrary& library, const std:
|
||||
return pFile;
|
||||
|
||||
CFontStream* pStream = (CFontStream*)m_pApplicationFontStreams->GetStream(strFileName);
|
||||
if (NULL == pStream)
|
||||
return NULL;
|
||||
pFile = (CFontFile*)CFontManager::LoadFontFile(library, pStream, lFaceIndex);
|
||||
if (NULL == pFile)
|
||||
return NULL;
|
||||
|
||||
@ -153,33 +153,62 @@
|
||||
index += lenRec;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
var _X = parseFloat("".fromUtf8(buffer, index, lenRec));
|
||||
index += lenRec;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
var _Y = parseFloat("".fromUtf8(buffer, index, lenRec));
|
||||
// TODO: близость
|
||||
if (_Y != prevY)
|
||||
let amount = lenRec;
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
if (Line >= 0)
|
||||
this.pages[pageIndex].Lines[Line].Glyphs.sort((prev, next) => prev.X - next.X);
|
||||
Line++;
|
||||
this.pages[pageIndex].Lines.push({ Glyphs : [] });
|
||||
prevY = _Y;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
var _X = parseFloat("".fromUtf8(buffer, index, lenRec));
|
||||
index += lenRec;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
var _Y = parseFloat("".fromUtf8(buffer, index, lenRec));
|
||||
if (_Y != prevY)
|
||||
{
|
||||
if (Line >= 0)
|
||||
this.pages[pageIndex].Lines[Line].Glyphs.sort((prev, next) => prev.X - next.X);
|
||||
Line++;
|
||||
this.pages[pageIndex].Lines.push({ Glyphs : [] });
|
||||
prevY = _Y;
|
||||
}
|
||||
index += lenRec;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
this.pages[pageIndex].Lines[Line].Glyphs.push({
|
||||
fontName : _fontName,
|
||||
fontSize : _fontSize,
|
||||
X : _X * 1.015,
|
||||
Y : _Y * 1.015,
|
||||
UChar : String.fromCharCode(lenRec)
|
||||
});
|
||||
}
|
||||
index += lenRec;
|
||||
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
|
||||
index += 4;
|
||||
this.pages[pageIndex].Lines[Line].Glyphs.push({
|
||||
fontName : _fontName,
|
||||
fontSize : _fontSize,
|
||||
X : _X * 1.015,
|
||||
Y : _Y * 1.015,
|
||||
UChar : String.fromCharCode(lenRec)
|
||||
});
|
||||
}
|
||||
this.pages[pageIndex].Lines.sort((prev, next) => prev.Glyphs[0].Y - next.Glyphs[0].Y);
|
||||
|
||||
prevY = -1;
|
||||
var prevFontName = "";
|
||||
var prevFontSize = "";
|
||||
for (let i = 0; i < this.pages[pageIndex].Lines.length; i++)
|
||||
{
|
||||
for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++)
|
||||
{
|
||||
let glyph = this.pages[pageIndex].Lines[i].Glyphs[j];
|
||||
if (glyph.fontName == prevFontName)
|
||||
delete glyph.fontName;
|
||||
else
|
||||
prevFontName = glyph.fontName;
|
||||
if (glyph.fontSize == prevFontSize && j != 0)
|
||||
delete glyph.fontSize;
|
||||
else
|
||||
prevFontSize = glyph.fontSize;
|
||||
if (glyph.Y == prevY && j != 0)
|
||||
delete glyph.Y;
|
||||
else
|
||||
prevY = glyph.Y;
|
||||
}
|
||||
}
|
||||
Module["_XPS_Delete"](glyphs);
|
||||
|
||||
return res;
|
||||
};
|
||||
CFile.prototype.structure = function()
|
||||
|
||||
@ -112,9 +112,6 @@ int main()
|
||||
int width = info[1] * 96 / info[3];
|
||||
int height = info[2] * 96 / info[3];
|
||||
BYTE* res = NULL;
|
||||
if (pages_count > 0)
|
||||
res = XPS_GetPixmap(test, 0, width, height);
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
if (pages_count > 0)
|
||||
res = XPS_GetPixmap(test, 0, width, height);
|
||||
|
||||
@ -138,23 +135,30 @@ int main()
|
||||
{
|
||||
DWORD nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
std::cout << "Font " << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
std::cout << "Size " << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << nPathLength << std::endl;
|
||||
std::cout << "Amount " << nPathLength << std::endl;
|
||||
DWORD nAmount = nPathLength;
|
||||
for (DWORD j = 0; j < nAmount; j++)
|
||||
{
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << "X " << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << "Y " << std::string((char*)(pGlyphs + i), nPathLength) << " ";
|
||||
i += nPathLength;
|
||||
nPathLength = GetLength(pGlyphs + i);
|
||||
i += 4;
|
||||
std::cout << "Symbol " << nPathLength << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* pStructure = XPS_GetStructure(test);
|
||||
@ -206,7 +210,7 @@ int main()
|
||||
int height = info[2] * 96 / info[3];
|
||||
BYTE* res = NULL;
|
||||
if (pages_count > 0)
|
||||
res = XPS_GetPixmap(test, 0, width, height);
|
||||
res = XPS_GetPixmap(test, 1, width, height);
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
std::cout << (int)res[i] << " ";
|
||||
|
||||
@ -4,8 +4,9 @@ import base
|
||||
import os
|
||||
|
||||
if not base.is_file("raster.o"):
|
||||
print("Please use raster_make.py previously")
|
||||
exit(0)
|
||||
base.cmd("python", ["raster_make.py"])
|
||||
if not base.is_file("raster.o"):
|
||||
exit(0)
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
|
||||
@ -698,6 +698,9 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP
|
||||
{
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
}
|
||||
#ifdef WASM_MODE
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
#endif
|
||||
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
|
||||
@ -94,12 +94,14 @@ base.copy_file("./all_files_test/index.html", "./deploy/index.html")
|
||||
base.copy_file("./all_files_test/code.js", "./deploy/code.js")
|
||||
base.copy_file("./all_files_test/file.js", "./deploy/file.js")
|
||||
base.copy_dir("./all_files_test/pdf", "./deploy/pdf")
|
||||
if not base.is_dir("./../../DesktopEditor/graphics/pro/js/deploy"):
|
||||
base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["xps_make.py"])
|
||||
if base.is_dir("./../../DesktopEditor/graphics/pro/js/deploy"):
|
||||
base.create_dir("./deploy/xps")
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.js", "./deploy/xps/xps.js")
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.wasm", "./deploy/xps/xps.wasm")
|
||||
else:
|
||||
print("xps_make.py not used. core/DesktopEditor/graphics/pro/js/xps_make.py")
|
||||
print("xps_make.py error")
|
||||
base.copy_dir("./all_files_test/xps", "./deploy/xps")
|
||||
|
||||
base.delete_file("djvu.js")
|
||||
|
||||
@ -684,6 +684,24 @@ namespace XPS
|
||||
|
||||
if (!bIsSideways)
|
||||
{
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
if (!m_pGlyphs)
|
||||
{
|
||||
m_pGlyphs = new CData();
|
||||
m_pGlyphs->SkipLen();
|
||||
}
|
||||
|
||||
double pdA, pdB, pdC, pdD, pdE, pdF;
|
||||
pRenderer->GetTransform(&pdA, &pdB, &pdC, &pdD, &pdE, &pdF);
|
||||
Aggplus::CMatrix oTransform(pdA, pdB, pdC, pdD, pdE, pdF);
|
||||
|
||||
std::string sFontName = U_TO_UTF8(m_pFontManager->GetName());
|
||||
m_pGlyphs->WriteString((BYTE*)sFontName.c_str(), sFontName.length());
|
||||
std::string sFontSize = std::to_string(dFontSize * pdA + pdE);
|
||||
m_pGlyphs->WriteString((BYTE*)sFontSize.c_str(), sFontSize.length());
|
||||
m_pGlyphs->AddInt(unUtf16Len);
|
||||
#endif
|
||||
|
||||
while (GetNextGlyph(wsIndices.c_str(), nIndicesPos, nIndicesLen, pUtf16, nUtf16Pos, unUtf16Len, oEntry))
|
||||
{
|
||||
double dAdvance, dRealAdvance;
|
||||
@ -716,25 +734,10 @@ namespace XPS
|
||||
}
|
||||
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
if (!m_pGlyphs)
|
||||
{
|
||||
m_pGlyphs = new CData();
|
||||
m_pGlyphs->SkipLen();
|
||||
}
|
||||
|
||||
double _dX = dXorigin;
|
||||
double _dY = dYorigin;
|
||||
double pdA, pdB, pdC, pdD, pdE, pdF;
|
||||
pRenderer->GetTransform(&pdA, &pdB, &pdC, &pdD, &pdE, &pdF);
|
||||
Aggplus::CMatrix oTransform(pdA, pdB, pdC, pdD, pdE, pdF);
|
||||
oTransform.TransformPoint(_dX, _dY);
|
||||
|
||||
std::wstring wsFontName;
|
||||
pRenderer->get_FontName(&wsFontName);
|
||||
std::string sFontName = U_TO_UTF8(wsFontName);
|
||||
m_pGlyphs->WriteString((BYTE*)sFontName.c_str(), sFontName.length());
|
||||
std::string sFontSize = std::to_string(dFontSize * pdA + pdE);
|
||||
m_pGlyphs->WriteString((BYTE*)sFontSize.c_str(), sFontSize.length());
|
||||
std::string sX = std::to_string(_dX);
|
||||
m_pGlyphs->WriteString((BYTE*)sX.c_str(), sX.length());
|
||||
std::string sY = std::to_string(_dY);
|
||||
|
||||
Reference in New Issue
Block a user