mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
working on cid truetype
This commit is contained in:
parent
b40782d800
commit
cab38518de
@ -4,9 +4,14 @@
|
||||
* Copyright (C) 2012 by Lu Wang coolwanglu<at>gmail.com
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "GfxFont.h"
|
||||
|
||||
#include "BackgroundRenderer.h"
|
||||
#include "util.h"
|
||||
|
||||
using std::all_of;
|
||||
|
||||
void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
|
||||
double dx, double dy,
|
||||
@ -14,7 +19,11 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
|
||||
CharCode code, int nBytes, Unicode *u, int uLen)
|
||||
{
|
||||
auto font = state->getFont();
|
||||
if((font->getType() == fontType3) || (font->getWMode()) || (uLen == 0))
|
||||
if((font->getType() == fontType3)
|
||||
|| (font->getWMode())
|
||||
|| (uLen == 0)
|
||||
|| (!all_of(u, u+uLen, isLegalUnicode))
|
||||
)
|
||||
{
|
||||
SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
|
||||
}
|
||||
|
@ -125,6 +125,8 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
|
||||
|
||||
script_fout << format("Open(%1%, 1)") % (tmp_dir / (fn + suffix)) << endl;
|
||||
|
||||
unordered_map<int,int> gid2code;
|
||||
|
||||
auto ctu = font->getToUnicode();
|
||||
int * code2GID = nullptr;
|
||||
if(ctu)
|
||||
@ -150,9 +152,17 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
|
||||
else
|
||||
{
|
||||
script_fout << "Reencode(\"original\")" << endl;
|
||||
int len;
|
||||
|
||||
GfxCIDFont * _font = dynamic_cast<GfxCIDFont*>(font);
|
||||
|
||||
// code2GID has been stored for embedded CID fonts
|
||||
code2GID = dynamic_cast<GfxCIDFont*>(font)->getCodeToGIDMap(nullptr, &len);
|
||||
code2GID = _font->getCodeToGIDMap(nullptr, &maxcode);
|
||||
|
||||
int * p = _font->getCIDToGID();
|
||||
int l = _font->getCIDToGIDLen();
|
||||
for(int i = 0; i < l; ++i)
|
||||
gid2cid.insert(make_pair(p[i], i));
|
||||
// ??
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,15 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "HTMLRenderer.h"
|
||||
#include "namespace.h"
|
||||
|
||||
using std::all_of;
|
||||
|
||||
string HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
|
||||
{
|
||||
// mupdf consulted
|
||||
@ -187,27 +190,10 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
|
||||
++nSpaces;
|
||||
}
|
||||
|
||||
if(uLen == 0)
|
||||
if(uLen > 0)
|
||||
{
|
||||
// TODO
|
||||
#if 0
|
||||
CharCode c = 0;
|
||||
for(int i = 0; i < n; ++i)
|
||||
{
|
||||
c = (c<<8) | (code&0xff);
|
||||
code >>= 8;
|
||||
}
|
||||
for(int i = 0; i < n; ++i)
|
||||
{
|
||||
Unicode u = (c&0xff);
|
||||
c >>= 8;
|
||||
outputUnicodes(html_fout, &u, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
outputUnicodes(html_fout, u, uLen);
|
||||
if(all_of(u, u+uLen, isLegalUnicode))
|
||||
outputUnicodes(html_fout, u, uLen);
|
||||
}
|
||||
|
||||
dx += dx1;
|
||||
|
Loading…
Reference in New Issue
Block a user