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