Example #1
0
void MailEditorMainWindow::fontChanged(const QFont &f)
  {
  FontCombo->setCurrentIndex(FontCombo->findText(QFontInfo(f).family()));
  FontSize->setCurrentIndex(FontSize->findText(QString::number(f.pointSize())));

  ui->actionBold->setChecked(f.bold());
  ui->actionItalic->setChecked(f.italic());
  ui->actionUnderline->setChecked(f.underline());
  }
Example #2
0
/*!
 * Set the format properties from the given \a font.
 */
void Format::setFont(const QFont &font)
{
    setFontName(font.family());
    setFontSize(font.pointSize());
    setFontBold(font.bold());
    setFontItalic(font.italic());
    setFontUnderline(font.underline() ? FontUnderlineSingle : FontUnderlineNone);
    setFontStrikeOut(font.strikeOut());
}
Example #3
0
void EmfPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & textItem )
{
	setClipping();

	SetBkMode( metaDC, TRANSPARENT );

	QFont f = textItem.font();
	QFontMetrics fm(f);
	HFONT wfont = CreateFontA(fm.height() - 1, fm.averageCharWidth(), 0, 0,
				10*f.weight(), f.italic(), f.underline (), f.strikeOut(),
				DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				DEFAULT_QUALITY, DEFAULT_PITCH, f.family().toAscii().data());
	SelectObject( metaDC, wfont);

	QColor colour = painter()->pen().color();
	SetTextColor( metaDC, RGB(colour.red(), colour.green(), colour.blue()));

	QString text = textItem.text();
	int size = text.size();

	QMatrix m = painter()->worldMatrix();

	XFORM xf;
	xf.eM11 = m.m11();
	xf.eM12 = m.m12();
	xf.eM21 = m.m21();
	xf.eM22 = m.m22();
	xf.eDx = m.dx();
	xf.eDy = m.dy();
	SetWorldTransform(metaDC, &xf);

#ifdef Q_WS_WIN
	wchar_t *wtext = (wchar_t *)malloc(size*sizeof(wchar_t));
	if (!wtext){
		qWarning("EmfEngine: Not enough memory in drawTextItem().");
		return;
	}
	
	size = text.toWCharArray(wtext);
	TextOutW(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), wtext, size);
	free(wtext);
#else
	TextOutA(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), text.toLocal8Bit().data(), size);
#endif

	xf.eM11 = 1.0;
	xf.eM12 = 0.0;
	xf.eM21 = 0.0;
	xf.eM22 = 1.0;
	xf.eDx = 0.0;
	xf.eDy = 0.0;
	SetWorldTransform(metaDC, &xf);

	resetClipping();
	DeleteObject(wfont);
}
Example #4
0
/**
 * Reimplemented to retain the italic/bold status on font change.
 *
 * It is important to note that, this method retains the old bold,
 * italic and underline property of the font and hence all these
 * properties should be set explicitly.
 *
 * @note This overrides (hides) the base's non virtual method.
 */
void TextItem::setFont(QFont f)
{
    const QFont old = font();

    f.setBold(old.bold());
    f.setItalic(old.italic());
    f.setUnderline(old.underline());

    QGraphicsTextItem::setFont(f);
}
Example #5
0
void EditorWidget::fontChanged(const QFont &f)
{
	if (m_initialPag == RichTextIndex) {
		m_font_input->setCurrentIndex(m_font_input->findText(QFontInfo(f).family()));
		m_font_size_input->setCurrentIndex(m_font_size_input->findText(QString::number(f.pointSize())));
		m_bold_action->setChecked(f.bold());
		m_italic_action->setChecked(f.italic());
		m_underline_action->setChecked(f.underline());
	}
}
void EnvironmentSettingsDialog::on_styleName_currentIndexChanged(int index)
{
   int style = ui->styleName->itemData(index).toInt();
   QFont font = m_lexer->font(style);

   ui->styleFont->setCurrentFont(font);
   ui->fontBold->setChecked(font.bold());
   ui->fontItalic->setChecked(font.italic());
   ui->fontUnderline->setChecked(font.underline());
   ui->fontSize->setValue(font.pointSize());
}
Example #7
0
void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase)
{
    Style fstyle = normal; //from MacTypes.h
    if(fnt.bold())
        fstyle |= bold;
    if(fnt.italic())
        fstyle |= italic;
    if(fnt.underline())
        fstyle |= underline;
    aglUseFont((AGLContext)d_func()->cx, fnt.macFontID(), fstyle, QFontInfo(fnt).pointSize(), 0, 256, listBase);
}
Example #8
0
void TextEdit::fontChanged(const QFont &f)
{
    if (m_bSelected){
        if (!m_bNoSelected)
            emit fontSelected(f);
        m_bSelected = false;
    }
    if (m_param == NULL)
        return;
    m_bChanged = true;
    if (f.bold() != m_bBold){
        m_bBold = f.bold();
        Command cmd;
        cmd->id    = CmdBold;
        cmd->flags = m_bBold ? COMMAND_CHECKED : 0;
        cmd->param = m_param;
        Event e(EventCommandChecked, cmd);
        e.process();
    }
    if (f.italic() != m_bItalic){
        m_bItalic = f.italic();
        Command cmd;
        cmd->id    = CmdItalic;
        cmd->flags = m_bItalic ? COMMAND_CHECKED : 0;
        cmd->param = m_param;
        Event e(EventCommandChecked, cmd);
        e.process();
    }
    if (f.underline() != m_bUnderline){
        m_bUnderline = f.underline();
        Command cmd;
        cmd->id    = CmdUnderline;
        cmd->flags = m_bUnderline ? COMMAND_CHECKED : 0;
        cmd->param = m_param;
        Event e(EventCommandChecked, cmd);
        e.process();
    }
    m_bChanged = false;
}
Example #9
0
File: setting.cpp Project: rd8/qGo
QString Setting::fontToString(QFont f)
{
#ifdef Q_WS_X11_xxx
	return f.rawName();
#else
	return f.family() + "-" +
		QString::number(f.pointSize()) + "-" +
		QString::number(f.weight()) + "-" +
		QString::number(f.italic()) + "-" +
		QString::number(f.underline()) + "-" +
		QString::number(f.strikeOut());
#endif
}
void XmlFontSerializator::save(const QVariant &value, QString name)
{

    QFont font = value.value<QFont>();
    QDomElement _node = doc()->createElement(name);
    _node.setAttribute("Type","QFont");
    _node.setAttribute("family",font.family());
    _node.setAttribute("pointSize",font.pointSize());
    saveBool(_node,"bold",font.bold());
    saveBool(_node,"italic",font.italic());
    saveBool(_node,"underline",font.underline());

    node()->appendChild(_node);
}
void QFontDialog::setFont( const QFont &f )
{
    d->family = f.family();
    d->style = d->fdb.styleString( f );
    d->size = f.pointSize();
    if ( d->size == -1 ) {
	    QFontInfo fi( f );
	    d->size = fi.pointSize();
    }
    d->strikeout->setChecked( f.strikeOut() );
    d->underline->setChecked( f.underline() );

    updateFamilies();
}
Example #12
0
void ConvertDialogTest::convert_addText_fontPx()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *textGroupBox = effectsScrollArea->textGroupBox;
    textGroupBox->setChecked(true);
    QLineEdit *textLineEdit = effectsScrollArea->textLineEdit;
    QString testText = "Test Text";
    textLineEdit->setText(testText);
    QComboBox *fontSizeComboBox = effectsScrollArea->textFontSizeComboBox;
    int px = 1;
    fontSizeComboBox->setCurrentIndex(px);

    QFont font = effectsScrollArea->textFontComboBox->currentFont();
    int fontSize = 20;
    font.setPixelSize(fontSize);
    font.setBold(true);
    font.setItalic(true);
    font.setUnderline(true);
    font.setStrikeOut(true);

    effectsScrollArea->textFontSizeSpinBox->setValue(fontSize);
    effectsScrollArea->textBoldPushButton->setChecked(font.bold());
    effectsScrollArea->textItalicPushButton->setChecked(font.italic());
    effectsScrollArea->textUnderlinePushButton->setChecked(font.underline());
    effectsScrollArea->textStrikeOutPushButton->setChecked(font.strikeOut());

    QColor color = Qt::green;
    effectsScrollArea->textColorFrame->setColor(color);

    effectsScrollArea->textOpacitySpinBox->setValue(0.5);
    effectsScrollArea->textPositionComboBox->setCurrentIndex(TopRightCorner);

    QPoint position = QPoint(4, 3);
    effectsScrollArea->textXSpinBox->setValue(position.x());
    effectsScrollArea->textYSpinBox->setValue(position.y());

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getTextString(), testText);
    QCOMPARE(conf.getTextFont(), font);
    QCOMPARE(conf.getTextColor(), color);
    QCOMPARE(conf.getTextOpacity(), 0.5);
    QCOMPARE(conf.getTextPosModifier(), TopRightCorner);
    QCOMPARE(conf.getTextPos(), position);
    QCOMPARE(conf.getTextUnitPair(), PosUnitPair(Pixel, Pixel));
    QCOMPARE(conf.getTextFrame(), false);
    QCOMPARE(conf.getTextRotation(), 0);
}
Example #13
0
QString SongSettingWidget::getFontText(QFont font)
{
    QString f = font.toString().split(",").at(0);
    QString st(QString("%1: %2").arg(f).arg(font.pointSize()));
    if(font.bold())
        st += ", " + tr("Bold");
    if(font.italic())
        st += ", " + tr("Italic");
    if(font.strikeOut())
        st += ", " + tr("StrikeOut");
    if(font.underline())
        st += ", " + tr("Underline");

    return st;
}
Example #14
0
void QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color,
                                QSGText::TextStyle style, const QColor &styleColor)
{
    QList<QGlyphRun> glyphsList(textLayout->glyphRuns());

    QSGGlyphNode *prevNode = 0;

    QFont font = textLayout->font();
    qreal underlinePosition, ascent, lineThickness;
    int decorations = NoDecoration;
    decorations |= (font.underline() ? Underline : 0);
    decorations |= (font.overline()  ? Overline  : 0);
    decorations |= (font.strikeOut() ? StrikeOut : 0);

    underlinePosition = ascent = lineThickness = 0;
    for (int i=0; i<glyphsList.size(); ++i) {
        QGlyphRun glyphs = glyphsList.at(i);
        QRawFont rawfont = glyphs.rawFont();
        prevNode = addGlyphs(position + QPointF(0, rawfont.ascent()), glyphs, color, style, styleColor);

        if (decorations) {
            qreal rawAscent = rawfont.ascent();
            if (decorations & Underline) {
                ascent = qMax(ascent, rawAscent);
                qreal pos = rawfont.underlinePosition();
                if (pos > underlinePosition) {
                    underlinePosition = pos;
                    // take line thickness from the rawfont with maximum underline
                    // position in this case
                    lineThickness = rawfont.lineThickness();
                }
            } else {
                // otherwise it's strike out or overline, we take line thickness
                // from the rawfont with maximum ascent
                if (rawAscent > ascent) {
                    ascent = rawAscent;
                    lineThickness = rawfont.lineThickness();
                }
            }
        }
    }

    if (decorations) {
        addTextDecorations(Decoration(decorations), position + QPointF(0, ascent), color,
                           textLayout->boundingRect().width(),
                           lineThickness, underlinePosition, ascent);
    }
}
void XmlFontSerializator::save(const QVariant &value, QString name)
{
    QFont font = value.value<QFont>();
    QDomElement _node = doc()->createElement(name);
    _node.setAttribute("Type","QFont");
    _node.setAttribute("family",font.family());
    _node.setAttribute("pointSize",font.pointSize());
#if QT_VERSION>0x040800
    _node.setAttribute("stylename",font.styleName());
#endif
    _node.setAttribute("weight",font.weight());
    //saveBool(_node,"bold",font.bold());
    saveBool(_node,"italic",font.italic());
    saveBool(_node,"underline",font.underline());
    node()->appendChild(_node);
}
Example #16
0
void obs_data_set_qfont(obs_data_t* data, const char* name, QFont font){

	obs_data_t *fontObj = obs_data_create();
	obs_data_set_string(fontObj, "face", (font.family()).toUtf8().data());
	obs_data_set_string(fontObj, "style", (font.styleName()).toUtf8().data());
	obs_data_set_int(fontObj, "size", font.pointSize());

	int flags  = font.bold() ? OBS_FONT_BOLD : 0;
	flags |= font.italic() ? OBS_FONT_ITALIC : 0;
	flags |= font.underline() ? OBS_FONT_UNDERLINE : 0;
	flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0;
	obs_data_set_int(fontObj, "flags", flags);

	obs_data_set_obj(data, "font", fontObj);
	obs_data_release(fontObj);
	return;
}
Example #17
0
QString FontEdit::font2str(const QFont &f, bool use_tr)
{
    QString fontName = f.family();
    fontName += ", ";
    if (f.pointSize() > 0){
        fontName += QString::number(f.pointSize());
        fontName += " pt.";
    }else{
        fontName += QString::number(f.pixelSize());
        fontName += " pix.";
    }
    switch (f.weight()){
    case QFont::Light:
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("light"), use_tr);
        break;
    case QFont::DemiBold:
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("demibold"), use_tr);
        break;
    case QFont::Bold:
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("bold"), use_tr);
        break;
    case QFont::Black:
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("black"), use_tr);
        break;
    default:
        break;
    }
    if (f.italic()){
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("italic"), use_tr);
    }
    if (f.strikeOut()){
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("strikeout"), use_tr);
    }
    if (f.underline()){
        fontName += ", ";
        fontName += s_tr(I18N_NOOP("underline"), use_tr);
    }
    return fontName;
}
Example #18
0
/*!
    \since 4.5

    Sets the font highlighted in the QFontDialog to the given \a font.

    \sa selectedFont()
*/
void QFontDialog::setCurrentFont(const QFont &font)
{
    Q_D(QFontDialog);
    d->family = font.family();
    d->style = d->fdb.styleString(font);
    d->size = font.pointSize();
    if (d->size == -1) {
        QFontInfo fi(font);
        d->size = fi.pointSize();
    }
    d->strikeout->setChecked(font.strikeOut());
    d->underline->setChecked(font.underline());
    d->updateFamilies();
    if (d->canBeNativeDialog()) {
        if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
            helper->setCurrentFont(font);
    }
}
Example #19
0
QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled,
                             const QString &lhref, const QString &lnm, VerticalAlignment a )
{
    QString k;
    QTextOStream ts( &k );
    ts << fn.pointSize() << "/"
    << fn.weight() << "/"
    << (int)fn.underline() << "/"
    << (int)fn.strikeOut() << "/"
    << (int)fn.italic() << "/"
    << (uint)col.rgb() << "/"
    << fn.family() << "/"
    << (int)misspelled << "/"
    << lhref << "/"
    << lnm << "/"
    << (int)a;
    return k;
}
Example #20
0
/*!
    \since 4.5

    Sets the font highlighted in the QFontDialog to the given \a font.

    \sa selectedFont()
*/
void QFontDialog::setCurrentFont(const QFont &font)
{
    Q_D(QFontDialog);
    d->family = font.family();
    d->style = d->fdb.styleString(font);
    d->size = font.pointSize();
    if (d->size == -1) {
        QFontInfo fi(font);
        d->size = fi.pointSize();
    }
    d->strikeout->setChecked(font.strikeOut());
    d->underline->setChecked(font.underline());
    d->updateFamilies();

#ifdef Q_WS_MAC
    if (d->delegate)
        QFontDialogPrivate::setFont(d->delegate, font);
#endif
}
Example #21
0
void PreferenceDialog::changeStyle(int nIndice)
{
	QColor foreground = lexer.color(nIndice);
	QColor background = lexer.paper(nIndice);
	QFont font = lexer.font(nIndice);

	fontBold->setChecked( font.bold() );
	fontItalic->setChecked( font.italic() );
	fontUnderline->setChecked( font.underline() );

	fontFamilly->setCurrentFont(font);

	__updateFontSize(font);

	backgroundColorButton->setColor(background);
	foregroundColorButton->setColor(foreground);

	__updateStyleSample();
}
Example #22
0
QDomElement Calligra::Sheets::NativeFormat::createElement(const QString & tagName, const QFont & font, QDomDocument & doc)
{
    QDomElement e(doc.createElement(tagName));

    e.setAttribute("family", font.family());
    e.setAttribute("size", font.pointSize());
    e.setAttribute("weight", font.weight());
    if (font.bold())
        e.setAttribute("bold", "yes");
    if (font.italic())
        e.setAttribute("italic", "yes");
    if (font.underline())
        e.setAttribute("underline", "yes");
    if (font.strikeOut())
        e.setAttribute("strikeout", "yes");
    //e.setAttribute( "charset", KGlobal::charsets()->name( font ) );

    return e;
}
Example #23
0
void DFont :: FromODataLayout (ODataLayout *pODataLayout )
{
  QFont    *qfont  = NULL;
  QColor   *qcolor = NULL;
BEGINSEQ
  if ( !pODataLayout )                               LEAVESEQ
    
  if ( qfont = pODataLayout->get_font() )
  {  
    strcpy(family_name,QS2SZ(qfont->family()));
    weight         = (ADK_FontWeight)qfont->weight();
    italic         = qfont->italic();
    underline      = qfont->underline();
    strike_out     = qfont->strikeOut();
    fixed_pitch    = qfont->fixedPitch();
    style_hint     = (ADK_FontStyle)qfont->styleHint();
    style_strategy = (ADK_FontStyleStrategy)qfont->styleStrategy();
    stretch        = qfont->stretch();
  }
  
  prefer_quality = NO;
  if ( style_strategy && QFont::PreferQuality )
  {
    prefer_quality = YES;
    style_strategy = (ADK_FontStyleStrategy)(style_strategy - QFont::PreferQuality);
  }
  
  if ( qcolor = pODataLayout->get_text_color() )
    text_color = QCOLOR2DCOLOR(*qcolor); 
  if ( qcolor = pODataLayout->get_bg_color() )
    bg_color = QCOLOR2DCOLOR(*qcolor);

  use_pixel = NO;
  if ( (size = qfont->pointSize()) == -1 )  // pixel size used
  {
    use_pixel = YES;
    size = qfont->pixelSize();
  }

ENDSEQ

}
Example #24
0
static QString describeFont(const QFont &f)
{
    QString res = "'" + f.family() + "' ";

    if(f.pointSize() > 0)
        res += QString::number(f.pointSize()) + "pt";
    else
        res += QString::number(f.pixelSize()) + "px";

    if(f.bold())
        res += " bold";
    if(f.italic())
        res += " italic";
    if(f.underline())
        res += " underline";
    if(f.overline())
        res += " overline";
    if(f.strikeOut())
        res += " strikeout";
    return res;
}
void BiLiTextSourcePropertyDlg::mSltFontComboxChanged(const QString &text) {

	QFont font = qobject_cast<QFontComboBox *>(sender())->currentFont();

	obs_data_t *fontObj = obs_data_create();

	obs_data_set_string(fontObj, "face", (font.family()).toUtf8().data());
	obs_data_set_string(fontObj, "style", (font.styleName()).toUtf8().data());
	obs_data_set_int(fontObj, "size", font.pointSize());

	int flags  = font.bold() ? OBS_FONT_BOLD : 0;
	flags |= font.italic() ? OBS_FONT_ITALIC : 0;
	flags |= font.underline() ? OBS_FONT_UNDERLINE : 0;
	flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0;
	obs_data_set_int(fontObj, "flags", flags);

	obs_data_t *settingFont = obs_source_get_settings(mSrc);
	obs_data_set_obj(settingFont, "font", fontObj);
	obs_data_release(fontObj);
	obs_data_release(settingFont);
}
QString LegendWidget::saveToString()
{
	QString s = "<Legend>\n";
	s += FrameWidget::saveToString();
	s += "<Text>\n" + d_text->text() + "\n</Text>\n";

	QFont f = d_text->font();
	s += "<Font>" + f.family() + "\t";
	s += QString::number(f.pointSize())+"\t";
	s += QString::number(f.weight())+"\t";
	s += QString::number(f.italic())+"\t";
	s += QString::number(f.underline())+"\t";
	s += QString::number(f.strikeOut())+"</Font>\n";

	s += "<TextColor>" + d_text->color().name()+"</TextColor>\n";
	QColor bc = backgroundColor();
	s += "<Background>" + bc.name() + "</Background>\n";
	s += "<Alpha>" + QString::number(bc.alpha()) + "</Alpha>\n";
	s += "<Angle>" + QString::number(d_angle) + "</Angle>\n";
	s += "<AutoUpdate>" + QString::number(d_auto_update) + "</AutoUpdate>\n";
	return s + "</Legend>\n";
}
	void toString(const QFont & font, QString & szBuffer)
	{
		QString szFamily(font.family());
		szBuffer.sprintf("%s,%d,%d,%d", szFamily.toUtf8().data(), font.pointSize(), font.styleHint(), font.weight());
		QString szOptions;
		if(font.bold())
			szOptions.append('b');
		if(font.italic())
			szOptions.append('i');
		if(font.underline())
			szOptions.append('u');
		if(font.strikeOut())
			szOptions.append('s');
		if(font.fixedPitch())
			szOptions.append('f');

		if(!szOptions.isEmpty())
		{
			szBuffer.append(',');
			szBuffer.append(szOptions);
		}
	}
Example #28
0
void StyleSheetEditorDialog::slotAddFont()
{
    bool ok;
    QFont font = QFontDialog::getFont(&ok, this);
    if (ok) {
        QString fontStr;
        if (font.weight() != QFont::Normal) {
            fontStr += QString::number(font.weight());
            fontStr += QLatin1Char(' ');
        }

        switch (font.style()) {
        case QFont::StyleItalic:
            fontStr += QLatin1String("italic ");
            break;
        case QFont::StyleOblique:
            fontStr += QLatin1String("oblique ");
            break;
        default:
            break;
        }
        fontStr += QString::number(font.pointSize());
        fontStr += QLatin1String("pt \"");
        fontStr += font.family();
        fontStr += QLatin1Char('"');

        insertCssProperty(QLatin1String("font"), fontStr);
        QString decoration;
        if (font.underline())
            decoration += QLatin1String("underline");
        if (font.strikeOut()) {
            if (!decoration.isEmpty())
                decoration += QLatin1Char(' ');
            decoration += QLatin1String("line-through");
        }
        insertCssProperty(QLatin1String("text-decoration"), decoration);
    }
}
Example #29
0
void QJsonPaintEngine::updateFont(const QFont &font)
{
	Q_D(QJsonPaintEngine);
#ifdef QT_PICTURE_DEBUG
	qDebug() << " -> updateFont(): pt sz:" << font.pointSize();
#endif
	QStringList decorators;
	if (font.italic())     decorators << "itallic";
	if (font.strikeOut())   decorators << "strikeout";
	if (font.underline())   decorators << "underline";
	switch (font.weight())
	{
	case QFont::Light: decorators << "lighter"; break;
	case QFont::DemiBold: decorators << "bolder"; break;
	case QFont::Bold: decorators << "bold"; break;
	case QFont::Black: decorators << "bold"; break;
	case QFont::Normal: break;
	default: break;
	}

	QString units;
	float size;
	if (font.pixelSize() != -1)
	{
		units="px";
		size = font.pixelSize();
	} else {
		units="pt";
		size = font.pointSize();
	}

	d->s << QString("\t{\"f\": { \"d\": \"%1\", \"s\": %2, \"u\": \"%4\", \"f\": \"%3\"}},\r\n")
			.arg(decorators.join(" "))
			.arg(size)
			.arg(font.family())
			.arg(units);
}
Example #30
0
bool WidgetInfo::FontChanged(const char *setting)
{
	obs_data_t *font_obj = obs_data_get_obj(view->settings, setting);
	bool       success;
	uint32_t   flags;
	QFont      font;

	if (!font_obj) {
		font = QFontDialog::getFont(&success, view);
	} else {
		MakeQFont(font_obj, font);
		font = QFontDialog::getFont(&success, font, view);
		obs_data_release(font_obj);
	}

	if (!success)
		return false;

	font_obj = obs_data_create();

	obs_data_set_string(font_obj, "face", QT_TO_UTF8(font.family()));
	obs_data_set_string(font_obj, "style", QT_TO_UTF8(font.styleName()));
	obs_data_set_int(font_obj, "size", font.pointSize());
	flags  = font.bold() ? OBS_FONT_BOLD : 0;
	flags |= font.italic() ? OBS_FONT_ITALIC : 0;
	flags |= font.underline() ? OBS_FONT_UNDERLINE : 0;
	flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0;
	obs_data_set_int(font_obj, "flags", flags);

	QLabel *label = static_cast<QLabel*>(widget);
	label->setFont(font);
	label->setText(QString("%1 %2").arg(font.family(), font.styleName()));

	obs_data_set_obj(view->settings, setting, font_obj);
	obs_data_release(font_obj);
	return true;
}