diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-27 13:55:44 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-27 13:55:44 +0000 |
commit | 47ce3271b417e6d0a8fcbbbe94bd9060290e5032 (patch) | |
tree | c6da726176d1271ff0fe608db0b51b52fb4870f8 /Build/source/texk/dvisvgm/dvisvgm-src/src | |
parent | e8c2792ffc88bff8519581351d6349a84d81bebe (diff) |
dvisvgm 1.15
git-svn-id: svn://tug.org/texlive/trunk@39886 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src')
58 files changed, 333 insertions, 253 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Bitmap.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Bitmap.cpp index e83ff8b8ee9..ad8a915c318 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Bitmap.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Bitmap.cpp @@ -21,7 +21,6 @@ #include <config.h> #include <algorithm> #include <cstdlib> -#include <iostream> #include <limits> #include "Bitmap.h" #include "macros.h" @@ -86,7 +85,7 @@ void Bitmap::forAllPixels (Callback &data) const { UInt8 byte = _bytes[row*_bpr+col]; int x; for (int b=7; (b >= 0) && ((x = 8*col+(7-b)) < _cols); b--) - data.pixel(x, row, byte & (1 << b), *this); + data.pixel(x, row, bool(byte & (1 << b)), *this); } } data.finish(); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/BoundingBox.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/BoundingBox.cpp index 6caa29554c3..eca7142dbf0 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/BoundingBox.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/BoundingBox.cpp @@ -21,7 +21,6 @@ #include <config.h> #include <algorithm> #include <sstream> -#include <string> #include "BoundingBox.h" #include "Matrix.h" #include "XMLNode.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/CMap.cpp index 4b7e8ec5811..ba536de75d7 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CMap.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CMap.cpp @@ -21,12 +21,9 @@ #include <config.h> #include <algorithm> #include <sstream> -#include <set> -#include <vector> #include "CMap.h" #include "CMapManager.h" #include "FileFinder.h" -#include "InputReader.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CMapManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/CMapManager.cpp index 57e469c4cd9..2f360d7331d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CMapManager.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CMapManager.cpp @@ -23,7 +23,6 @@ #include "CMap.h" #include "CMapManager.h" #include "CMapReader.h" -#include "Font.h" #include "FileFinder.h" #include "Message.h" @@ -121,7 +120,7 @@ const CMap* CMapManager::findCompatibleBaseFontMap (const PhysicalFont *font, co vector<CharMapID> charmapIDs; font->collectCharMapIDs(charmapIDs); - const bool is_unicode_map = dynamic_cast<const UnicodeCMap*>(cmap); + const bool is_unicode_map = bool(dynamic_cast<const UnicodeCMap*>(cmap)); const size_t num_encodings = is_unicode_map ? 2 : sizeof(encodings)/sizeof(CharMapIDToEncName); // try to find a compatible encoding CMap diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp index ecd996953ac..3e82161f387 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Calculator.cpp @@ -31,9 +31,6 @@ const char NUMBER = 1; const char NAME = 2; -#include <iostream> - - /** Evaluates a given arithmetic expression and returns its value. * The evaluator is implemented as a recursive descent parser. * @param[in] is reads expression from this stream diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.cpp index f15318f9c26..e6d11c102a4 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.cpp @@ -344,18 +344,26 @@ static bool cmp_long (const char *line1, const char *line2) { } +static void write_line (const char *str) { + fputs(str, stdout); +} + + /** Prints the help text to stdout. * @param[in] mode format of help text */ -void CmdLineParserBase::help (int mode) const { +void CmdLineParserBase::help (int mode, void (*out)(const char*)) const { size_t numlines; const char **lines = helplines(&numlines); + if (out == 0) + out = write_line; if (mode == 0) { // list options with section headers for (size_t i=0; i < numlines; i++) { switch (*lines[i]) { - case 's': fputc('\n', stdout); break; // section header - case 'o': fputs(" ", stdout); break; // option info + case 's': out("\n"); break; // section header + case 'o': out(" "); break; // option info } - puts(lines[i]+1); + out(lines[i]+1); + out("\n"); } } else { @@ -363,9 +371,10 @@ void CmdLineParserBase::help (int mode) const { sort(linevec.begin(), linevec.end(), mode == 1 ? cmp_short : cmp_long); for (vector<const char*>::iterator it=linevec.begin(); it != linevec.end(); ++it) { if (**it != 's') { // skip section headers - puts(*it+1); + out(*it+1); + out("\n"); if (**it == 'd') - puts("\nOptions:"); + out("\nOptions:\n"); } } } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.h index 5eaa189250f..0052f3423ac 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CmdLineParserBase.h @@ -65,7 +65,7 @@ class CmdLineParserBase public: virtual void parse (int argc, char **argv, bool printErrors=true); - virtual void help (int mode=0) const; + virtual void help (int mode=0, void (*out)(const char*)=0) const; virtual int numFiles () const {return _files.size();} virtual const char* file (size_t n) {return n < _files.size() ? _files[n].c_str() : 0;} // virtual void status () const; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.cpp index 1d53201a694..ba052631c8d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.cpp @@ -21,6 +21,7 @@ const CmdLineParserBase::Option CommandLine::_options[] = { #endif {'\0', "color", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_color)}, {'\0', "colornames", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_colornames)}, + {'\0', "comments", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_comments)}, #if !defined(DISABLE_GS) {'E', "eps", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_eps)}, #endif @@ -81,6 +82,7 @@ void CommandLine::init () { #endif _color_given = false; _colornames_given = false; + _comments_given = false; #if !defined(DISABLE_GS) _eps_given = false; #endif @@ -172,6 +174,7 @@ const char** CommandLine::helplines (size_t *numlines) const { "o-j, --clipjoin compute intersection of clipping paths", #endif "o --colornames prefer color names to RGB values if possible", + "o --comments add comments with additional information", #if !defined(DISABLE_GS) "o --grad-overlap create operlapping color gradient segments", #endif @@ -243,6 +246,10 @@ void CommandLine::handle_colornames (InputReader &ir, const Option &opt, bool lo _colornames_given = true; } +void CommandLine::handle_comments (InputReader &ir, const Option &opt, bool longopt) { + _comments_given = true; +} + #if !defined(DISABLE_GS) void CommandLine::handle_eps (InputReader &ir, const Option &opt, bool longopt) { _eps_given = true; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.h index 5de9c9f55a2..68ea640a942 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/CommandLine.h @@ -24,6 +24,7 @@ class CommandLine : public CmdLineParserBase #endif bool color_given () const {return _color_given;} bool colornames_given () const {return _colornames_given;} + bool comments_given () const {return _comments_given;} #if !defined(DISABLE_GS) bool eps_given () const {return _eps_given;} #endif @@ -99,6 +100,7 @@ class CommandLine : public CmdLineParserBase #endif void handle_color (InputReader &ir, const Option &opt, bool longopt); void handle_colornames (InputReader &ir, const Option &opt, bool longopt); + void handle_comments (InputReader &ir, const Option &opt, bool longopt); #if !defined(DISABLE_GS) void handle_eps (InputReader &ir, const Option &opt, bool longopt); #endif @@ -153,6 +155,7 @@ class CommandLine : public CmdLineParserBase #endif bool _color_given; bool _colornames_given; + bool _comments_given; #if !defined(DISABLE_GS) bool _eps_given; #endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIReader.cpp index 7b3509ffba8..ab76eb80bd6 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIReader.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIReader.cpp @@ -22,18 +22,14 @@ #include <algorithm> #include <cstdarg> #include <fstream> -#include <iostream> #include <sstream> #include "Color.h" #include "DVIActions.h" #include "DVIReader.h" #include "Font.h" #include "FontManager.h" -#include "Message.h" #include "SignalHandler.h" #include "VectorStream.h" -#include "macros.h" -#include "types.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.cpp index f93a1a49c81..5582eb59989 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.cpp @@ -29,12 +29,9 @@ #include "DVIToSVGActions.h" #include "Font.h" #include "FontManager.h" -#include "FileFinder.h" #include "GlyphTracerMessages.h" #include "InputBuffer.h" #include "InputReader.h" -#include "Matrix.h" -#include "Message.h" #include "PageRanges.h" #include "PageSize.h" #include "SVGOutput.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.h index 2264404707a..deb8d1c4039 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVG.h @@ -21,7 +21,6 @@ #ifndef DVISVGM_DVITOSVG_H #define DVISVGM_DVITOSVG_H -#include <iostream> #include <string> #include <utility> #include "DVIReader.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVGActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVGActions.cpp index c2f3f35c5de..ba0539767b7 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVGActions.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/DVIToSVGActions.cpp @@ -27,10 +27,7 @@ #include "Font.h" #include "FontManager.h" #include "GlyphTracerMessages.h" -#include "SpecialManager.h" #include "System.h" -#include "XMLNode.h" -#include "XMLString.h" using namespace std; @@ -114,7 +111,6 @@ void DVIToSVGActions::setChar (double x, double y, unsigned c, bool vertical, co GlyphTracerMessages callback(fontname != font->name(), false); fontname = font->name(); - BoundingBox charbox; GlyphMetrics metrics; font->getGlyphMetrics(c, vertical, metrics); const PhysicalFont* pf = dynamic_cast<const PhysicalFont*>(font); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.cpp index 572c6128d3a..1a878568cae 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.cpp @@ -37,8 +37,8 @@ Directory::Directory () { firstread = true; memset(&fileData, 0, sizeof(WIN32_FIND_DATA)); #else - dir = 0; - dirent = 0; + _dir = 0; + _dirent = 0; #endif } @@ -49,8 +49,8 @@ Directory::Directory (string dirname) { firstread = true; memset(&fileData, 0, sizeof(WIN32_FIND_DATA)); #else - dir = 0; - dirent = 0; + _dir = 0; + _dirent = 0; #endif open(dirname); } @@ -71,8 +71,8 @@ bool Directory::open (string dname) { handle = FindFirstFile(dname.c_str(), &fileData); return handle != INVALID_HANDLE_VALUE; #else - dir = opendir(_dirname.c_str()); - return dir; + _dir = opendir(_dirname.c_str()); + return bool(_dir); #endif } @@ -81,7 +81,7 @@ void Directory::close () { #ifdef __WIN32__ FindClose(handle); #else - closedir(dir); + closedir(_dir); #endif } @@ -106,22 +106,22 @@ const char* Directory::read (EntryType type) { handle = INVALID_HANDLE_VALUE; return 0; #else - if (!dir) + if (!_dir) return 0; - while ((dirent = readdir(dir))) { - string path = string(_dirname) + "/" + dirent->d_name; + while ((_dirent = readdir(_dir))) { + string path = string(_dirname) + "/" + _dirent->d_name; struct stat stats; if (stat(path.c_str(), &stats) == 0) { if (S_ISDIR(stats.st_mode)) { if (type == ET_FILE_OR_DIR || type == ET_DIR) - return dirent->d_name; + return _dirent->d_name; } else if (type == ET_FILE_OR_DIR || type == ET_FILE) - return dirent->d_name; + return _dirent->d_name; } } - closedir(dir); - dir = 0; + closedir(_dir); + _dir = 0; return 0; #endif } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.h index e2a99123ceb..8e317eb5240 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Directory.h @@ -48,8 +48,8 @@ class Directory HANDLE handle; WIN32_FIND_DATA fileData; #else - DIR *dir; - struct dirent *dirent; + DIR *_dir; + struct dirent *_dirent; #endif }; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/EPSToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/EPSToSVG.cpp index d12327cf9f3..05392bb6473 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/EPSToSVG.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/EPSToSVG.cpp @@ -20,7 +20,6 @@ #include <config.h> #include <fstream> -#include <istream> #include <sstream> #include "EPSFile.h" #include "EPSToSVG.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/EncFile.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/EncFile.cpp index 625aac257de..705230a016c 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/EncFile.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/EncFile.cpp @@ -22,7 +22,6 @@ #include <fstream> #include "Font.h" #include "EncFile.h" -#include "FontMap.h" #include "InputBuffer.h" #include "InputReader.h" #include "FileFinder.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp index a72bd1fa3a1..8caae75275a 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.cpp @@ -37,7 +37,7 @@ #include <cstdlib> #include <fstream> #include <map> -#include <string> +#include <set> #include "FileFinder.h" #include "FileSystem.h" #include "FontMap.h" @@ -48,6 +48,7 @@ static bool _initialized = false; static bool _mktex_enabled = false; +static std::set<std::string> _additional_dirs; // --------------------------------------------------- @@ -66,6 +67,7 @@ void FileFinder::init (const char *argv0, const char *progname, bool enable_mkte return; _mktex_enabled = enable_mktexmf; + addLookupDir("."); // always lookup files in the current working directory #ifdef MIKTEX miktex = new MiKTeXCom; #else @@ -123,6 +125,11 @@ std::string FileFinder::version () { } +void FileFinder::addLookupDir (const std::string &path) { + _additional_dirs.insert(path); +} + + /** Determines filetype by the filename extension and calls kpse_find_file * to actually look up the file. * @param[in] fname name of file to look up @@ -133,10 +140,16 @@ static const char* find_file (const std::string &fname, const char *ftype) { return 0; static std::string buf; - // try to lookup the file in the current working directory - buf = FileSystem::getcwd()+"/"+fname; - if (FileSystem::exists(buf.c_str())) - return buf.c_str(); + // try to lookup the file in the additionally specified directories + for (std::set<std::string>::iterator it=_additional_dirs.begin(); it != _additional_dirs.end(); ++it) { + if (it->at(0) == '/') + buf.clear(); + else + buf = FileSystem::getcwd()+"/"; + buf += (*it) + "/" + fname; + if (FileSystem::exists(buf)) + return buf.c_str(); + } std::string ext; if (ftype) @@ -152,7 +165,7 @@ static const char* find_file (const std::string &fname, const char *ftype) { if (ext == "dll" || ext == "exe") { // lookup dll and exe files in the MiKTeX bin directory first buf = miktex->getBinDir() + "/" + fname; - if (FileSystem::exists(buf.c_str())) + if (FileSystem::exists(buf)) return buf.c_str(); } else if (ext == "cmap") { @@ -175,7 +188,7 @@ static const char* find_file (const std::string &fname, const char *ftype) { // lookup exe files in directory where dvisvgm is located if (const char *path = kpse_var_value("SELFAUTOLOC")) { buf = std::string(path) + "/" + fname; - return FileSystem::exists(buf.c_str()) ? buf.c_str() : 0; + return FileSystem::exists(buf) ? buf.c_str() : 0; } return 0; } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.h index 64e55d0a7fb..ec9cc1f549d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileFinder.h @@ -28,6 +28,7 @@ struct FileFinder static void init (const char *argv0, const char *progname, bool enable_mktexmf); static void finish (); static std::string version (); + static void addLookupDir (const std::string &path); static const char* lookup (const std::string &fname, const char *ftype, bool extended=true); static const char* lookup (const std::string &fname, bool extended=true) {return lookup(fname, 0, extended);} }; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FilePath.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FilePath.cpp index 96da36017c3..a01cf28bb64 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FilePath.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FilePath.cpp @@ -54,7 +54,7 @@ static char adapt_current_path (string &path, char target_drive) { if (target_drive == 0) target_drive = current_drive; if (path.empty() || path[0] != '/') { - if (FileSystem::chdir((string(1, target_drive) + ":").c_str())) { + if (FileSystem::chdir(string(1, target_drive) + ":")) { path.insert(0, FileSystem::getcwd()+"/"); strip_drive_letter(path); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp index a2512403b1b..0d3f04277bd 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.cpp @@ -115,13 +115,13 @@ string FileSystem::getcwd () { /** Changes the work directory. * @param[in] dir path to new work directory * @return true on success */ -bool FileSystem::chdir (const char *dir) { +bool FileSystem::chdir (const std::string &dirname) { bool success = false; - if (dir) { + if (const char *cdirname = dirname.c_str()) { #ifdef __WIN32__ - success = (_chdir(dir) == 0); + success = (_chdir(cdirname) == 0); #else - success = (chdir(dir) == 0); + success = (chdir(cdirname) == 0); #endif } return success; @@ -155,24 +155,24 @@ const char* FileSystem::userdir () { /** Private wrapper function for mkdir: creates a single folder. * @param[in] dir folder name * @return true on success */ -static bool s_mkdir (const char *dir) { +static bool s_mkdir (const string &dirname) { bool success = true; - if (!FileSystem::exists(dir)) { + if (!FileSystem::exists(dirname)) { #ifdef __WIN32__ - success = (_mkdir(dir) == 0); + success = (_mkdir(dirname.c_str()) == 0); #else - success = (mkdir(dir, 0776) == 0); + success = (mkdir(dirname.c_str(), 0775) == 0); #endif } return success; } -static bool inline s_rmdir (const char *dir) { +static bool inline s_rmdir (const string &dirname) { #ifdef __WIN32__ - return (_rmdir(dir) == 0); + return (_rmdir(dirname.c_str()) == 0); #else - return (rmdir(dir) == 0); + return (rmdir(dirname.c_str()) == 0); #endif } @@ -192,14 +192,14 @@ static string trim (const string &str) { * the parent folders are also created. * @param[in] dir single folder name or path to folder * @return true if folder(s) could be created */ -bool FileSystem::mkdir (const char *dir) { +bool FileSystem::mkdir (const string &dirname) { bool success = false; - if (dir) { + if (const char *cdirname = dirname.c_str()) { success = true; - const string dirstr = adaptPathSeperators(trim(dir)); + const string dirstr = adaptPathSeperators(trim(cdirname)); for (size_t pos=1; success && (pos = dirstr.find('/', pos)) != string::npos; pos++) - success &= s_mkdir(dirstr.substr(0, pos).c_str()); - success &= s_mkdir(dirstr.c_str()); + success &= s_mkdir(dirstr.substr(0, pos)); + success &= s_mkdir(dirstr); } return success; } @@ -208,23 +208,23 @@ bool FileSystem::mkdir (const char *dir) { /** Removes a directory and its contents. * @param[in] dirname path to directory * @return true on success */ -bool FileSystem::rmdir (const char *dirname) { +bool FileSystem::rmdir (const string &dirname) { bool ok = false; - if (dirname && isDirectory(dirname)) { + if (isDirectory(dirname)) { ok = true; #ifdef __WIN32__ - string pattern = string(dirname) + "/*"; + string pattern = dirname + "/*"; WIN32_FIND_DATA data; HANDLE h = FindFirstFile(pattern.c_str(), &data); bool ready = (h == INVALID_HANDLE_VALUE); while (!ready && ok) { const char *fname = data.cFileName; - string path = string(dirname) + "/" + fname; - if (isDirectory(path.c_str())) { + string path = dirname + "/" + fname; + if (isDirectory(path)) { if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) - ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); + ok = rmdir(path) && s_rmdir(path); } - else if (isFile(path.c_str())) + else if (isFile(path)) ok = remove(path); else ok = false; @@ -232,16 +232,16 @@ bool FileSystem::rmdir (const char *dirname) { } FindClose(h); #else - if (DIR *dir = opendir(dirname)) { + if (DIR *dir = opendir(dirname.c_str())) { struct dirent *ent; while ((ent = readdir(dir)) && ok) { const char *fname = ent->d_name; string path = string(fname) + "/" + fname; - if (isDirectory(path.c_str())) { + if (isDirectory(path)) { if (strcmp(fname, ".") != 0 && strcmp(fname, "..") != 0) - ok = rmdir(path.c_str()) && s_rmdir(path.c_str()); + ok = rmdir(path) && s_rmdir(path); } - else if (isFile(path.c_str())) + else if (isFile(path)) ok = remove(path); else ok = false; @@ -256,42 +256,46 @@ bool FileSystem::rmdir (const char *dirname) { /** Checks if a file or directory exits. */ -bool FileSystem::exists (const char *fname) { - if (!fname) - return false; +bool FileSystem::exists (const string &fname) { + if (const char *cfname = fname.c_str()) { + #ifdef __WIN32__ - return GetFileAttributes(fname) != INVALID_FILE_ATTRIBUTES; + return GetFileAttributes(cfname) != INVALID_FILE_ATTRIBUTES; #else - struct stat attr; - return stat(fname, &attr) == 0; + struct stat attr; + return stat(cfname, &attr) == 0; #endif + } + return false; } /** Returns true if 'fname' references a directory. */ -bool FileSystem::isDirectory (const char *fname) { - if (!fname) - return false; +bool FileSystem::isDirectory (const string &fname) { + if (const char *cfname = fname.c_str()) { #ifdef __WIN32__ - return GetFileAttributes(fname) & FILE_ATTRIBUTE_DIRECTORY; + return GetFileAttributes(cfname) & FILE_ATTRIBUTE_DIRECTORY; #else - struct stat attr; - return stat(fname, &attr) == 0 && S_ISDIR(attr.st_mode); + struct stat attr; + return stat(cfname, &attr) == 0 && S_ISDIR(attr.st_mode); #endif + } + return false; } /** Returns true if 'fname' references a file. */ -bool FileSystem::isFile (const char *fname) { - if (!fname) - return false; +bool FileSystem::isFile (const string &fname) { + if (const char *cfname = fname.c_str()) { #ifdef __WIN32__ - ifstream ifs(fname); - return (bool)ifs; + ifstream ifs(cfname); + return (bool)ifs; #else - struct stat attr; - return stat(fname, &attr) == 0 && S_ISREG(attr.st_mode); + struct stat attr; + return stat(cfname, &attr) == 0 && S_ISREG(attr.st_mode); #endif + } + return false; } @@ -305,7 +309,7 @@ int FileSystem::collect (const char *dirname, vector<string> &entries) { while (!ready) { string fname = data.cFileName; string path = string(dirname)+"/"+fname; - string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; + string typechar = isFile(path) ? "f" : isDirectory(path) ? "d" : "?"; if (fname != "." && fname != "..") entries.push_back(typechar+fname); ready = !FindNextFile(h, &data); @@ -317,7 +321,7 @@ int FileSystem::collect (const char *dirname, vector<string> &entries) { while ((ent = readdir(dir))) { string fname = ent->d_name; string path = string(dirname)+"/"+fname; - string typechar = isFile(path.c_str()) ? "f" : isDirectory(path.c_str()) ? "d" : "?"; + string typechar = isFile(path) ? "f" : isDirectory(path) ? "d" : "?"; if (fname != "." && fname != "..") entries.push_back(typechar+fname); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.h index 3bfe43665d2..4e36653f1fd 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FileSystem.h @@ -33,13 +33,13 @@ struct FileSystem static UInt64 filesize (const std::string &fname); static std::string adaptPathSeperators (std::string path); static std::string getcwd (); - static bool chdir (const char *dir); - static bool exists (const char *file); - static bool mkdir (const char *dir); - static bool rmdir (const char *fname); + static bool chdir (const std::string &dir); + static bool exists (const std::string &fname); + static bool mkdir (const std::string &dirname); + static bool rmdir (const std::string &dirname); static int collect (const char *dirname, std::vector<std::string> &entries); - static bool isDirectory (const char *fname); - static bool isFile (const char *fname); + static bool isDirectory (const std::string &fname); + static bool isFile (const std::string &fname); static const char* userdir (); static const char* DEVNULL; static const char PATHSEP; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.cpp index cea0968c689..af1c8d4c9b1 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.cpp @@ -20,26 +20,19 @@ #include <config.h> #include <cstdlib> -#include <iostream> #include <fstream> #include <sstream> #include "CMap.h" #include "FileFinder.h" #include "FileSystem.h" #include "Font.h" -#include "FontEncoding.h" #include "FontEngine.h" -#include "GFGlyphTracer.h" -#include "Glyph.h" #include "Message.h" #include "MetafontWrapper.h" -#include "TFM.h" -#include "VFReader.h" #include "SignalHandler.h" #include "Subfont.h" #include "SVGTree.h" #include "Unicode.h" -#include "macros.h" using namespace std; @@ -307,6 +300,25 @@ int PhysicalFont::descent () const { } +std::string PhysicalFont::familyName () const { + if (type() == MF) + return ""; + FontEngine::instance().setFont(*this); + const char *family = FontEngine::instance().getFamilyName(); + return family ? family : ""; +} + + +std::string PhysicalFont::styleName () const { + if (type() == MF) + return ""; + FontEngine::instance().setFont(*this); + const char *style = FontEngine::instance().getStyleName(); + return style ? style : ""; +} + + + /** Extracts the glyph outlines of a given character. * @param[in] c character code of requested glyph * @param[out] glyph path segments of the glyph outline @@ -510,7 +522,7 @@ UInt32 PhysicalFontImpl::unicode (UInt32 c) const { // try to get the Unicode point from the character name string glyphname = glyphName(c); UInt32 codepoint; - if (!glyphname.empty() && (codepoint = Unicode::psNameToCodepoint(glyphname)) != 0) + if (!glyphname.empty() && (codepoint = Unicode::aglNameToCodepoint(glyphname)) != 0) return codepoint; if (c <= 0x1900) // does character code c fit into Private Use Zone U+E000? return 0xe000+c; @@ -538,7 +550,7 @@ void PhysicalFontImpl::tidy () const { if (type() == MF) { const char *ext[] = {"gf", "tfm", "log", 0}; for (const char **p=ext; *p; ++p) { - if (FileSystem::exists((name()+"."+(*p)).c_str())) + if (FileSystem::exists(name()+"."+(*p))) FileSystem::remove(name()+"."+(*p)); } } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.h index 8d3d5d08c19..f4d828eb977 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Font.h @@ -123,6 +123,8 @@ class PhysicalFont : public virtual Font virtual bool getExactGlyphBox (int c, GlyphMetrics &metrics, bool vertical, GFGlyphTracer::Callback *cb=0) const; virtual bool isCIDFont () const; virtual int hAdvance () const; + virtual std::string familyName () const; + virtual std::string styleName () const; virtual double hAdvance (int c) const; virtual double vAdvance (int c) const; std::string glyphName (int c) const; @@ -324,6 +326,7 @@ class NativeFontImpl : public NativeFont const Font* uniqueFont () const {return this;} const char* path () const {return _path.c_str();} int fontIndex() const {return _fontIndex;} + std::string fontFamily () const; bool findAndAssignBaseFontMap (); CharMapID getCharMapID () const {return CharMapID::NONE;} Character decodeChar (UInt32 c) const; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontCache.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontCache.h index ed1d07c6de9..3fea7db79af 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontCache.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontCache.h @@ -21,7 +21,6 @@ #ifndef DVISVGM_FONTCACHE_H #define DVISVGM_FONTCACHE_H -#include <iostream> #include <string> #include <map> #include "types.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.cpp index 0565a34470e..1e446a6b811 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.cpp @@ -19,7 +19,6 @@ *************************************************************************/ #include <config.h> -#include <iostream> #include <sstream> #include <ft2build.h> #include FT_ADVANCES_H @@ -53,17 +52,16 @@ static inline FT_Fixed to_16dot16 (int val) { FontEngine::FontEngine () : _currentFace(0), _currentFont(0) { _currentChar = _currentGlyphIndex = 0; - _horDeviceRes = _vertDeviceRes = 300; if (FT_Init_FreeType(&_library)) - Message::estream(true) << "FontEngine: error initializing FreeType library\n"; + Message::estream(true) << "failed to initialize FreeType library\n"; } FontEngine::~FontEngine () { if (_currentFace && FT_Done_Face(_currentFace)) - Message::estream(true) << "FontEngine: error removing glyph\n"; + Message::estream(true) << "failed to release font\n"; if (FT_Done_FreeType(_library)) - Message::estream(true) << "FontEngine: error removing FreeType library\n"; + Message::estream(true) << "failed to release FreeType library\n"; } @@ -84,21 +82,15 @@ string FontEngine::version () { } -void FontEngine::setDeviceResolution (int x, int y) { - _horDeviceRes = x; - _vertDeviceRes = y; -} - - /** Sets the font to be used. * @param[in] fname path to font file * @param[in] fontindex index of font in font collection (multi-font files, like TTC) * @return true on success */ bool FontEngine::setFont (const string &fname, int fontindex, const CharMapID &charMapID) { if (_currentFace && FT_Done_Face(_currentFace)) - Message::estream(true) << "FontEngine: error removing font\n"; + Message::estream(true) << "failed to release font\n"; if (FT_New_Face(_library, fname.c_str(), fontindex, &_currentFace)) { - Message::estream(true) << "FontEngine: error reading file " << fname << '\n'; + Message::estream(true) << "can't read font file " << fname << '\n'; return false; } if (charMapID.valid()) @@ -396,7 +388,7 @@ static bool trace_outline (FT_Face face, const Font *font, int index, Glyph &gly FT_Outline_Decompose(&outline, &funcs, &glyph); return true; } - Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; + Message::wstream(true) << "can't trace outline (no font selected)\n"; return false; } @@ -409,8 +401,5 @@ static bool trace_outline (FT_Face face, const Font *font, int index, Glyph &gly * @param[in] scale if true the current pt size will be considered otherwise the plain TrueType units are used. * @return false on errors */ bool FontEngine::traceOutline (const Character &c, Glyph &glyph, bool scale) const { - if (_currentFace) - return trace_outline(_currentFace, _currentFont, charIndex(c), glyph, scale); - Message::wstream(true) << "FontEngine: can't trace outline, no font face selected\n"; - return false; + return trace_outline(_currentFace, _currentFont, charIndex(c), glyph, scale); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.h index 8cacb1526fd..a5edea81879 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEngine.h @@ -43,7 +43,6 @@ class FontEngine ~FontEngine (); static FontEngine& instance (); static std::string version (); - void setDeviceResolution (int x, int y); bool setFont (const Font &font); bool isCIDFont() const; bool traceOutline (const Character &c, Glyph &glyph, bool scale=true) const; @@ -75,7 +74,6 @@ class FontEngine int charIndex (const Character &c) const; private: - int _horDeviceRes, _vertDeviceRes; mutable unsigned int _currentChar, _currentGlyphIndex; FT_Face _currentFace; FT_Library _library; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontManager.cpp index 8834fa20996..91e61fba3b8 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontManager.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontManager.cpp @@ -26,11 +26,9 @@ #include "CMap.h" #include "Font.h" #include "FontManager.h" -#include "FontMap.h" #include "FileFinder.h" #include "FileSystem.h" #include "Message.h" -#include "macros.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMap.cpp index 5d42c8f185c..0698e71121f 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMap.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMap.cpp @@ -21,7 +21,6 @@ #include <config.h> #include <cstring> #include <fstream> -#include <iostream> #include <limits> #include <vector> #include "CMap.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMetrics.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMetrics.cpp index bba7645488d..c50d010802c 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMetrics.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontMetrics.cpp @@ -23,7 +23,6 @@ #include "FileFinder.h" #include "FontMetrics.h" #include "JFM.h" -#include "TFM.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFGlyphTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFGlyphTracer.cpp index fdfe71af80e..6e70e55327a 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFGlyphTracer.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFGlyphTracer.cpp @@ -20,7 +20,6 @@ #include <config.h> #include "GFGlyphTracer.h" -#include "Pair.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFReader.cpp index 5b852ed11d1..d305431d5b4 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFReader.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFReader.cpp @@ -19,10 +19,8 @@ *************************************************************************/ #include <config.h> -#include <iostream> #include <sstream> #include "GFReader.h" -#include "macros.h" #include "SignalHandler.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFTracer.cpp index 9e3ce57f2cd..d18741ba82d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/GFTracer.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/GFTracer.cpp @@ -19,9 +19,7 @@ *************************************************************************/ #include <config.h> -#include <iostream> #include <fstream> -#include <sstream> #include "GFTracer.h" #include "Glyph.h" #include "Message.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/HtmlSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/HtmlSpecialHandler.cpp index 595e8ab79e1..55ca1e5a46f 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/HtmlSpecialHandler.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/HtmlSpecialHandler.cpp @@ -25,7 +25,6 @@ #include "InputReader.h" #include "Message.h" #include "SVGTree.h" -#include "XMLNode.h" using namespace std; @@ -57,7 +56,7 @@ void HtmlSpecialHandler::preprocess (const char *prefix, istream &is, SpecialAct void HtmlSpecialHandler::preprocessNameAnchor (const string &name) { NamedAnchors::iterator it = _namedAnchors.find(name); if (it == _namedAnchors.end()) { // anchor completely undefined? - int id = _namedAnchors.size()+1; + int id = static_cast<int>(_namedAnchors.size())+1; _namedAnchors[name] = NamedAnchor(_actions->getCurrentPageNumber(), id, 0); } else if (it->second.id < 0) { // anchor referenced but not defined yet? @@ -77,7 +76,7 @@ void HtmlSpecialHandler::preprocessHrefAnchor (const string &uri) { if (it != _namedAnchors.end()) // anchor already defined? it->second.referenced = true; else { - int id = _namedAnchors.size()+1; + int id = static_cast<int>(_namedAnchors.size())+1; _namedAnchors[name] = NamedAnchor(0, -id, 0, true); } } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/InputReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/InputReader.cpp index 493dd311b30..46107532f68 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/InputReader.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/InputReader.cpp @@ -107,7 +107,7 @@ int InputReader::compare (const char *s, bool consume) { bool InputReader::parseInt (int &val, bool accept_sign) { val = 0; int fac=1; - char sign; // explicitly given sign + int sign; // explicitly given sign if (accept_sign && ((sign = peek()) == '+' || sign == '-')) { if (isdigit(peek(1))) { get(); // skip sign @@ -143,7 +143,7 @@ bool InputReader::parseInt (int base, int &val) { const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; const char maxdigit = digits[base-1]; - char c; + int c; if (!isalnum(c = tolower(peek())) || c > maxdigit) return false; @@ -167,7 +167,7 @@ char InputReader::parseDouble (double &val) { int int_part=0; bool is_float = false; skipSpace(); - char sign = peek(); + int sign = peek(); if (parseInt(int_part)) { // match [+-]?[0-9]+\.? if (peek() == '.') { get(); @@ -179,7 +179,6 @@ char InputReader::parseDouble (double &val) { } } else { // match [+-]?\. - char sign; // explicitly given sign if ((sign = peek()) == '+' || sign == '-') { // match [+-]?\.[0-9] if (peek(1) != '.' || !isdigit(peek(2))) return 0; @@ -199,7 +198,7 @@ char InputReader::parseDouble (double &val) { frac_part += (get()-'0')/u; val = (int_part + frac_part) * fac; // parse exponent - char c; + int c; if (tolower(peek()) == 'e' && (isdigit(c=peek(1)) || ((c == '+' || c == '-') && isdigit(peek(2))))) { get(); // skip 'e' int exp; @@ -245,7 +244,7 @@ string InputReader::getWord () { char InputReader::getPunct () { skipSpace(); if (ispunct(peek())) - return get(); + return char(get()); return 0; } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/JFM.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/JFM.h index 413b77ab83e..42e4deb3dd8 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/JFM.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/JFM.h @@ -30,6 +30,8 @@ class JFM : public TFM public: JFM (std::istream &is); bool verticalLayout () const {return _vertical;} + UInt16 minChar () const {return _minchar;} + UInt16 maxChar () const {return static_cast<UInt16>(_minchar+_charTypeTable.size()-1);} protected: void readTables (StreamReader &sr, int nt, int nw, int nh, int nd, int ni); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp index a8352d502dc..e972dd55ad3 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp @@ -169,7 +169,7 @@ void MapLine::parseDVIPDFMLine (InputReader &ir) { ir.skipSpace(); while (ir.peek() == '-') { ir.get(); - char option = ir.get(); + int option = ir.get(); if (!isprint(option)) throw MapLineException("option character expected"); ir.skipSpace(); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/MetafontWrapper.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/MetafontWrapper.cpp index d59a04bd444..e60a66d1cb6 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/MetafontWrapper.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/MetafontWrapper.cpp @@ -28,8 +28,7 @@ #include "Message.h" #include "MetafontWrapper.h" #include "Process.h" -#include "SignalHandler.h" -#include "macros.h" +#include "XMLString.h" using namespace std; @@ -65,35 +64,36 @@ bool MetafontWrapper::call (const string &mode, double mag) { const char *cmd = "mf"; #endif ostringstream oss; - oss << "\"\\mode=" << mode << ";" - "mag:=" << mag << ";" - "batchmode;" - "input " << _fontname << "\""; + oss << "\"\\mode=" << mode << ";" // set MF mode, e.g. 'proof', 'ljfour' or 'localfont' + "mode_setup;" // initialize MF variables + "mag:=" << mag << ";" // set magnification factor + "show pixels_per_inch*mag;" // print character resolution to stdout + "batchmode;" // don't halt on errors and don't print informational messages + "input " << _fontname << "\""; // load font description Message::mstream(false, Message::MC_STATE) << "\nrunning Metafont for " << _fontname << '\n'; Process mf_process(cmd, oss.str().c_str()); - mf_process.run(); - - // try to read Metafont's logfile and get name of created GF file - ifstream ifs((_fontname+".log").c_str()); - if (ifs) { - char buf[128]; - while (ifs) { - ifs.getline(buf, 128); - string line = buf; - if (line.substr(0, 15) == "! Interruption.") - SignalHandler::instance().trigger(true); - if (line.substr(0, 17) == "Output written on") { - size_t pos = line.find("gf ", 18+_fontname.length()); - if (pos != string::npos) { - string gfname = line.substr(18, pos-16); // GF filename found - FileSystem::rename(gfname, _fontname+".gf"); - } - break; - } + string mf_messages; + mf_process.run(&mf_messages); + + // get resolution value from stdout created by above MF command + char buf[256]; + istringstream iss(mf_messages); + int resolution = 0; + while (iss) { + iss.getline(buf, sizeof(buf)); + string line = buf; + if (line.substr(0, 3) == ">> ") { + resolution = atoi(line.substr(3).c_str()); + break; } } - ifstream gf((_fontname+".gf").c_str()); - return (bool)gf; + // compose expected name of GF file (see Metafont Book, p. 324) + string gfname = _fontname + "."; + if (resolution > 0) + gfname += XMLString(resolution); + gfname += "gf"; + FileSystem::rename(gfname, _fontname+".gf"); // remove resolution from filename + return FileSystem::exists(_fontname+".gf"); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PSInterpreter.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PSInterpreter.cpp index dba47987bce..77da4520bec 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PSInterpreter.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PSInterpreter.cpp @@ -21,7 +21,6 @@ #include <config.h> #include <cstring> #include <fstream> -#include <iostream> #include <sstream> #include "FileFinder.h" #include "InputReader.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PdfSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PdfSpecialHandler.cpp index 9829776bf77..ee278d10f05 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PdfSpecialHandler.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PdfSpecialHandler.cpp @@ -45,7 +45,7 @@ bool PdfSpecialHandler::process (const char *prefix, istream &is, SpecialActions // read mode selector ('+', '-', or '=') char modechar = '+'; // default mode (append if new, do not replace existing mapping) if (strchr("=+-", ir.peek())) // leading modifier given? - modechar = ir.get(); + modechar = char(ir.get()); else if (!_maplineProcessed) { // no modifier given? // remove default map entries if this is the first mapline/mapfile special called FontMap::instance().clear(); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp index ed81588b695..59bc21e7cf8 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp @@ -151,41 +151,55 @@ bool Process::run (string *out) { close_handle(devnull); return exitcode == 0; #else + int pipefd[2]; + pipe(pipefd); pid_t pid = fork(); if (pid == 0) { // child process - if (!out) { - int devnull = open(FileSystem::DEVNULL, O_WRONLY); - if (devnull >= 0) { - dup2(devnull, STDOUT_FILENO); - dup2(devnull, STDERR_FILENO); - close(devnull); - } - } + dup2(pipefd[1], STDOUT_FILENO); // redirect stdout to the pipe + dup2(pipefd[1], STDERR_FILENO); // redirect stderr to the pipe + close(pipefd[0]); + close(pipefd[1]); + vector<const char*> params; params.push_back(_cmd.c_str()); string paramstr = _paramstr; // private copy to be changed by split_paramstr() split_paramstr(paramstr, params); - params.push_back(0); // trailing NULL marks end + params.push_back(0); // trailing NULL marks end of parameter list execvp(_cmd.c_str(), const_cast<char* const*>(¶ms[0])); exit(1); } - if (pid > 0) { // main process - int status; + close(pipefd[1]); + bool ok = false; + if (pid > 0) { // parent process for (;;) { + if (out) { + // + out->clear(); + char buf[512]; + ssize_t len; + while ((len = read(pipefd[0], buf, sizeof(buf)-1)) > 0) { + buf[len] = 0; + *out += string(buf); + } + } + int status; waitpid(pid, &status, WNOHANG); - if (WIFEXITED(status)) // child process exited normally - return WEXITSTATUS(status) == 0; - + if (WIFEXITED(status)) { // child process exited normally + ok = (WEXITSTATUS(status) == 0); + break; + } try { SignalHandler::instance().check(); } catch (SignalException &e) { // caught ctrl-c + close(pipefd[0]); kill(pid, SIGKILL); throw; } } } - return false; + close(pipefd[0]); + return ok; #endif } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp index 27d515a8364..7f909ba17b5 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/PsSpecialHandler.cpp @@ -21,12 +21,10 @@ #include <config.h> #include <cmath> #include <fstream> -#include <iostream> #include <memory> #include <sstream> #include "EPSFile.h" #include "FileFinder.h" -#include "Ghostscript.h" #include "Message.h" #include "PathClipper.h" #include "PSPattern.h" @@ -35,9 +33,6 @@ #include "SpecialActions.h" #include "SVGTree.h" #include "TensorProductPatch.h" -#include "VectorIterator.h" -#include "XMLNode.h" -#include "XMLString.h" #include "TriangularPatch.h" @@ -396,7 +391,6 @@ void PsSpecialHandler::dviEndPage (unsigned) { double w = max(0.0, _previewFilter.width()); double h = max(0.0, _previewFilter.height()); double d = max(0.0, _previewFilter.depth()); - bool isBaselineHorizontal = true; if (_actions && (_actions->getBBoxFormatString() == "preview" || _actions->getBBoxFormatString() == "min")) { if (_actions->getBBoxFormatString() == "preview") { _actions->bbox() = bbox; @@ -426,7 +420,7 @@ void PsSpecialHandler::dviEndPage (unsigned) { // apply page transformations to box extents Matrix pagetrans; _actions->getPageTransform(pagetrans); - isBaselineHorizontal = transform_box_extents(pagetrans, w, h, d); + bool isBaselineHorizontal = transform_box_extents(pagetrans, w, h, d); _actions->bbox().lock(); if (isBaselineHorizontal) { @@ -722,7 +716,7 @@ void PsSpecialHandler::makepattern (vector<double> &p) { * 1-3: (optional) RGB values for uncolored tiling patterns * further parameters depend on the pattern type */ void PsSpecialHandler::setpattern (vector<double> &p) { - int pattern_id = p[0]; + int pattern_id = static_cast<int>(p[0]); Color color; if (p.size() == 4) color.setRGB(p[1], p[2], p[3]); @@ -775,7 +769,6 @@ void PsSpecialHandler::clip (vector<double>&, bool evenodd) { * @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */ void PsSpecialHandler::clip (Path &path, bool evenodd) { // when this method is called, _path contains the clipping path - _path.removeRedundantCommands(); if (path.empty() || !_actions) return; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.cpp index 0d8310748ee..752b5c1346d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.cpp @@ -21,7 +21,6 @@ #include <config.h> #include <algorithm> #include <sstream> -#include <string> #include "BoundingBox.h" #include "DependencyGraph.h" #include "DVIToSVG.h" @@ -41,6 +40,7 @@ bool SVGTree::USE_FONTS=true; bool SVGTree::CREATE_USE_ELEMENTS=false; bool SVGTree::RELATIVE_PATH_CMDS=false; bool SVGTree::MERGE_CHARS=true; +bool SVGTree::ADD_COMMENTS=false; double SVGTree::ZOOM_FACTOR=1.0; @@ -336,6 +336,23 @@ static XMLElementNode* createGlyphNode (int c, const PhysicalFont &font, GFGlyph } +static string font_info (const Font &font) { + ostringstream oss; + if (const NativeFont *nf = dynamic_cast<const NativeFont*>(&font)) { + oss << nf->familyName() << ' ' << nf->styleName() << "; " << nf->filename(); + if (nf->style()) { + if (nf->style()->bold != 0) + oss << ", bold:" << XMLString(nf->style()->bold) << "pt"; + if (nf->style()->extend != 1) + oss << ", extent:" << XMLString(nf->style()->extend); + if (nf->style()->slant != 0) + oss << ", slant:" << XMLString(nf->style()->slant); + } + } + return oss.str(); +} + + void SVGTree::appendFontStyles (const set<const Font*> &fonts) { if (CREATE_STYLE && USE_FONTS && !fonts.empty() && _defs) { XMLElementNode *styleNode = new XMLElementNode("style"); @@ -354,7 +371,13 @@ void SVGTree::appendFontStyles (const set<const Font*> &fonts) { << ";font-size:" << XMLString(it->second->scaledSize()) << "px"; if (it->second->color() != Color::BLACK) style << ";fill:" << it->second->color().svgColorString(); - style << "}\n"; + style << '}'; + if (ADD_COMMENTS) { + string info = font_info(*it->second); + if (!info.empty()) + style << " /* " << info << " */"; + } + style << '\n'; } XMLCDataNode *cdata = new XMLCDataNode(style.str()); styleNode->append(cdata); @@ -371,6 +394,11 @@ void SVGTree::append (const PhysicalFont &font, const set<int> &chars, GFGlyphTr return; if (USE_FONTS) { + if (ADD_COMMENTS) { + string info = font_info(font); + if (!info.empty()) + appendToDefs(new XMLCommentNode(string(" font: ")+info+" ")); + } XMLElementNode *fontNode = new XMLElementNode("font"); string fontname = font.name(); fontNode->addAttribute("id", fontname); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.h index 29667d4745e..0afc57988fb 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/SVGTree.h @@ -90,10 +90,11 @@ class SVGTree public: static bool USE_FONTS; ///< if true, create font references and don't draw paths directly - static bool CREATE_STYLE; ///< use style elements and class attributes to reference fonts? + static bool CREATE_STYLE; ///< use style elements and class attributes to reference fonts? static bool CREATE_USE_ELEMENTS; ///< allow generation of <use/> elements? static bool RELATIVE_PATH_CMDS; ///< relative path commands rather than absolute ones? static bool MERGE_CHARS; ///< whether to merge chars with common properties into the same <text> tag + static bool ADD_COMMENTS; ///< add comments with additional information static double ZOOM_FACTOR; ///< factor applied to width/height attribute protected: diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/SpecialManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/SpecialManager.cpp index 6abec223167..76e300773af 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/SpecialManager.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/SpecialManager.cpp @@ -25,7 +25,6 @@ #include "SpecialHandler.h" #include "SpecialManager.h" #include "PsSpecialHandler.h" -#include "macros.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp index 7e7ba4d08cd..f15023f58da 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp @@ -39,7 +39,7 @@ istream& StreamReader::replaceStream (istream &in) { UInt32 StreamReader::readUnsigned (int bytes) { UInt32 ret = 0; for (bytes--; bytes >= 0 && !_is->eof(); bytes--) { - UInt32 b = _is->get(); + UInt32 b = UInt32(_is->get()); ret |= b << (8*bytes); } return ret; @@ -61,7 +61,7 @@ UInt32 StreamReader::readUnsigned (int bytes, CRC32 &crc32) { * @param[in] bytes number of bytes to read (max. 4) * @return read integer */ Int32 StreamReader::readSigned (int bytes) { - Int32 ret = _is->get(); + Int32 ret = Int32(_is->get()); if (ret & 128) // negative value? ret |= 0xffffff00; for (bytes-=2; bytes >= 0 && !_is->eof(); bytes--) @@ -76,7 +76,7 @@ Int32 StreamReader::readSigned (int bytes) { * @return read integer */ Int32 StreamReader::readSigned (int bytes, CRC32 &crc32) { Int32 ret = readSigned(bytes); - crc32.update(ret, bytes); + crc32.update(UInt32(ret), bytes); return ret; } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamWriter.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamWriter.cpp index 7ab1846b6e8..5b50b33673a 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamWriter.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamWriter.cpp @@ -30,7 +30,7 @@ using namespace std; * @param[in] n number of bytes to be considered */ void StreamWriter::writeUnsigned (UInt32 val, int n) { for (n--; n >= 0; n--) - _os.put((val >> (8*n)) & 0xff); + _os.put(char((val >> (8*n)) & 0xff)); } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Subfont.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Subfont.cpp index 762ab8b65d7..8b125ac5ef9 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Subfont.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Subfont.cpp @@ -24,15 +24,16 @@ #include <fstream> #include <limits> #include "FileFinder.h" -#include "Subfont.h" #include "Message.h" +#include "Subfont.h" + using namespace std; // helper functions static int skip_mapping_data (istream &is); -static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &pos); +static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, long &pos); /** Constructs a new SubfontDefinition object. @@ -105,7 +106,7 @@ Subfont* SubfontDefinition::subfont (const string &id) const { int SubfontDefinition::subfonts (vector<Subfont*> &sfs) const { for (ConstIterator it=_subfonts.begin(); it != _subfonts.end(); ++it) sfs.push_back(it->second); - return sfs.size(); + return int(sfs.size()); } ////////////////////////////////////////////////////////////////////// @@ -153,7 +154,7 @@ bool Subfont::read () { // build mapping array _mapping = new UInt16[256]; memset(_mapping, 0, 256*sizeof(UInt16)); - int pos=0; + long pos=0; char buf[1024]; bool complete=false; while (!complete) { @@ -210,7 +211,7 @@ static int skip_mapping_data (istream &is) { * @param[in] fname name of the mapfile being scanned * @param[in,out] offset position/index of next mapping value * @return true if the line is the last one the current mapping sequence, i.e. the line doesn't end with a backslash */ -static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, int &offset) { +static bool scan_line (const char *line, int lineno, UInt16 *mapping, const string &fname, long &offset) { const char *p=line; char *q; for (; *p && isspace(*p); p++); @@ -222,7 +223,7 @@ static bool scan_line (const char *line, int lineno, UInt16 *mapping, const stri } else { long val1 = strtol(p, &q, 0); // first value of range - long val2; // last value of range + long val2 = -1; // last value of range ostringstream oss; // output stream for exception messages switch (*q) { case ':': diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/TFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/TFM.cpp index 5c492f01217..dbb8658069e 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/TFM.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/TFM.cpp @@ -19,7 +19,6 @@ *************************************************************************/ #include <config.h> -#include <iostream> #include <fstream> #include <vector> #include "FileFinder.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/TensorProductPatch.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/TensorProductPatch.cpp index a5ded129648..e3eb030d58d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/TensorProductPatch.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/TensorProductPatch.cpp @@ -18,7 +18,6 @@ ** along with this program; if not, see <http://www.gnu.org/licenses/>. ** *************************************************************************/ -#include <iostream> #include <valarray> #include "TensorProductPatch.h" diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/TpicSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/TpicSpecialHandler.cpp index 6d1402976c3..4992209449f 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/TpicSpecialHandler.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/TpicSpecialHandler.cpp @@ -30,9 +30,7 @@ #include "SpecialActions.h" #include "SVGTree.h" #include "TpicSpecialHandler.h" -#include "XMLNode.h" -#include "XMLString.h" -#include "types.h" + using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.cpp index 8292981e55d..ec62a41dd96 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.cpp @@ -19,6 +19,7 @@ *************************************************************************/ #include <xxhash.h> +#include <cctype> #include <cstddef> #include "Unicode.h" @@ -113,8 +114,8 @@ string Unicode::utf8 (Int32 c) { /* The following table provides a compact mapping from PostScript character names * to Unicode points. Instead of using the character names directly it maps the * hash values (xxhash32) of the names to the corresponding code points. - * The character mapping is derived from - * http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt and + * The character mapping is derived from the Adobe Glyph List (AGL): + * https://github.com/adobe-type-tools/agl-aglfn * http://tug.ctan.org/macros/latex/contrib/pdfx/glyphtounicode-cmr.tex */ static struct Hash2Unicode { UInt32 hash; @@ -4533,11 +4534,50 @@ static struct Hash2Unicode { }; -/** Returns the Unicode point for a given PostScript character name. - * @param psname PostScript name of the character to look up +#if 0 +/** Tries to extract the codepoint from character names like "uni1234" or "u1234". + * Valid names must match ^u(ni)?[0-9A-F]{4,}(\..*)?$. + * @param[in] psname character name + * @return the extracted codepoint or 0 on failure */ +static Int32 name_as_codepoint (const string &name) { + int offset=1; + if (name.length() >= 7 && name.substr(0, 3) == "uni") + offset = 3; + else if (name.length() < 5 || name[0] != 'u') + return 0; + + Int32 cp=0; + for (string::const_iterator it=name.begin()+offset; it != name.end() && *it != '.'; ++it) { + if (!isdigit(*it) && (*it < 'A' || *it > 'F')) + return 0; + cp = (cp*16) + (*it - (isdigit(*it) ? '0' : 'A')); + } + return cp; +} + + +static const char* get_suffix (const string &name) { + static const char *suffixes[] = { + "small", "swash", "superior", "inferior", "numerator", "denominator", "oldstyle", + "display", "text", "big", "bigg", "Big", "Bigg", 0 + }; + size_t pos = name.rfind('.'); + if (pos != string::npos) { + string suffix = name.substr(pos+1); + for (const char **p=suffixes; *p; p++) + if (suffix == *p) + return *p; + } + return 0; +} +#endif + + +/** Returns the Unicode point for a given AGL character name. + * @param name AGL name of the character to look up * @return codepoint of the character */ -Int32 Unicode::psNameToCodepoint (const string &psname) { - UInt32 hash = XXH32(&psname[0], psname.length(), 0); +Int32 Unicode::aglNameToCodepoint (const string &name) { + UInt32 hash = XXH32(&name[0], name.length(), 0); int left=0; int right=sizeof(hash2unicode)/sizeof(Hash2Unicode)-1; while (left <= right) { diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.h index 4dd790c1b28..8b25b4193c1 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Unicode.h @@ -29,7 +29,7 @@ struct Unicode static bool isValidCodepoint (UInt32 code); static UInt32 charToCodepoint (UInt32 c); static std::string utf8 (Int32 c); - static Int32 psNameToCodepoint (const std::string &psname); + static Int32 aglNameToCodepoint (const std::string &name); }; #endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/VFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/VFReader.cpp index 9f023d527de..286f0513a55 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/VFReader.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/VFReader.cpp @@ -23,7 +23,6 @@ #include "Font.h" #include "VFActions.h" #include "VFReader.h" -#include "macros.h" using namespace std; diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLDocument.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLDocument.cpp index b2131b5f3f9..33ad5f645ef 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLDocument.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLDocument.cpp @@ -19,7 +19,6 @@ *************************************************************************/ #include <config.h> -#include "macros.h" #include "XMLDocument.h" using namespace std; @@ -47,8 +46,8 @@ void XMLDocument::clear () { void XMLDocument::append (XMLNode *node) { if (!node) return; - XMLElementNode *newRoot = dynamic_cast<XMLElementNode*>(node); - if (newRoot) { // there can only be one root element node in the document + if (XMLElementNode *newRoot = dynamic_cast<XMLElementNode*>(node)) { + // there can only be one root element node in the document delete _rootElement; // so if there is already one... _rootElement = newRoot; // ...we replace it } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLNode.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLNode.cpp index ff62055e924..c8beab36bb5 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLNode.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/XMLNode.cpp @@ -21,6 +21,7 @@ #include <config.h> #include <map> #include <list> +#include <sstream> #include "macros.h" #include "XMLNode.h" #include "XMLString.h" @@ -215,10 +216,17 @@ const char* XMLElementNode::getAttributeValue(const std::string& name) const { ////////////////////// void XMLTextNode::append (XMLNode *node) { + if (!node) + return; if (XMLTextNode *tn = dynamic_cast<XMLTextNode*>(node)) append(tn); - else + else { + // append text representation of the node + ostringstream oss; + node->write(oss); + append(XMLString(oss.str())); delete node; + } } diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/dvisvgm.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/dvisvgm.cpp index 073b5bd2045..a3bb950f07e 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/dvisvgm.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/dvisvgm.cpp @@ -23,7 +23,6 @@ #include <fstream> #include <iostream> #include <sstream> -#include <string> #include <xxhash.h> #include "gzstream.h" #include "CommandLine.h" @@ -31,21 +30,15 @@ #include "DVIToSVGActions.h" #include "EPSToSVG.h" #include "FileFinder.h" -#include "FilePath.h" #include "FileSystem.h" #include "Font.h" -#include "FontCache.h" #include "FontEngine.h" -#include "FontMap.h" #include "Ghostscript.h" #include "HtmlSpecialHandler.h" -#include "InputReader.h" -#include "Message.h" #include "PageSize.h" #include "PSInterpreter.h" #include "PsSpecialHandler.h" #include "SignalHandler.h" -#include "SpecialManager.h" #include "SVGOutput.h" #include "System.h" @@ -114,15 +107,15 @@ static bool set_cache_dir (const CommandLine &args) { if (args.cache_given() && !args.cache_arg().empty()) { if (args.cache_arg() == "none") PhysicalFont::CACHE_PATH = 0; - else if (FileSystem::exists(args.cache_arg().c_str())) + else if (FileSystem::exists(args.cache_arg())) PhysicalFont::CACHE_PATH = args.cache_arg().c_str(); else Message::wstream(true) << "cache directory '" << args.cache_arg() << "' does not exist (caching disabled)\n"; } else if (const char *userdir = FileSystem::userdir()) { static string cachepath = userdir + string("/.dvisvgm/cache"); - if (!FileSystem::exists(cachepath.c_str())) - FileSystem::mkdir(cachepath.c_str()); + if (!FileSystem::exists(cachepath)) + FileSystem::mkdir(cachepath); PhysicalFont::CACHE_PATH = cachepath.c_str(); } if (args.cache_given() && args.cache_arg().empty()) { @@ -266,6 +259,7 @@ int main (int argc, char *argv[]) { SVGTree::ZOOM_FACTOR = args.zoom_arg(); SVGTree::RELATIVE_PATH_CMDS = args.relative_given(); SVGTree::MERGE_CHARS = !args.no_merge_given(); + SVGTree::ADD_COMMENTS = args.comments_given(); DVIToSVG::TRACE_MODE = args.trace_all_given() ? (args.trace_all_arg() ? 'a' : 'm') : 0; Message::LEVEL = args.verbosity_arg(); PhysicalFont::EXACT_BBOX = args.exact_given(); diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/options.xml b/Build/source/texk/dvisvgm/dvisvgm-src/src/options.xml index d24d0fdfa61..ecc4b08d8c5 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/options.xml +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/options.xml @@ -52,6 +52,9 @@ <option long="colornames"> <description>prefer color names to RGB values if possible</description> </option> + <option long="comments"> + <description>add comments with additional information</description> + </option> <option long="grad-overlap" if="!defined(DISABLE_GS)"> <description>create operlapping color gradient segments</description> </option> |