src/lib/src/functions.cpp
/**
 * Converts a QFont to a CSS string.
 * @param	font	The font to convert.
 * @return	The CSS font.
 */
Converts a QFont to a CSS string.
@param       font    The font to convert.
@return      The CSS font.
Converts a QFont to a CSS string . @param font The font to convert . @return The CSS font .
QString qFontToCss(const QFont &font)
{
	QString style;
	switch (font.style())
	{
		case QFont::StyleNormal: style = "normal"; break;
		case QFont::StyleItalic: style = "italic"; break;
		case QFont::StyleOblique: style = "oblique"; break;
	}
	QString size;
	if (font.pixelSize() == -1) {
		size = QString::number(font.pointSize()) + "pt";
	} else {
		size = QString::number(font.pixelSize()) + "px";
	}
	const QString weight = QString::number(font.weight() * 8);
	QStringList decorations;
	if (font.strikeOut()) {
		decorations.append("line-through");
	}
	if (font.underline()) {
		decorations.append("underline");
	}
	return "font-family:'" + font.family() + "'; font-size:" + size + "; font-style:" + style + "; font-weight:" + weight + "; text-decoration:" + (decorations.isEmpty() ? "none" : decorations.join(" ")) + ";";
}
QString qFontToCss ( const QFont & font ) { QString style ; switch ( font . style ( ) ) { case QFont :: StyleNormal : style = " " ; break ; case QFont :: StyleItalic : style = " " ; break ; case QFont :: StyleOblique : style = " " ; break ; } QString size ; if ( font . pixelSize ( ) == -1 ) { size = QString :: number ( font . pointSize ( ) ) + " " ; } else { size = QString :: number ( font . pixelSize ( ) ) + " " ; } const QString weight = QString :: number ( font . weight ( ) * 8 ) ; QStringList decorations ; if ( font . strikeOut ( ) ) { decorations . append ( " " ) ; } if ( font . underline ( ) ) { decorations . append ( " " ) ; } return " " + font . family ( ) + " " + size + " " + style + " " + weight + " " + ( decorations . isEmpty ( ) ? " " : decorations . join ( " " ) ) + " " ; }
Converts a QFont to a CSS string.
Converts a QFont to a CSS string .
// Should be "font.weight() * 8 + 100", but linux doesn't handle weight the same way windows do