Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

Fonts in Qt/Embedded

Supported Formats

Qt/Embedded supports four font formats:

TrueType (TTF) The scalable font technology now standard on MS-Windows and Apple Macintosh, and becoming popular on X11.
Postscript Type1 (PFA/PFB) Scalable fonts often used by printers, also popular on X11. These are similar in functionality to TTF fonts and are not discussed further in this document.
Bitmap Distribution Format
fonts (BDF)
A standard format for non-scalable fonts. A large number of BDF fonts are supplied as part of standard X11 distributions - most of these can be used with Qt/Embedded. You should not use these in a production system: they are very slow to load and take up a lot of storage space. Instead, render the BDF to a QPF.
Qt Prerendered Font (QPF) A light-weight non-scalable font format specific to Qt/Embedded.

Support for each of these font formats (except QPF which is always enabled) can be enabled or disabled independently by using the Qt/Embedded Features Definition. There is support in Qt/Embedded for writing a QPF font file from any font, so you can initially enable TTF and BDF formats, save QPF files for the fonts and sizes you need, then remove TTF and BDF support.

See tools/makeqpf for a tool that helps produce QPF files from the TTF and BDF, or just run your application with the -savefonts option.

Memory Requirements

With TTF fonts, each character in the font at a given point size is only rendered when first used in a drawing or metrics operation. With BDF fonts all characters are rendered when the font is used. With QPF fonts, the characters are stored in the same format that Qt uses for drawing.

For example, a 10-point Times font containing the ASCII characters uses around 1300 bytes when stored in QPF format.

Taking advantage of the way the QPF format is structured, Qt/Embedded memory-maps the data rather than reading and parsing it. This reduces RAM consumption even further.

Scalable fonts use a larger amount of memory per font, but these fonts provide a memory saving if many different sizes of each font are needed.

Smooth Fonts

TTF, PFA, and QPF fonts can be rendered as smooth anti-aliased fonts to give superior readability, especially on low-resolution devices. The difference between smooth and non-smooth fonts is illustrated below (you may need to change your display to low resolution to see the difference):

unsmooth

smooth

In Qt/Embedded 2.2.1, smooth fonts use eight times as much memory as non-smooth fonts. This multiplier will be reduced to a configurable 2 or 4 (i.e. 4-level and 16-level shading rather than the default 256-level shading).

Unicode

All fonts used by Qt/Embedded use the Unicode character encoding. Most fonts available today use this encoding, but they usually don't contain all the Unicode characters. A complete 16-point Unicode font uses over 1 MB of memory.

The font definition file

When Qt/Embedded applications run, they look for a file called $QTDIR/lib/fonts/fontdir or /usr/local/qt-embedded/lib/fonts/fontdir. This file defines the fonts available to the application. It has the following format:

name file renderer italic weight size flags
where

Field Value
name Helvetica, Times, etc.
file helvR0810.bdf, verdana.ttf, etc.
renderer BDF or FT
italic y or n
weight 50 is normal, 75 is bold, etc.
size 0 for scalable or point size * 10 (i.e. 120 for 12pt)
flags
  • s: smooth (anti-aliased)
  • u: Unicode range when saving (default is Latin-1)
  • a: ASCII range when saving (default is Latin-1)

The font definition file does not specify QPF fonts; these are loaded directly from the directory containing the fontdir file, and must be named name_size_weightitalicflag.qpf, where

Field Value
name helvetica, times, etc. (in lowercase)
size point size * 10 (i.e. 120 for 12pt)
italicflag i for italic, otherwise nothing.
weight 50 is normal, 75 is bold, etc.

If an application is run with the -savefonts command-line option, then whenever a font other than a QPF font is used, a corresponding QPF file is saved. This allows you to easily find the font usage of your applications and to generate QPF files so that you can eventually reduce the memory usage of your applications by disabling TTF and BDF support from Qt/Embedded, or by modifying the initialization of qws_savefonts in kernel/qapplication_qws.cpp of the Qt/Embedded library source code. In extreme cases of memory-saving, it is possible to save partially-rendered fonts (i.e. only the characters in "Product NameTM") if you are certain that these are the only characters you will need from the font. See QMemoryManager::savePrerenderedFont() for this functionality.

Notes

The font definition file, naming conventions for font files, and the format of QPF files may change in versions of Qt/Embedded after 3.

When enabled, Qt/Embedded uses the powerful FreeType2 library to implement TrueType and Type1 support.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenVG

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web