03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

lit them efficiently from a shared heap. The CFont* acts as a handle to an address in this<br />

heap.<br />

Releasing a font releases the client-side CFont* and in the case of an installable font,<br />

decrements a usage count, which will cause the font to be released when the usage count<br />

reaches zero.<br />

Installable fonts are a main reason why GetNearestFont...() calls may fail (because of a<br />

potential out-of-memory error). Also note that it is worth releasing them as soon as possible,<br />

to free up the memory.<br />

Sometimes, you want a device-dependent font. For instance, you may want a font of a<br />

particular pixel size, without going through the trouble of mapping from pixels to twips and<br />

then back to pixels again. For this, you can use GetNearestFontInPixels() on most<br />

graphics devices: this uses a font spec but interprets its iHeight in pixels rather than twips.<br />

Or, you may want one to use a special character from a particular symbol font. For this, you<br />

can use GetFontById(), which requires you to specify a UID rather than a font spec.<br />

A word processor-like application will potentially utilize a large number of fonts, because<br />

there would generally be a number of fonts to select from and each would have a large<br />

range of sizes.<br />

Sometimes the device-independence implied by a TFontSpec isn't device-independent<br />

enough. You can rely on Arial, Times New Roman, and Courier fonts or similar being<br />

present on any Western-locale device but not, for example, in Far Eastern locales. In<br />

response, Symbian applications usually contain font specification information in resource<br />

files, so that this aspect of an application can be localized: there are FONT and NAMED_FONT<br />

resource structures for this.<br />

But don't overgeneralize: text layout conventions are different for Far Eastern applications<br />

too, so you may have to change other things if you want to support Far Eastern locales. You<br />

don't need to make any special font-related changes to support Unicode-based Western-<br />

locale machines.<br />

15.2.3 More on Printing<br />

A comprehensive print model is built into the GDI and implemented by higher-level<br />

components of Symbian OS. Note, however, that printing is usually only relevant to larger,<br />

communicator-type phones. More compact devices usually find it unnecessary, and cut the<br />

support.<br />

To provide system support for particular printers, printer drivers are written as plug-ins that<br />

implement the CPrinterDevice interface, and stored in the /system/printers<br />

directory. On the client-side, the usual approach is to use the provided GUI dialog (if present,<br />

it's usually called CEikPrinterSetupDialog) to allow the user to set up and start printing.<br />

Print set up options can include:<br />

� page setup: supports paper size, margins, rich text for header and footer, and options<br />

for page numbering, header on first page, footer on first page;<br />

� print setup: the number of copies you want to print, and the driver you want to use;<br />

� print preview : a preview showing the layout.<br />

In your document model, you should externalize print settings.<br />

Of course, such options can also be set up directly: CPrintSetup is the key class here.<br />

On-screen print preview support is provided through CPrintPreviewImage. And as we've

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!