os/textandloc/fontservices/textshaperplugin/include/SymbianFontInstance.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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 * SymbianFontInstance.CPP
    16 * Symbian implementation of LEFontInstance
    17 *
    18 */
    19 
    20 
    21 #ifndef SYMBIANFontInstance_H_
    22 #define SYMBIANFontInstance_H_
    23 
    24 #include <stdio.h>
    25 
    26 #include "layout/LETypes.h"
    27 #include "layout/LEFontInstance.h"
    28 
    29 #include "FontTableCache.h"
    30 
    31 #include "sfnt.h"
    32 #include "cmaps.h"
    33 
    34 // Symbian includes
    35 #include <gdi.h>
    36 
    37 class MOpenFontExtensionInterface;
    38 
    39 class SymbianFontInstance : public LEFontInstance, protected FontTableCache
    40 	{
    41 public:
    42 	SymbianFontInstance(CBitmapFont* aBitmapFont, LEErrorCode &status, le_bool aKeepGlyphOfZWJ = false);
    43 	virtual ~SymbianFontInstance();
    44 	void SetSessionHandle(TInt aHandle) 
    45 		{
    46 		iSessionHandle = aHandle;
    47 		}
    48 
    49 	const void *getFontTable(LETag tableTag) const;
    50 
    51 	le_int32 getUnitsPerEM() const
    52 		{
    53 		return fUnitsPerEM;
    54 		}
    55 
    56 	le_int32 getAscent() const
    57 		{
    58 		return fAscent;
    59 		}
    60 
    61 	le_int32 getDescent() const
    62 		{
    63 		return fDescent;
    64 		}
    65 
    66 	le_int32 getLeading() const
    67 		{
    68 		return fLeading;
    69 		}
    70 
    71 	LEGlyphID mapCharToGlyph(LEUnicode32 ch) const
    72 		{
    73 		// 1922 mlyl -->
    74 		if (ch == 0x200D && !iKeepGlyphOfZWJ)
    75 			return 1;
    76 		else
    77 		// <-- 1922 mlyl
    78 			return fCMAPMapper->unicodeToGlyph(ch);
    79 		}
    80 
    81 	void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
    82 
    83 	le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
    84 
    85 	void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
    86 	float xUnitsToPoints(float xUnits) const;
    87 	float yUnitsToPoints(float yUnits) const;
    88 	float getXPixelsPerEm() const;
    89 	float getYPixelsPerEm() const;
    90 	float getScaleFactorX() const;
    91 	float getScaleFactorY() const;
    92 
    93 protected:
    94 	const void *readFontTable(LETag tableTag) const;
    95 
    96 private:
    97 	FILE *fFile;	
    98 
    99 	le_int32 fUnitsPerEM;
   100 	le_int32 fAscent;
   101 	le_int32 fDescent;
   102 	le_int32 fLeading;
   103 
   104 	const SFNTDirectory *fDirectory;
   105 	le_uint16 fDirPower;
   106 	le_uint16 fDirExtra;
   107 
   108 	float fXPixelsPerEm;
   109 	float fYPixelsPerEm;
   110 
   111 	float fDeviceScaleX;
   112 	float fDeviceScaleY;
   113 
   114 	CMAPMapper *fCMAPMapper;
   115 
   116 	const HMTXTable *fHMTXTable;
   117 	le_uint16 fNumGlyphs;
   118 	le_uint16 fNumLongHorMetrics;
   119 
   120 	CBitmapFont* iFont;
   121 	MOpenFontShapingExtension* iExtensionInterface;
   122 	MOpenFontTrueTypeExtension* iTrueTypeExtensionInterface;
   123 	TInt iSessionHandle;
   124 	
   125 	// --> 1922 mlyl: The script which this shaper will shape
   126 	le_bool iKeepGlyphOfZWJ;
   127 	// <-- 1922 mlyl
   128 
   129 	static le_int8 highBit(le_int32 value);
   130 
   131 	const DirectoryEntry *findTable(LETag tag) const;
   132 	const void *readTable(LETag tag, le_uint32 *length) const;
   133 	void deleteTable(const void *table) const;
   134 	void getMetrics();
   135 
   136 	CMAPMapper *findUnicodeMapper();
   137 	};
   138 
   139 #endif