Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, August 2007
how to get a full family name list of font?


Message 1 in thread

Hi,

When I call QFont::substitutions (), I get a quite limited set of font 
names.
1:    arial
2:    courier new
3:    sans serif
4:    times new roman

However, when I made a call to QFontDialog::getFont(), I saw much more 
(20 some)

Does anyone know how to get a full family name list of font?

Thanks,
Lingfa

--
 [ signature omitted ] 

Message 2 in thread

> When I call QFont::substitutions (), I get a quite limited 
> set of font 
> names.
> 1:    arial
> 2:    courier new
> 3:    sans serif
> 4:    times new roman

Returns a sorted list of substituted family names.
So this is not all fonts, but just the font families.

> However, when I made a call to QFontDialog::getFont(), I saw 
> much more 
> (20 some)
> 
> Does anyone know how to get a full family name list of font?
> 

i'd guess that if you call QFont::substitutes() on each of the families
that you got above, you should get the full list.

Cheers,
Peter

--
 [ signature omitted ] 

Message 3 in thread

>
>
>i'd guess that if you call QFont::substitutes() on each of the families
>that you got above, you should get the full list.
>
>  
>
I did it, but it just return one of each.

Here is what I did:

    msg += "\nQFont::substitutions ()\n";
    QStringList fonts = QFont::substitutions (); // Returns a sorted 
list of substituted family names.
    count = 1;
    foreach(QString item, fonts)
    {
        msg += tr("%1:\t%2 (%3)\n").arg(count).arg(QString(item))
            .arg(QFont::substitutes(item).join(", "))
            ;
        count ++;
    }

Here is the output:

QFont::substitutions ()

1: courier (courier new)

2: helvetica (arial)

3: sans serif (arial)

4: times (times new roman)




--
 [ signature omitted ] 

Message 4 in thread

Aren't you supposed to use the QFontDatabase class to get a list of Font
Families?

http://doc.trolltech.com/4.3/qfontdatabase.html

-----Original Message-----
From: Lingfa Yang [mailto:lingfa@xxxxxxx] 
Sent: Tuesday, August 21, 2007 11:23
To: qt-interest@xxxxxxxxxxxxx
Cc: Qt Interest
Subject: Re: how to get a full family name list of font?


>
>
>i'd guess that if you call QFont::substitutes() on each of the families
>that you got above, you should get the full list.
>
>  
>
I did it, but it just return one of each.

Here is what I did:

    msg += "\nQFont::substitutions ()\n";
    QStringList fonts = QFont::substitutions (); // Returns a sorted 
list of substituted family names.
    count = 1;
    foreach(QString item, fonts)
    {
        msg += tr("%1:\t%2 (%3)\n").arg(count).arg(QString(item))
            .arg(QFont::substitutes(item).join(", "))
            ;
        count ++;
    }

Here is the output:

QFont::substitutions ()

1: courier (courier new)

2: helvetica (arial)

3: sans serif (arial)

4: times (times new roman)




--
 [ signature omitted ] 

Message 5 in thread

Jones, Torrin A (US SSA) wrote:

>Aren't you supposed to use the QFontDatabase class to get a list of Font
>Families?
>
>http://doc.trolltech.com/4.3/qfontdatabase.html
>
>  
>
Quite right! This is exactly what I want.

Thanks a lot.
Lingfa


--
 [ signature omitted ]