コード例 #1
0
ファイル: EmSpecialHandler.cpp プロジェクト: MiKTeX/miktex
/** Handles the "point" command that adds a point to the point list. */
void EmSpecialHandler::point (InputReader &ir, SpecialActions &actions) {
	DPair pos(actions.getX(), actions.getY());
	int n = ir.getInt();
	if (ir.getPunct() == ',') {
		pos.x(ir.getDouble());
		if (ir.getPunct() == ',')
			pos.y(ir.getDouble());
	}
	_points[n] = pos;
}
コード例 #2
0
/** Reads a length value including a trailing unit specifier and returns it. */
static Length read_length (InputReader &ir) {
	Length length;
	ir.skipSpace();
	if (!isalpha(ir.peek())) {
		double val = ir.getDouble();
		string unit = isalpha(ir.peek()) ? ir.getString(2) : "pt";
		length = Length(val, unit);
	}
	return length;
}
コード例 #3
0
/** 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);
    }
}
コード例 #4
0
ファイル: EmSpecialHandler.cpp プロジェクト: MiKTeX/miktex
/** Reads a length (value + unit) and returns its value in PS points (bp).
 *  If no unit is specified, TeX points are assumed. */
static double read_length (InputReader &in) {
	double val = in.getDouble();
	string unitstr;
	if (isalpha(in.peek())) unitstr += in.get();
	if (isalpha(in.peek())) unitstr += in.get();
	Length::Unit unit = Length::Unit::PT;
	try {
		unit = Length::stringToUnit(unitstr);
	}
	catch (UnitException &e) {
	}
	return Length(val, unit).bp();
}
コード例 #5
0
void DvisvgmSpecialHandler::processImg (InputReader &ir, SpecialActions *actions) {
    if (actions) {
        const double pt2bp = 72/72.27;
        double w = ir.getDouble()*pt2bp;
        double h = ir.getDouble()*pt2bp;
        string f = ir.getString();
        update_bbox(w, h, 0, actions);
        XMLElementNode *img = new XMLElementNode("image");
        img->addAttribute("x", actions->getX());
        img->addAttribute("y", actions->getY());
        img->addAttribute("width", w);
        img->addAttribute("height", h);
        img->addAttribute("xlink:href", f);
        if (!actions->getMatrix().isIdentity())
            img->addAttribute("transform", actions->getMatrix().getSVG());
        actions->appendToPage(img);
    }
}