/** Evaluates the special dvisvgm:bbox. * variant 1: dvisvgm:bbox [r[el]] <width> <height> [<depth>] [transform] * variant 2: dvisvgm:bbox a[bs] <x1> <y1> <x2> <y2> [transform] * variant 3: dvisvgm:bbox f[ix] <x1> <y1> <x2> <y2> [transform] * variant 4: dvisvgm:bbox n[ew] <name> * variant 5: dvisvgm:bbox lock | unlock */ void DvisvgmSpecialHandler::processBBox (InputReader &ir, SpecialActions &actions) { ir.skipSpace(); if (ir.check("lock")) actions.bbox().lock(); else if (ir.check("unlock")) actions.bbox().unlock(); else { int c = ir.peek(); try { if (!isalpha(c)) c = 'r'; // no mode specifier => relative box parameters else { while (!isspace(ir.peek())) // skip trailing characters ir.get(); if (c == 'n') { // "new": create new local bounding box ir.skipSpace(); string name; while (isalnum(ir.peek())) name += char(ir.get()); ir.skipSpace(); if (!name.empty() && ir.eof()) actions.bbox(name, true); // create new user box } else if (c == 'a' || c == 'f') { // "abs" or "fix" Length lengths[4]; for (Length &len : lengths) len = read_length(ir); BoundingBox b(lengths[0], lengths[1], lengths[2], lengths[3]); ir.skipSpace(); if (ir.check("transform")) b.transform(actions.getMatrix()); if (c == 'a') actions.embed(b); else { actions.bbox() = b; actions.bbox().lock(); } } } if (c == 'r') { Length w = read_length(ir); Length h = read_length(ir); Length d = read_length(ir); ir.skipSpace(); update_bbox(w, h, d, ir.check("transform"), actions); } } catch (const UnitException &e) { throw SpecialException(string("dvisvgm:bbox: ") + e.what()); } } }
static string read_entry (InputReader &in) { string entry; bool accept_slashes=true; while (!in.eof() && ((in.peek() == '/' && accept_slashes) || valid_name_char(in.peek()))) { if (in.peek() != '/') accept_slashes = false; entry += char(in.get()); } if (entry.length() > 1) { // strip leading slashes // According to the PostScript specification, a single slash without further // following characters is a valid name. size_t n=0; while (n < entry.length() && entry[n] == '/') n++; entry = entry.substr(n); } return entry; }
/** Evaluates the special dvisvgm:bbox. * variant 1: dvisvgm:bbox [r[el]] <width> <height> [<depth>] * variant 2: dvisvgm:bbox a[bs] <x1> <y1> <x2> <y2> * variant 3: dvisvgm:bbox f[ix] <x1> <y1> <x2> <y2> * variant 4: dvisvgm:bbox n[ew] <name> */ void DvisvgmSpecialHandler::processBBox (InputReader &ir, SpecialActions *actions) { const double pt2bp = 72/72.27; ir.skipSpace(); int c = ir.peek(); if (isalpha(c)) { while (!isspace(ir.peek())) // skip trailing characters ir.get(); if (c == 'n') { ir.skipSpace(); string name; while (isalnum(ir.peek())) name += char(ir.get()); ir.skipSpace(); if (!name.empty() && ir.eof()) actions->bbox(name, true); // create new user box } else if (c == 'a' || c == 'f') { double p[4]; for (int i=0; i < 4; i++) p[i] = ir.getDouble()*pt2bp; BoundingBox b(p[0], p[1], p[2], p[3]); if (c == 'a') actions->embed(b); else { actions->bbox() = b; actions->bbox().lock(); } } } else c = 'r'; // no mode specifier => relative box parameters if (c == 'r') { double w = ir.getDouble()*pt2bp; double h = ir.getDouble()*pt2bp; double d = ir.getDouble()*pt2bp; update_bbox(w, h, d, actions); } }
void CommandLine::handle_zip (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getIntArg(ir, opt, longopt, _zip_arg)) _zip_given = true; }
void CommandLine::handle_version (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getBoolArg(ir, opt, longopt, _version_arg)) _version_given = true; }
void CommandLine::handle_trace_all (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getBoolArg(ir, opt, longopt, _trace_all_arg)) _trace_all_given = true; }
void CommandLine::handle_progress (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getDoubleArg(ir, opt, longopt, _progress_arg)) _progress_given = true; }
void CommandLine::handle_no_specials (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getStringArg(ir, opt, longopt, _no_specials_arg)) _no_specials_given = true; }
void CommandLine::handle_cache (InputReader &ir, const Option &opt, bool longopt) { if (ir.eof() || getStringArg(ir, opt, longopt, _cache_arg)) _cache_given = true; }