Ejemplo n.º 1
0
  /*!
     * \class TextCursorChangeFontStretch
   * \author Anders Fernström
   * \date 2005-11-03
   * \date 2005-11-04 (update)
     *
     * \brief Command for changing font stretch
   *
   * 2005-11-04 AF, implemented the function
     */
  void TextCursorChangeFontStretch::execute()
  {
    QTextCursor cursor( document()->getCursor()->currentCell()->textCursor() );
    if( !cursor.isNull() )
    {
      QTextCharFormat format = cursor.charFormat();
      QFont font = format.font();

      int oldStretch = font.stretch();
      if( oldStretch != stretch_ )
      {
        font.setStretch( stretch_ );
        format.setFont( font );

        cursor.mergeCharFormat ( format );

        if( oldStretch == cursor.charFormat().font().stretch() )
        {
          // 2006-01-30 AF, add message box
          QString msg = "QT was unable to stretch the font";
          QMessageBox::warning( 0, "Warning", msg, "OK" );
        }
      }
    }

  }
Ejemplo n.º 2
0
int QFontProto::stretch() const
{
  QFont *item = qscriptvalue_cast<QFont*>(thisObject());
  if (item)
    return item->stretch();
  return 0;
}
void tst_QFont::resolve()
{
    QFont font;
    font.setPointSize(font.pointSize() * 2);
    font.setItalic(false);
    font.setWeight(QFont::Normal);
    font.setUnderline(false);
    font.setStrikeOut(false);
    font.setOverline(false);
    font.setStretch(QFont::Unstretched);

    QFont font1;
    font1.setWeight(QFont::Bold);
    QFont font2 = font1.resolve(font);

    QVERIFY(font2.weight() == font1.weight());

    QVERIFY(font2.pointSize() == font.pointSize());
    QVERIFY(font2.italic() == font.italic());
    QVERIFY(font2.underline() == font.underline());
    QVERIFY(font2.overline() == font.overline());
    QVERIFY(font2.strikeOut() == font.strikeOut());
    QVERIFY(font2.stretch() == font.stretch());

    QFont font3;
    font3.setStretch(QFont::UltraCondensed);
    QFont font4 = font3.resolve(font1).resolve(font);

    QVERIFY(font4.stretch() == font3.stretch());

    QVERIFY(font4.weight() == font.weight());
    QVERIFY(font4.pointSize() == font.pointSize());
    QVERIFY(font4.italic() == font.italic());
    QVERIFY(font4.underline() == font.underline());
    QVERIFY(font4.overline() == font.overline());
    QVERIFY(font4.strikeOut() == font.strikeOut());


    QFont f1,f2,f3;
    f2.setPointSize(45);
    f3.setPointSize(55);

    QFont f4 = f1.resolve(f2);
    QCOMPARE(f4.pointSize(), 45);
    f4 = f4.resolve(f3);
    QCOMPARE(f4.pointSize(), 55);
}
Ejemplo n.º 4
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

}
Ejemplo n.º 5
0
/*virtual*/
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
                           gfxFontStyle& aFontStyle,
                           float aDevPixPerCSSPixel)
{
  QFont qFont = QGuiApplication::font();

  NS_NAMED_LITERAL_STRING(quote, "\"");
  nsString family((char16_t*)qFont.family().data());
  aFontName = quote + family + quote;

  aFontStyle.systemFont = true;
  aFontStyle.style = qFont.style();
  aFontStyle.weight = qFont.weight();
  aFontStyle.stretch = qFont.stretch();
  // use pixel size directly if it is set, otherwise compute from point size
  if (qFont.pixelSize() != -1) {
    aFontStyle.size = qFont.pixelSize();
  } else {
    aFontStyle.size = qFont.pointSizeF() * qApp->primaryScreen()->logicalDotsPerInch() / 72.0f;
  }

  return true;
}