summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-02-13 17:57:19 +0000
committerKarl Berry <karl@freefriends.org>2017-02-13 17:57:19 +0000
commit440b2f2a8fe3b1328d2166a83ab56a12bedc624c (patch)
tree02326974419db3aefc05d556d6e218ae8a92e480 /Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp
parent8be6eac70738a24fd3b7609bf9447b84a4237025 (diff)
import original dvisvgm-2.1.2
git-svn-id: svn://tug.org/texlive/trunk@43208 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp
index 49809861199..333bd204cb2 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/MapLine.cpp
@@ -29,16 +29,27 @@
using namespace std;
-/** Constructs a MapLine object by parsing a single mapline from the given stream. */
-MapLine::MapLine (istream &is)
- : _sfd(0), _fontindex(0), _slant(0), _bold(0), _extend(1)
+MapLine::MapLine () : _sfd(0), _fontindex(0), _slant(0), _bold(0), _extend(1)
{
+}
+
+
+/** Constructs a MapLine object by parsing a single map line from the given stream. */
+MapLine::MapLine (istream &is) : MapLine() {
char buf[256];
is.getline(buf, 256);
parse(buf);
}
+MapLine::MapLine (string str) : MapLine() {
+ size_t pos = str.rfind('\n');
+ if (pos != string::npos)
+ str = str.substr(0, pos);
+ parse(str.c_str());
+}
+
+
// Some of the following functions have been derived from the dvipdfmx source file fontmap.c:
// http://cvs.ktug.or.kr/viewcvs/dvipdfmx/src/fontmap.c?revision=1.43&view=markup
@@ -87,17 +98,19 @@ static bool split_fontname (string &fontname, string &sfdname) {
* The line may either be given in dvips or dvipdfmx mapfile format.
* @param[in] line the mapline */
void MapLine::parse (const char *line) {
- CharInputBuffer ib(line, strlen(line));
- BufferInputReader ir(ib);
- _texname = ir.getString();
- string sfdname;
- split_fontname(_texname, sfdname);
- if (!sfdname.empty())
- _sfd = SubfontDefinition::lookup(sfdname);
- if (isDVIPSFormat(line))
- parseDVIPSLine(ir);
- else
- parseDVIPDFMLine(ir);
+ if (line) {
+ CharInputBuffer ib(line, strlen(line));
+ BufferInputReader ir(ib);
+ _texname = ir.getString();
+ string sfdname;
+ split_fontname(_texname, sfdname);
+ if (!sfdname.empty())
+ _sfd = SubfontDefinition::lookup(sfdname);
+ if (isDVIPSFormat(line))
+ parseDVIPSLine(ir);
+ else
+ parseDVIPDFMLine(ir);
+ }
}