fontservices/fontstore/inc/openfontrasterizer.h
changeset 0 1fb32624e06b
child 6 f7b2d24357ad
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     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 class COpenFontFile;
       
    24 
       
    25 /**
       
    26 Supplied to COpenFontRasterizer::ExtendedInterface() to access the extended
       
    27 API interface MOpenFontLinkedTypefaceExtension.
       
    28 
       
    29 @see	COpenFontRasterizer::ExtendedInterface()
       
    30 @see	MOpenFontLinkedTypefaceExtension
       
    31 @publishedPartner
       
    32 @prototype
       
    33 */
       
    34 const TUid KUidLinkedTypefaceRasterizerExtension = {0x10285EAA};
       
    35 
       
    36 /**
       
    37 The Open Font rasterizer plug-in Interface Definition class. 
       
    38 
       
    39 This interface allows the implementation of an Open Font rasterizer plug-in,
       
    40 which can then be dynamically loaded at run time by the ECOM plug-in framework. 
       
    41 The plug-in implementation is instantiated by calling NewL(), passing the implementation 
       
    42 UID so that ECOM can instantiate the correct implementation. 
       
    43 
       
    44 The rasterizer interface declares a single pure virtual functions, which the 
       
    45 plug-in derived from this interface must implement. The function reads font files, and creates 
       
    46 a COpenFontFile object if the font file is of the right type.
       
    47 
       
    48 Writing derived classes:
       
    49 
       
    50 Open font rasterizers should derive from this class and implement the 
       
    51 NewFontFileL() function.
       
    52 
       
    53 Derived classes should also define the factory function. It is a static function 
       
    54 which takes no arguments. It creates a COpenFontRasterizer derived object on the heap, and returns it 
       
    55 to the caller. This factory function, together with the implementation UID will form 
       
    56 the TImplementationProxy used by the ECOM framework to instatiate the plug-in. 
       
    57 
       
    58 The rasterizer class may also need to store an 'engine context'. This is an 
       
    59 object derived from COpenFontRasterizerContext, which provides functions that 
       
    60 make it easier to write the glyph bitmap during rasterization.
       
    61 
       
    62 
       
    63 @publishedPartner
       
    64 @released
       
    65 */
       
    66 class COpenFontRasterizer: public CBase
       
    67 	{
       
    68 public:
       
    69 	/** Creates a COpenFontFile derived object for loading font files in the 
       
    70 	new format. 
       
    71 
       
    72 	This function is called by the framework during font and bitmap server 
       
    73 	startup. It creates a font file object for font files in the \\resource\\fonts 
       
    74 	directory on all drives, using the default search path. The first font of 
       
    75 	a given name overrides subsequent ones. The directory search path is soft 
       
    76 	to hard: Y:, X:, W:, ..., C:, B:, A:, Z:. Files may also be added 
       
    77 	dynamically after startup using CWsScreenDevice::AddFile(), which 
       
    78 	indirectly calls this function.
       
    79 
       
    80 	Implementations of this function should examine the file aFileName, and if 
       
    81 	it is of the correct type attempt to create a COpenFontFile derived object 
       
    82 	to load it. The caller is responsible for deleting the object. The function 
       
    83 	must return NULL if it cannot recognise the file, and it may also leave if 
       
    84 	there is an error. 
       
    85 
       
    86 	@param aUid An ID to be used for the file. UIDs are required by the font 
       
    87 	framework, so the font store allocates them for non Symbian OS-native font 
       
    88 	files. This ID persists until the font is unloaded, e.g. if the device is 
       
    89 	rebooted.
       
    90 	@param	aFileName		The full path and filename of the file from which the COpenFontFile
       
    91 							object is created, if the file is the correct type.
       
    92 	@param	aFileSession	The file session owned by the Font and Bitmap server. This file session 
       
    93 							should be used for any file access. If COpenFontFile objects need to keep 
       
    94 							files open, aFileSession should be stored in a place that is accessible to them. 
       
    95 	@return	A pointer to a new COpenFontFile derived object, or NULL if the file type is not recognised.
       
    96 	@see	CWsScreenDevice::AddFile() */
       
    97 	virtual COpenFontFile* NewFontFileL(TInt aUid,const TDesC& aFileName,RFs& aFileSession) = 0;
       
    98 	inline static COpenFontRasterizer* NewL(TUid aInterfaceImplUid);
       
    99 	inline virtual ~COpenFontRasterizer();
       
   100 	IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
       
   101 private:
       
   102 	TUid iDtor_ID_Key;//ECOM identifier used during destruction
       
   103 	};
       
   104 
       
   105 /** Uses ECOM plug-in framework to instantiate the Open Font rasterizer interface 
       
   106 implementation given its implementation UID. 
       
   107 
       
   108 @param	aInterfaceImplUid	The UID of the interface implementation required
       
   109 
       
   110 @return	COpenFontRasterizer*	A pointer to a COpenFontRasterizer object. */
       
   111 inline COpenFontRasterizer* COpenFontRasterizer::NewL(TUid aInterfaceImplUid)
       
   112 {
       
   113 	return reinterpret_cast <COpenFontRasterizer*> (
       
   114 		REComSession::CreateImplementationL(
       
   115 			aInterfaceImplUid,
       
   116 			_FOFF(COpenFontRasterizer, iDtor_ID_Key))); 
       
   117 }
       
   118 
       
   119 /** Default destructor */
       
   120 inline COpenFontRasterizer::~COpenFontRasterizer()
       
   121 {
       
   122 	REComSession::DestroyedImplementation(iDtor_ID_Key);
       
   123 }
       
   124 
       
   125 #endif /*OPENFONTRASTERIZER_H*/