// Based on kconfigbase.cpp static QFont Str2Font(const QString &aValue) { uint nFontBits; QFont aRetFont; QString chStr; QStringList sl = QStringList::split(QString::fromLatin1(","), aValue); if(sl.count() == 1) { /* X11 font spec */ aRetFont = QFont(aValue); aRetFont.setRawMode(true); } else if(sl.count() == 10) { /* qt3 font spec */ aRetFont.fromString(aValue); } else if(sl.count() == 6) { /* backward compatible kde2 font spec */ aRetFont = QFont(sl[0], sl[1].toInt(), sl[4].toUInt()); aRetFont.setStyleHint((QFont::StyleHint)sl[2].toUInt()); nFontBits = sl[5].toUInt(); aRetFont.setItalic((nFontBits & 0x01) != 0); aRetFont.setUnderline((nFontBits & 0x02) != 0); aRetFont.setStrikeOut((nFontBits & 0x04) != 0); aRetFont.setFixedPitch((nFontBits & 0x08) != 0); aRetFont.setRawMode((nFontBits & 0x20) != 0); } aRetFont.setStyleStrategy((QFont::StyleStrategy)(QFont::PreferMatch | (_antiAliasing ? QFont::PreferAntialias : QFont::NoAntialias))); return aRetFont; }
// ============================================================================ // constructor GLBox::GLBox( QWidget* parent, const char* name, GlobalOptions * _options, AnimationEngine * _anim_engine,const QGLWidget* shareWidget) : QGLWidget( parent, name, shareWidget ) { xRot = yRot = zRot = 0.0; // default object rotation xTrans = yTrans = zTrans = 0.0; // default object translation ixTrans = iyTrans = izTrans = 0; scale = 1.0; // default object scale enable_s = false; // init mutex to protect data int status = pthread_mutex_init(&mutex,NULL); if (status != 0 ) { std::cerr <<"error during [pthread_mutex_init], aborted...\n"; exit(1); } // get options store_options = _options; anim_engine = _anim_engine; makeCurrent(); // activate OpenGL context, can build display list by now nb_object = 0; // no object so far // grid gridx = new GLGridObject(0,QColor(136,141,102),store_options->xy_grid); //yellow); gridy = new GLGridObject(1,QColor(136,141,102),store_options->yz_grid); gridz = new GLGridObject(2,QColor(136,141,102),store_options->xz_grid); cube = new GLCube(store_options->mesh_length*store_options->nb_meshs, QColor(136,141,102),store_options->show_cube); resizeGrid(store_options->mesh_length,store_options->nb_meshs); line_aliased = FALSE; MAX_PARTICLES_SIZE=5.0; // poly show_poly = store_options->show_poly; // HUD //QFont f=QFont("Courier", 12, QFont::Light); QFont f; f.setFamily("fixed"); f.setRawMode(true); //f.setStyleStrategy(QFont::OpenGLCompatible); f.setPixelSize(10); f.setFixedPitch ( true ) ; f.setStyleHint(QFont::AnyStyle, QFont::PreferBitmap); hud = new GLHudObject(width,height,f,yellow); hudProjection(); tree = new GLOctree(_options); p_data = new ParticlesData(); }
void QFontProto::setRawMode(bool enable) { QFont *item = qscriptvalue_cast<QFont*>(thisObject()); if (item) item->setRawMode(enable); }
void tst_QFont::serialize_data() { QTest::addColumn<QFont>("font"); // The version in which the tested feature was added. QTest::addColumn<QDataStream::Version>("minimumStreamVersion"); QFont basicFont; // Versions <= Qt 2.1 had broken point size serialization, // so we set an integer point size. basicFont.setPointSize(9); QFont font = basicFont; QTest::newRow("defaultConstructed") << font << QDataStream::Qt_1_0; font.setLetterSpacing(QFont::AbsoluteSpacing, 105); QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5; font = basicFont; font.setWordSpacing(50.0); QTest::newRow("wordSpacing") << font << QDataStream::Qt_4_5; font = basicFont; font.setPointSize(20); QTest::newRow("pointSize") << font << QDataStream::Qt_1_0; font = basicFont; font.setPixelSize(32); QTest::newRow("pixelSize") << font << QDataStream::Qt_3_0; font = basicFont; font.setStyleHint(QFont::Monospace); QTest::newRow("styleHint") << font << QDataStream::Qt_1_0; font = basicFont; font.setStretch(4000); QTest::newRow("stretch") << font << QDataStream::Qt_4_3; font = basicFont; font.setWeight(99); QTest::newRow("weight") << font << QDataStream::Qt_1_0; font = basicFont; font.setUnderline(true); QTest::newRow("underline") << font << QDataStream::Qt_1_0; font = basicFont; font.setStrikeOut(true); QTest::newRow("strikeOut") << font << QDataStream::Qt_1_0; font = basicFont; font.setFixedPitch(true); // This fails for versions less than this, as ignorePitch is set to false // whenever setFixedPitch() is called, but ignorePitch is considered an // extended bit, which were apparently not available until 4.4. QTest::newRow("fixedPitch") << font << QDataStream::Qt_4_4; font = basicFont; font.setLetterSpacing(QFont::AbsoluteSpacing, 10); // Fails for 4.4 because letterSpacing wasn't read until 4.5. QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5; font = basicFont; font.setRawMode(true); QTest::newRow("rawMode") << font << QDataStream::Qt_1_0; font = basicFont; font.setKerning(false); QTest::newRow("kerning") << font << QDataStream::Qt_4_0; font = basicFont; font.setStyleStrategy(QFont::NoFontMerging); // This wasn't read properly until 5.4. QTest::newRow("styleStrategy") << font << QDataStream::Qt_5_4; font = basicFont; font.setHintingPreference(QFont::PreferFullHinting); // This wasn't read until 5.4. QTest::newRow("hintingPreference") << font << QDataStream::Qt_5_4; font = basicFont; font.setStyleName("Regular Black Condensed"); // This wasn't read until 5.4. QTest::newRow("styleName") << font << QDataStream::Qt_5_4; }
QFont KResourceMan::readFontEntry( const QString& rKey, const QFont* pDefault ) const { QFont aRetFont; QString aValue = readEntry( rKey ); if( !aValue.isNull() ) { // find first part (font family) int nIndex = aValue.find( ',' ); if( nIndex == -1 ) return aRetFont; aRetFont.setFamily( aValue.left( nIndex ) ); // find second part (point size) int nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ) return aRetFont; aRetFont.setPointSize( aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toInt() ); // find third part (style hint) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ) return aRetFont; aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); // find fourth part (char set) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ) return aRetFont; aRetFont.setCharSet( (QFont::CharSet)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); // find fifth part (weight) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ) return aRetFont; aRetFont.setWeight( aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); // find sixth part (font bits) uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); if( nFontBits & 0x01 ) aRetFont.setItalic( true ); if( nFontBits & 0x02 ) aRetFont.setUnderline( true ); if( nFontBits & 0x04 ) aRetFont.setStrikeOut( true ); if( nFontBits & 0x08 ) aRetFont.setFixedPitch( true ); if( nFontBits & 0x20 ) aRetFont.setRawMode( true ); } else if( pDefault ) aRetFont = *pDefault; return aRetFont; }
QFont KConfigBase::readFontEntry(const char *pKey, const QFont *pDefault) const { QFont aRetFont; QString aValue = readEntry(pKey); if(!aValue.isNull()) { if(aValue.contains(',') > 5) { // KDE3 and upwards entry if(!aRetFont.fromString(aValue) && pDefault) aRetFont = *pDefault; } else { // backward compatibility with older font formats // ### remove KDE 3.1 ? // find first part (font family) int nIndex = aValue.find(','); if(nIndex == -1) { if(pDefault) aRetFont = *pDefault; return aRetFont; } aRetFont.setFamily(aValue.left(nIndex)); // find second part (point size) int nOldIndex = nIndex; nIndex = aValue.find(',', nOldIndex + 1); if(nIndex == -1) { if(pDefault) aRetFont = *pDefault; return aRetFont; } aRetFont.setPointSize(aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toInt()); // find third part (style hint) nOldIndex = nIndex; nIndex = aValue.find(',', nOldIndex + 1); if(nIndex == -1) { if(pDefault) aRetFont = *pDefault; return aRetFont; } aRetFont.setStyleHint((QFont::StyleHint)aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toUInt()); // find fourth part (char set) nOldIndex = nIndex; nIndex = aValue.find(',', nOldIndex + 1); if(nIndex == -1) { if(pDefault) aRetFont = *pDefault; return aRetFont; } QString chStr = aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1); // find fifth part (weight) nOldIndex = nIndex; nIndex = aValue.find(',', nOldIndex + 1); if(nIndex == -1) { if(pDefault) aRetFont = *pDefault; return aRetFont; } aRetFont.setWeight(aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toUInt()); // find sixth part (font bits) uint nFontBits = aValue.right(aValue.length() - nIndex - 1).toUInt(); aRetFont.setItalic(nFontBits & 0x01); aRetFont.setUnderline(nFontBits & 0x02); aRetFont.setStrikeOut(nFontBits & 0x04); aRetFont.setFixedPitch(nFontBits & 0x08); aRetFont.setRawMode(nFontBits & 0x20); } } else { if(pDefault) aRetFont = *pDefault; } return aRetFont; }