Ejemplo n.º 1
0
GlyphId CompositeText::addToFont(String name) {
    Exception::FontContext c1 (font);

    HorMetric hm;
    hm.advanceWidth = 0;
    hm.lsb = 0;
    Components components;
    Chars::iterator c;
    UShort totalAdvance = 0;
    for (c = chars.begin(); c != chars.end(); c ++) {
        totalAdvance += (*c)->getAdvance();
    }
    for (c = chars.begin(); c != chars.end(); c ++) {
        ((CompositeChar &)(**c)).addToComponents (components, hm, totalAdvance);
    }
    GlyphPtr newGlyph;
    if (components.empty())
        newGlyph = new Glyph (font, name, hm);
    else {
        newGlyph = new CompositeGlyph (font, name, hm, components);
        hm.lsb = newGlyph->getDisplacement();
        newGlyph->setHorMetric (hm);
    }
    return font.addGlyph (newGlyph);
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------------------
void dump_components(const Components& components, ostream& outf)
{
	if (components.empty())
		return;

	int depth(1);

	outf << string(depth * 2, ' ') << "<components>" << endl;

	for (Components::const_iterator citr(components.begin()); citr != components.end(); ++citr)
	{
		outf << string((depth + 1) * 2, ' ') << "<component name=\"";
		outf << citr->first << "\" id=\"" << (1 + distance(components.begin(), citr)) << "\"/>" << endl;
	}

	outf << string(depth * 2, ' ') << "</components>" << endl;
}