mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 09:38:40 +00:00
added a warning for conflicted font encoding
This commit is contained in:
parent
9c4d30fa88
commit
5cf21b4fb7
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
using boost::algorithm::to_lower;
|
using boost::algorithm::to_lower;
|
||||||
|
using std::unordered_set;
|
||||||
|
|
||||||
path HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
|
path HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
|
||||||
{
|
{
|
||||||
|
@ -212,12 +214,35 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||||
// move the slot such that it's consistent with the encoding seen in PDF
|
// move the slot such that it's consistent with the encoding seen in PDF
|
||||||
ofstream out(tmp_dir / (fn + "_.encoding"));
|
ofstream out(tmp_dir / (fn + "_.encoding"));
|
||||||
add_tmp_file(fn+"_.encoding");
|
add_tmp_file(fn+"_.encoding");
|
||||||
|
|
||||||
|
unordered_set<string> nameset;
|
||||||
|
bool name_conflict_warned = false;
|
||||||
|
|
||||||
out << format("/%1% [") % fn << endl;
|
out << format("/%1% [") % fn << endl;
|
||||||
for(int i = 0; i < 256; ++i)
|
for(int i = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
auto cn = font_8bit->getCharName(i);
|
auto cn = font_8bit->getCharName(i);
|
||||||
out << "/" << ((cn == nullptr) ? ".notdef" : cn) << endl;
|
if(cn == nullptr)
|
||||||
|
{
|
||||||
|
out << "/.notdef" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(nameset.insert(string(cn)).second)
|
||||||
|
{
|
||||||
|
out << "/" << cn << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!name_conflict_warned)
|
||||||
|
{
|
||||||
|
name_conflict_warned = false;
|
||||||
|
//TODO: may be resolved using advanced font properties?
|
||||||
|
cerr << "Warning: encoding confliction detected in font: " << fn << endl;
|
||||||
|
}
|
||||||
|
out << "/.notdef" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out << "] def" << endl;
|
out << "] def" << endl;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user