--- a/graphicsdeviceinterface/gdi/sgdi/FONT.CPP Tue Feb 02 01:47:50 2010 +0200
+++ b/graphicsdeviceinterface/gdi/sgdi/FONT.CPP Fri Apr 16 16:21:04 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
@@ -24,6 +24,7 @@
#include "gdiinline.inl"
#include "gdistructs.h"
#include "gdiconsts.h"
+#include "gdiplatapi.h"
/**
Names holds the types & data associated with the glyph selection
@@ -345,10 +346,13 @@
The object's font style is set to the default: EPostureUpright, EStrokeWeightNormal,
and EPrintPosNormal.
-@param aTypefaceName The name of the typeface (e.g. "Roman").
-@param aHeight The height of the typeface, in twips. */
+@param aTypefaceName The name of the typeface (e.g. "Roman"). It should be no
+ longer than KMaxTypefaceNameLength characters in length.
+@param aHeight The height of the typeface, in twips.
+@panic GDI 6, if aTypefaceName is more than KMaxTypefaceNameLength characters long.
+*/
{
- iTypeface.iName=aTypefaceName;
+ iTypeface.SetName(aTypefaceName);
}
@@ -605,6 +609,29 @@
return (KTTypefaceMaskScript & iFlags) >> KTTypefaceBitsNumAttrib;
}
+/**
+Sets the name of the typeface. This method should be used rather than
+directly accessing the iName public member.
+@param aName The name of the typeface (e.g. "Roman"). It should be no
+ longer than KMaxTypefaceNameLength characters in length.
+@panic GDI 6, if aName is more than KMaxTypefaceNameLength characters
+ long.
+*/
+EXPORT_C void TTypeface::SetName(const TDesC& aName)
+ {
+ GDI_ASSERT_ALWAYS(aName.Length() <= KMaxTypefaceNameLength, EGdiPanic_TypefaceNameOverflow);
+ iName=aName;
+ }
+
+/**
+Returns the name of the typeface.
+@return The name of the typeface.
+*/
+EXPORT_C const TDesC& TTypeface::Name() const
+ {
+ return iName;
+ }
+
//
// CFont
@@ -1589,3 +1616,195 @@
// being the first three elements in TScript.
return TPtrC(KTScript2GlyphSample[aScript - 3]);
}
+
+
+EXPORT_C RFontTable::RFontTable():iTableContent(0), iLength(0),
+ iFont(NULL), iTag(0)
+ {
+ // a null constructor.
+ }
+
+EXPORT_C TInt
+RFontTable::Open(CFont& aFont, TUint32 aTag)
+ {
+ TGetFontTableParam param;
+ param.iTag = aTag;
+
+ // remember the parameters, to be used when releasing the font table.
+ iFont = &aFont;
+ iTag = aTag;
+
+ TInt ret = aFont.ExtendedFunction(KFontGetFontTable, (TAny *)¶m);
+ if (KErrNone == ret)
+ {
+ iTableContent = (TAny *)param.iContent;
+ iLength = param.iLength;
+ }
+ return ret;
+ }
+
+EXPORT_C TInt
+RFontTable::TableLength() const
+ {
+ return iLength;
+ }
+
+EXPORT_C const TUint8*
+RFontTable::TableContent() const
+ {
+ return (TUint8*)iTableContent;
+ }
+
+EXPORT_C void
+RFontTable::Close()
+ {
+ if (NULL != iFont)
+ {
+ (void)iFont->ExtendedFunction(KFontReleaseFontTable, (TAny *)&iTag);
+ }
+ iTableContent = 0;
+ iLength = 0;
+ iFont = NULL;
+ iTag = 0;
+ }
+
+EXPORT_C
+RGlyphOutlineIterator::RGlyphOutlineIterator():iOutlines(0), iLengths(0),
+ iCursor(-1), iCount(0), iFont(NULL), iCodes(NULL), iHinted(EFalse)
+ {
+ // a null constructor.
+ }
+
+EXPORT_C TInt
+RGlyphOutlineIterator::Open(CFont& aFont, TUint* aCodes, TInt aCount, TBool aHinted)
+ {
+ if (NULL == aCodes || 0 == aCount)
+ {
+ return KErrArgument;
+ }
+ TGetGlyphOutlineParam param;
+ iLengths = (TInt *)User::Alloc(sizeof(TInt) * aCount);
+ if (NULL == iLengths)
+ {
+ return KErrNoMemory;
+ }
+ iOutlines = (TAny **)User::Alloc(sizeof(TAny *) * aCount);
+ if (NULL == iOutlines)
+ {
+ User::Free(iLengths);
+ iLengths = NULL;
+ return KErrNoMemory;
+ }
+
+ param.iLengths = iLengths;
+ param.iCount = aCount;
+ param.iCodes = aCodes;
+ param.iHinted = aHinted;
+ param.iOutlines = iOutlines;
+
+ /* information needed in Close() */
+ iCodes = (TUint *)User::Alloc(sizeof(TUint) * aCount);
+ if (NULL == iCodes)
+ {
+ User::Free(iLengths);
+ User::Free(iOutlines);
+ iLengths = NULL;
+ iOutlines = NULL;
+ return KErrNoMemory;
+ }
+ Mem::Copy(iCodes, aCodes, aCount*sizeof(TUint));
+ iFont = &aFont;
+ iHinted = aHinted;
+ iCount = aCount;
+
+ TInt ret = aFont.ExtendedFunction(KFontGetGlyphOutline, (TAny *)¶m);
+ if (KErrNone != ret)
+ {
+ User::Free(iLengths);
+ User::Free(iOutlines);
+ User::Free(iCodes);
+ iLengths = NULL;
+ iOutlines = NULL;
+ iCodes = NULL;
+ iFont = NULL;
+ }
+ else
+ {
+ iCursor = 0;
+ }
+
+ return ret;
+ }
+
+EXPORT_C const TUint8*
+RGlyphOutlineIterator::Outline() const
+ {
+ GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown);
+
+ if (iLengths[iCursor] < 0)
+ {
+ return NULL;
+ }
+ else
+ {
+ return (const TUint8*)iOutlines[iCursor];
+ }
+ }
+
+EXPORT_C TInt
+RGlyphOutlineIterator::OutlineLength() const
+ {
+ GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown);
+
+ if (iLengths[iCursor] < 0)
+ {
+ return KErrGeneral;
+ }
+ else
+ {
+ return iLengths[iCursor];
+ }
+ }
+
+EXPORT_C TInt
+RGlyphOutlineIterator::Next()
+ {
+ if (iCursor >= 0 && iCursor < iCount-1)
+ {
+ ++iCursor;
+ return KErrNone;
+ }
+ else
+ {
+ iCursor = -1;
+ // if the iterator goes beyond the last element [when
+ // Next() returns KErrNotFound], the next call
+ // to Outline() or OutlineLength() will panic.
+
+ return KErrNotFound;
+ }
+ }
+
+EXPORT_C void
+RGlyphOutlineIterator::Close()
+ {
+ TReleaseGlyphOutlineParam param;
+ param.iCount = iCount;
+ param.iHinted = iHinted;
+ param.iCodes = iCodes;
+
+ if (NULL != iFont)
+ {
+ iFont->ExtendedFunction(KFontReleaseGlyphOutline, (TAny *)¶m);
+ }
+
+ iFont = NULL;
+ iCount = 0;
+ User::Free(iLengths);
+ iLengths = NULL;
+ iCursor = -1;
+ User::Free(iCodes);
+ iCodes = NULL;
+ User::Free(iOutlines);
+ iOutlines = NULL;
+ }