Rendering to bitmaps |
UniFEP V3 automatically enables Unicode display in all graphics contexts, including CFbsBitGc
. This is not the case in UniFEP V2, where CFbsBitGc
is not Unicode-capable.
UniFEP
comes with a small library UNIBIT.DLL
implementing the class CUnicodeRenderer
. An object of this class can be used to render Unicode on a bitmap in UniFEP V2. It is not necessary to do this just to render Unicode on a bitmap in UniFEP V3, but the class has not become useless: By proceeding as described below, a protective layer is created that will correctly render Unicode text even if Unicode characters are split over consecutive calls to DrawText
(in principle you could render one byte at a time). This is rarely necessary for newly developed applications, but useful to port legacy applications, or for applications using certain EPOC classes for rendering.
The class CUnicodeRenderer
is defined in the header file ufrender.h
Once you have created an object of type CUnicodeRenderer
, use SetGc(aGc)
to attach a CBitmapContext
to it. Use the methods of CUnicodeRenderer
instead of the CBitmapContext
methods with the same name.
You are free to use the other CBitmapContext
methods for other drawing operations. However, there is one restriction: You cannot use SetOrigin
between setting a clipping rectangle and drawing text. (In other words, if you have an active clipping region when calling DrawText
, you must not have changed the origin between the calls to SetClippingRect
and DrawText
.)
The same CUnicodeRenderer
object can be used for several CBitmapContext
s by calling SetGc
again.
To obtain a CUnicodeRenderer
object, proceed as follows:
RLibrary dll; _LIT(KUniBitDllName, "\\System\\Libs\\UniBit.dll"); User::LeaveIfError(dll.Load(KUniBitDllName)); TLibraryFunction entry = dll.Lookup(1); CUnicodeRenderer *aUniRenderer = (CUnicodeRenderer *) ((*entry)()); dll.Close();
(The DLL can indeed be closed immediately, it is no longer necessary. The CUnicodeRenderer
methods are not actually in that DLL.)
Rendering to bitmaps |