This commit is contained in:
Kulikova Svetlana
2021-10-07 11:45:11 +03:00
parent ed2f9e0035
commit 4836418528
5 changed files with 69 additions and 66 deletions

View File

@ -15,6 +15,10 @@ if not base.is_file("./raster.o"):
base.configure_common_apps()
# remove previous version
if base.is_dir("./deploy"):
base.delete_dir("./deploy")
base.create_dir("./deploy")
if base.is_dir("./o"):
base.delete_dir("./o")
base.create_dir("./o")

View File

@ -7,9 +7,6 @@ import json
base.configure_common_apps()
# remove previous version
if base.is_dir("./deploy"):
base.delete_dir("./deploy")
base.create_dir("./deploy")
if base.is_dir("./o"):
base.delete_dir("./o")
base.create_dir("./o")
@ -25,12 +22,12 @@ if not base.is_dir("emsdk"):
# compile
compiler_flags = ["-O3",
"-fno-rtti",
"-Wno-unused-command-line-argument",
# "-fno-rtti"
"-Wno-unused-command-line-argument",
"-s WASM=1",
"-s ALLOW_MEMORY_GROWTH=1",
"-s FILESYSTEM=0",
"-s ENVIRONMENT='web,worker'"]
"-s ENVIRONMENT='web'"]
#"-s LLD_REPORT_UNDEFINED"]
compile_files_array = []

View File

@ -194,34 +194,58 @@
var reader = new CBinaryReader(buffer, 0, len);
var Line = -1;
var prevY = -1;
while (reader.isValid())
{
var rec = {};
rec["word"] = reader.readString();
if (this.type == 2)
{
rec["x"] = 1.015 * reader.readDouble();
rec["y"] = 1.015 * reader.readDouble();
}
else
{
rec["x"] = reader.readDouble();
rec["y"] = reader.readDouble();
}
rec["w"] = reader.readDouble();
rec["h"] = reader.readDouble();
Line++;
this.pages[pageIndex].Lines.push({ Glyphs : [] });
for (let i = 0; i < _Word.length; i++)
{
this.pages[pageIndex].Lines[Line].Glyphs.push({
X : _X + _W / (_Word.length - 1) * i,
UChar : _Word[i]
});
}
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
// xps
if (this.type == 2)
{
let _fontName = reader.readString();
let _fontSize = reader.readDouble();
let amount = reader.readInt();
for (var i = 0; i < amount; i++)
{
let _X = reader.readDouble();
let _Y = reader.readDouble();
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;
}
let _Char = reader.readInt();
this.pages[pageIndex].Lines[Line].Glyphs.push({
fontName : _fontName,
fontSize : _fontSize,
X : _X * 1.015,
Y : _Y * 1.015,
UChar : String.fromCharCode(_Char)
});
}
}
// djvu
else
{
let _Word = reader.readString();
let _X = reader.readDouble();
let _Y = reader.readDouble();
let _W = reader.readDouble();
let _H = reader.readDouble();
Line++;
this.pages[pageIndex].Lines.push({ Glyphs : [] });
for (let i = 0; i < _Word.length; i++)
{
this.pages[pageIndex].Lines[Line].Glyphs.push({
X : _X + _W / (_Word.length - 1) * i,
UChar : _Word[i]
});
}
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
}
}
Module["_free"](glyphs);
@ -246,16 +270,8 @@
{
var rec = {};
rec["link"] = reader.readString();
if (this.type == 2)
{
rec["x"] = 1.015 * reader.readDouble();
rec["y"] = 1.015 * reader.readDouble();
}
else
{
rec["x"] = reader.readDouble();
rec["y"] = reader.readDouble();
}
rec["x"] = (this.type == 2 ? 1.015 : 1) * reader.readDouble();
rec["y"] = (this.type == 2 ? 1.015 : 1) * reader.readDouble();
rec["w"] = reader.readDouble();
rec["h"] = reader.readDouble();
res.push(rec);
@ -282,16 +298,9 @@
while (reader.isValid())
{
var rec = {};
rec["page"] = reader.readInt();
rec["page"] = reader.readInt();
rec["level"] = reader.readInt();
if (this.type == 2)
{
rec["y"] = reader.readDouble();
}
else
{
rec["y"] = reader.readInt();
}
rec["y"] = reader.readDouble();
rec["description"] = reader.readString();
res.push(rec);
}

View File

@ -353,7 +353,7 @@ void getBookmars(const GP<DjVmNav>& nav, int& pos, int count, NSWasm::CData& out
{
out.AddInt(nPage);
out.AddInt(level);
out.AddInt(0); // Y position
out.AddDouble(0.0);
GUTF8String description = gpBookMark->displayname;
out.WriteString((BYTE*)description.getbuf(), description.length());
}
@ -434,14 +434,10 @@ BYTE* CDjVuFileImplementation::GetPageGlyphs(int nPageIndex, const int& nRasterW
std::string sText = U_TO_UTF8(csWord);
oRes.WriteString((BYTE*)sText.c_str(), sText.length());
std::string sX = std::to_string(arrCoords[0] * dKoefX);
oRes.WriteString((BYTE*)sX.c_str(), sX.length());
std::string sY = std::to_string(arrCoords[3] * dKoefY);
oRes.WriteString((BYTE*)sY.c_str(), sY.length());
std::string sW = std::to_string((arrCoords[2] - arrCoords[0]) * dKoefX);
oRes.WriteString((BYTE*)sW.c_str(), sW.length());
std::string sH = std::to_string((arrCoords[1] - arrCoords[3]) * dKoefY);
oRes.WriteString((BYTE*)sH.c_str(), sH.length());
oRes.AddDouble(arrCoords[0] * dKoefX);
oRes.AddDouble(arrCoords[3] * dKoefY);
oRes.AddDouble((arrCoords[2] - arrCoords[0]) * dKoefX);
oRes.AddDouble((arrCoords[1] - arrCoords[3]) * dKoefY);
}
}
}

View File

@ -722,8 +722,7 @@ namespace XPS
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->AddDouble(dFontSize * pdA + pdE);
m_pGlyphs->AddInt(unUtf16Len);
#endif
@ -763,10 +762,8 @@ namespace XPS
double _dY = dYorigin;
oTransform.TransformPoint(_dX, _dY);
std::string sX = std::to_string(_dX);
m_pGlyphs->WriteString((BYTE*)sX.c_str(), sX.length());
std::string sY = std::to_string(_dY);
m_pGlyphs->WriteString((BYTE*)sY.c_str(), sY.length());
m_pGlyphs->AddDouble(_dX);
m_pGlyphs->AddDouble(_dY);
m_pGlyphs->AddInt(oEntry.nUnicode);
m_pGlyphs->WriteLen();
#endif