os/textandloc/fontservices/fontstore/inc/openfontrasterizer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * The Open Font rasterizer plug-in Interface Definition class.
    16 *
    17 */
    18 
    19 
    20 #ifndef OPENFONTRASTERIZER_H
    21 #define OPENFONTRASTERIZER_H
    22 
    23 #include <ecom/ecom.h>
    24 
    25 class COpenFontFile;
    26 
    27 /**
    28 Supplied to COpenFontRasterizer::ExtendedInterface() to access the extended
    29 API interface MOpenFontLinkedTypefaceExtension.
    30 
    31 @see	COpenFontRasterizer::ExtendedInterface()
    32 @see	MOpenFontLinkedTypefaceExtension
    33 @publishedPartner
    34 @prototype
    35 */
    36 const TUid KUidLinkedTypefaceRasterizerExtension = {0x10285EAA};
    37 
    38 /**
    39 The Open Font rasterizer plug-in Interface Definition class. 
    40 
    41 This interface allows the implementation of an Open Font rasterizer plug-in,
    42 which can then be dynamically loaded at run time by the ECOM plug-in framework. 
    43 The plug-in implementation is instantiated by calling NewL(), passing the implementation 
    44 UID so that ECOM can instantiate the correct implementation. 
    45 
    46 The rasterizer interface declares a single pure virtual functions, which the 
    47 plug-in derived from this interface must implement. The function reads font files, and creates 
    48 a COpenFontFile object if the font file is of the right type.
    49 
    50 Writing derived classes:
    51 
    52 Open font rasterizers should derive from this class and implement the 
    53 NewFontFileL() function.
    54 
    55 Derived classes should also define the factory function. It is a static function 
    56 which takes no arguments. It creates a COpenFontRasterizer derived object on the heap, and returns it 
    57 to the caller. This factory function, together with the implementation UID will form 
    58 the TImplementationProxy used by the ECOM framework to instatiate the plug-in. 
    59 
    60 The rasterizer class may also need to store an 'engine context'. This is an 
    61 object derived from COpenFontRasterizerContext, which provides functions that 
    62 make it easier to write the glyph bitmap during rasterization.
    63 
    64 
    65 @publishedPartner
    66 @released
    67 */
    68 class COpenFontRasterizer: public CBase
    69 	{
    70 public:
    71 	/** Creates a COpenFontFile derived object for loading font files in the 
    72 	new format. 
    73 
    74 	This function is called by the framework during font and bitmap server 
    75 	startup. It creates a font file object for font files in the \\resource\\fonts 
    76 	directory on all drives, using the default search path. The first font of 
    77 	a given name overrides subsequent ones. The directory search path is soft 
    78 	to hard: Y:, X:, W:, ..., C:, B:, A:, Z:. Files may also be added 
    79 	dynamically after startup using CWsScreenDevice::AddFile(), which 
    80 	indirectly calls this function.
    81 
    82 	Implementations of this function should examine the file aFileName, and if 
    83 	it is of the correct type attempt to create a COpenFontFile derived object 
    84 	to load it. The caller is responsible for deleting the object. The function 
    85 	must return NULL if it cannot recognise the file, and it may also leave if 
    86 	there is an error. 
    87 
    88 	@param aUid An ID to be used for the file. UIDs are required by the font 
    89 	framework, so the font store allocates them for non Symbian OS-native font 
    90 	files. This ID persists until the font is unloaded, e.g. if the device is 
    91 	rebooted.
    92 	@param	aFileName		The full path and filename of the file from which the COpenFontFile
    93 							object is created, if the file is the correct type.
    94 	@param	aFileSession	The file session owned by the Font and Bitmap server. This file session 
    95 							should be used for any file access. If COpenFontFile objects need to keep 
    96 							files open, aFileSession should be stored in a place that is accessible to them. 
    97 	@return	A pointer to a new COpenFontFile derived object, or NULL if the file type is not recognised.
    98 	@see	CWsScreenDevice::AddFile() */
    99 	virtual COpenFontFile* NewFontFileL(TInt aUid,const TDesC& aFileName,RFs& aFileSession) = 0;
   100 	inline static COpenFontRasterizer* NewL(TUid aInterfaceImplUid);
   101 	inline virtual ~COpenFontRasterizer();
   102 	IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
   103 private:
   104 	TUid iDtor_ID_Key;//ECOM identifier used during destruction
   105 	};
   106 
   107 /** Uses ECOM plug-in framework to instantiate the Open Font rasterizer interface 
   108 implementation given its implementation UID. 
   109 
   110 @param	aInterfaceImplUid	The UID of the interface implementation required
   111 
   112 @return	COpenFontRasterizer*	A pointer to a COpenFontRasterizer object. */
   113 inline COpenFontRasterizer* COpenFontRasterizer::NewL(TUid aInterfaceImplUid)
   114 {
   115 	return reinterpret_cast <COpenFontRasterizer*> (
   116 		REComSession::CreateImplementationL(
   117 			aInterfaceImplUid,
   118 			_FOFF(COpenFontRasterizer, iDtor_ID_Key))); 
   119 }
   120 
   121 /** Default destructor */
   122 inline COpenFontRasterizer::~COpenFontRasterizer()
   123 {
   124 	REComSession::DestroyedImplementation(iDtor_ID_Key);
   125 }
   126 
   127 #endif /*OPENFONTRASTERIZER_H*/