Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static gint sp_style_write_ifontsize ( gchar *  p,
gint const   len,
gchar const *  key,
SPIFontSize const *const   val,
SPIFontSize const *const   base,
guint const   flags 
) [static]

Write SPIFontSize object into string.

Definition at line 3669 of file style.cpp.

References SPIFontSize::computed, SPIFontSize::inherit, SPIFontSize::set, Inkscape::CSSOStringStream::str(), SPIFontSize::type, and SPIFontSize::value.

Referenced by sp_style_write_difference(), and sp_style_write_string().

{
    if ((flags & SP_STYLE_FLAG_ALWAYS)
        || ((flags & SP_STYLE_FLAG_IFSET) && val->set)
        || ((flags & SP_STYLE_FLAG_IFDIFF) && val->set
            && (!base->set || sp_fontsize_differ(val, base))))
    {
        if (val->inherit) {
            return g_snprintf(p, len, "%s:inherit;", key);
        } else if (val->type == SP_FONT_SIZE_LITERAL) {
            for (unsigned i = 0; enum_font_size[i].key; i++) {
                if (enum_font_size[i].value == static_cast< gint > (val->value) ) {
                    return g_snprintf(p, len, "%s:%s;", key, enum_font_size[i].key);
                }
            }
        } else if (val->type == SP_FONT_SIZE_LENGTH) {
            Inkscape::CSSOStringStream os;
            os << key << ":" << val->computed << "px;";      // must specify px, see inkscape bug 1221626, mozilla bug 234789
            return g_strlcpy(p, os.str().c_str(), len);
        } else if (val->type == SP_FONT_SIZE_PERCENTAGE) {
            Inkscape::CSSOStringStream os;
            os << key << ":" << (SP_F8_16_TO_FLOAT(val->value) * 100.0) << "%;";
            return g_strlcpy(p, os.str().c_str(), len);
        }
    }
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index