fbs/fontandbitmapserver/sfbs/FBSFONT.CPP
branchRCL_3
changeset 164 25ffed67c7ef
parent 163 bbf46f59e123
equal deleted inserted replaced
163:bbf46f59e123 164:25ffed67c7ef
    17 #include <fbs.h>
    17 #include <fbs.h>
    18 #include <openfont.h>
    18 #include <openfont.h>
    19 #include <graphics/shapeimpl.h>
    19 #include <graphics/shapeimpl.h>
    20 #include "UTILS.H"
    20 #include "UTILS.H"
    21 #include <graphics/shaperparams.h>
    21 #include <graphics/shaperparams.h>
    22 #include "FbsMessage.H"
    22 #include "fbsmessage.h"
    23 #include <graphics/gdi/gdiconsts.h>
    23 #include <graphics/gdi/gdiconsts.h>
    24 #include <graphics/gdi/gdistructs.h>
    24 #include <graphics/gdi/gdistructs.h>
    25 
    25 
    26 GLREF_C void Panic(TFbsPanic aPanic);
    26 GLREF_C void Panic(TFbsPanic aPanic);
    27 
    27 
    83 	}
    83 	}
    84 	
    84 	
    85 EXPORT_C void CFbsFont::Reset()
    85 EXPORT_C void CFbsFont::Reset()
    86 	{
    86 	{
    87 	if (iHandle)
    87 	if (iHandle)
    88 	    {
       
    89 		iFbs->SendCommand(EFbsMessClose,iHandle);
    88 		iFbs->SendCommand(EFbsMessClose,iHandle);
    90 	    }
       
    91 	iHandle = 0;
    89 	iHandle = 0;
    92 	}
    90 	}
    93 	
    91 	
    94 EXPORT_C CBitmapFont* CFbsFont::Address() const
    92 EXPORT_C CBitmapFont* CFbsFont::Address() const
    95 	{
    93 	{
   115 	if (!iFbs)
   113 	if (!iFbs)
   116 		return KErrCouldNotConnect;
   114 		return KErrCouldNotConnect;
   117 	if (!aFontHandle)
   115 	if (!aFontHandle)
   118 		return KErrUnknown;
   116 		return KErrUnknown;
   119 	// close any existing handle
   117 	// close any existing handle
   120 	Reset();	
   118 	Reset();
   121 	// ask server to create the duplicate handle
   119 	// ask server to create the duplicate handle
   122 	TPckgBuf<TFontInfo> tfpckg;
   120 	TPckgBuf<TFontInfo> tfpckg;
   123 	TIpcArgs args(aFontHandle,&tfpckg);
   121 	TIpcArgs args(aFontHandle,&tfpckg);
   124 	TInt ret = iFbs->SendCommand(EFbsMessFontDuplicate,args);
   122 	TInt ret = iFbs->SendCommand(EFbsMessFontDuplicate,args);
   125 	if (ret != KErrNone || !tfpckg().iHandle)
   123 	if (ret != KErrNone || !tfpckg().iHandle)
   137 @released
   135 @released
   138 */
   136 */
   139 EXPORT_C TInt CFbsFont::Handle() const
   137 EXPORT_C TInt CFbsFont::Handle() const
   140 	{
   138 	{
   141 	if (!iHandle)
   139 	if (!iHandle)
   142 		{
       
   143 		return 0;
   140 		return 0;
   144 		}
       
   145 	return iServerHandle;
   141 	return iServerHandle;
   146 	}
   142 	}
   147 
   143 
   148 /** Gets how much of the specified descriptor can be displayed in this font without 
   144 /** Gets how much of the specified descriptor can be displayed in this font without 
   149 exceeding the specified width.
   145 exceeding the specified width.
   638 	iFbs->SendCommand(EFbsMessShapeDelete,iHandle,PointerToOffset(aParam->iShapeHeader, iFbs->HeapBase()));
   634 	iFbs->SendCommand(EFbsMessShapeDelete,iHandle,PointerToOffset(aParam->iShapeHeader, iFbs->HeapBase()));
   639 	return KErrNone;
   635 	return KErrNone;
   640 	}
   636 	}
   641 
   637 
   642 
   638 
   643 TInt CFbsFont::DoGetFontTable(TGetFontTableParam* aParam) const
       
   644     {
       
   645     TInt ret = KErrGeneral;
       
   646 
       
   647     TPckgBuf<TOffsetLen> retBuf;
       
   648     ret = iFbs->SendCommand(EFbsMessGetFontTable, 
       
   649             TIpcArgs(iHandle, aParam->iTag, &retBuf));
       
   650     
       
   651     if (KErrNone == ret)
       
   652         {
       
   653         aParam->iLength = retBuf().iLen;
       
   654         aParam->iContent = OffsetToPointer(retBuf().iOffset, iFbs->HeapBase());
       
   655         }
       
   656     return ret;
       
   657     }
       
   658 
       
   659 
       
   660 TInt CFbsFont::DoGetGlyphOutline(TGetGlyphOutlineParam* aParam) const
       
   661     {
       
   662     TInt ret = KErrGeneral;
       
   663     
       
   664     TPckgBuf<TFBSGlyphOutlineParam> paramsBuf;
       
   665     TInt count = aParam->iCount;
       
   666     paramsBuf().iCount = aParam->iCount;
       
   667     paramsBuf().iHinted = aParam->iHinted;
       
   668     paramsBuf().iHandle = iHandle;
       
   669 
       
   670     TOffsetLen* offsetLen = (TOffsetLen *)User::Alloc(count * sizeof(TOffsetLen));
       
   671     if (NULL == offsetLen)
       
   672         {
       
   673         return KErrNoMemory;
       
   674         }
       
   675     TPtr8 retBuf((TUint8 *)offsetLen, count * sizeof(TOffsetLen),
       
   676             count * sizeof(TOffsetLen));
       
   677     TPtr8 codes((TUint8 *)(aParam->iCodes), count * sizeof(TUint), 
       
   678             count * sizeof(TUint));
       
   679     
       
   680     ret = iFbs->SendCommand( EFbsMessGetGlyphOutline, 
       
   681             TIpcArgs(&paramsBuf, &codes, &retBuf));
       
   682     
       
   683     if (KErrNone == ret)
       
   684         {
       
   685         // server writes the offsets back to client, convert them
       
   686         // to local pointers.
       
   687         for (TInt i = 0; i < aParam->iCount; ++i)
       
   688             {
       
   689             aParam->iOutlines[i] = OffsetToPointer(offsetLen[i].iOffset, 
       
   690                     iFbs->HeapBase());
       
   691             aParam->iLengths[i] = offsetLen[i].iLen;
       
   692             }
       
   693         }
       
   694     User::Free(offsetLen);
       
   695     return ret;
       
   696     }
       
   697 
       
   698 TInt CFbsFont::DoReleaseGlyphOutline(TReleaseGlyphOutlineParam* aParam) const 
       
   699     {
       
   700     TInt ret = KErrGeneral;
       
   701     
       
   702     TPckgBuf<TFBSGlyphOutlineParam> params;
       
   703     TInt count = aParam->iCount;
       
   704     params().iCount = count;
       
   705     params().iHinted = aParam->iHinted;
       
   706     params().iHandle = iHandle;
       
   707 
       
   708     TPtr8 codes((unsigned char *)aParam->iCodes, count * sizeof(TUint), count * sizeof(TUint));
       
   709     
       
   710     ret = iFbs->SendCommand(EFbsMessReleaseGlyphOutline, 
       
   711             TIpcArgs(&params, &codes));
       
   712         
       
   713     return ret;
       
   714     }   
       
   715 
       
   716 TInt CFbsFont::DoReleaseFontTable(TUint32* aParam) const 
       
   717     {
       
   718     TInt ret = KErrGeneral;
       
   719     
       
   720     ret = iFbs->SendCommand(EFbsMessReleaseFontTable, 
       
   721             TIpcArgs(iHandle, *aParam));
       
   722         
       
   723     return ret;
       
   724     }   
       
   725 /** API extension system that enables the caller to access a particular API
   639 /** API extension system that enables the caller to access a particular API
   726 extension function. As an overload of this function in a derived class
   640 extension function. As an overload of this function in a derived class
   727 it calls its immediate parent implementation for any extension function Uid
   641 it calls its immediate parent implementation for any extension function Uid
   728 that it does not recognize and handle.
   642 that it does not recognize and handle.
   729 @param aInterfaceId UID of the required extension function
   643 @param aInterfaceId UID of the required extension function
   730 @param aParam Pointer to an arbitrary parameter block that can be used to
   644 @param aParam Pointer to an arbitrary parameter block that can be used to
   731 provide and/or return information to/from the particular extension function,
   645 provide and/or return information to/from the particular extension function,
   732 defaults to NULL.
   646 defaults to NULL.
   733 @return Integer return value from extension function, a system wide error code.
   647 @return Integer return value from extension function, a system wide error code.
   734 @panic FBSCLI 31, in debug builds only, if iExtra is NULL when it must not be.
       
   735 @panic FBSCLI 38, in debug builds only, if a reserved error code is returned 
       
   736 	from an extended function.
       
   737 @internalTechnology
   648 @internalTechnology
   738 @released
   649 @released
   739 */
   650 */
   740 EXPORT_C TInt CFbsFont::DoExtendedFunction(TUid aFunctionId, TAny* aParam) const
   651 EXPORT_C TInt CFbsFont::DoExtendedFunction(TUid aFunctionId, TAny* aParam) const
   741 	{
   652 	{
   761 		else if (aFunctionId == KTextInContextWidthInPixelsUid)
   672 		else if (aFunctionId == KTextInContextWidthInPixelsUid)
   762 			{
   673 			{
   763 			TTextWidthInternal* contextParam = (TTextWidthInternal*)aParam;
   674 			TTextWidthInternal* contextParam = (TTextWidthInternal*)aParam;
   764 			return DoTextWidthInPixels(contextParam->iText,&contextParam->iParam);
   675 			return DoTextWidthInPixels(contextParam->iText,&contextParam->iParam);
   765 			}
   676 			}
   766 		else if (aFunctionId == KFontGetFontTable) 
       
   767 		    {
       
   768             return DoGetFontTable(reinterpret_cast<TGetFontTableParam *>(aParam));
       
   769 		    }
       
   770 		else if (aFunctionId == KFontGetGlyphOutline)
       
   771 		    {
       
   772 		    return DoGetGlyphOutline(reinterpret_cast<TGetGlyphOutlineParam *>(aParam));
       
   773 		    }
       
   774 		else if (aFunctionId == KFontReleaseGlyphOutline)
       
   775 		    {
       
   776 		    return DoReleaseGlyphOutline(reinterpret_cast<TReleaseGlyphOutlineParam *>(aParam));
       
   777 		    }
       
   778 		else if (aFunctionId == KFontReleaseFontTable)
       
   779             {
       
   780             return DoReleaseFontTable(reinterpret_cast<TUint32 *>(aParam));
       
   781             }
       
   782 		}
   677 		}
   783 	return CFont::DoExtendedFunction(aFunctionId, aParam);
   678 	return CFont::DoExtendedFunction(aFunctionId, aParam);
   784 	}
   679 	}
   785 
   680