fbs/fontandbitmapserver/sfbs/FBSFONT.CPP
branchRCL_3
changeset 163 bbf46f59e123
parent 26 15986eb6c500
child 164 25ffed67c7ef
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
    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 	    {
    88 		iFbs->SendCommand(EFbsMessClose,iHandle);
    89 		iFbs->SendCommand(EFbsMessClose,iHandle);
       
    90 	    }
    89 	iHandle = 0;
    91 	iHandle = 0;
    90 	}
    92 	}
    91 	
    93 	
    92 EXPORT_C CBitmapFont* CFbsFont::Address() const
    94 EXPORT_C CBitmapFont* CFbsFont::Address() const
    93 	{
    95 	{
   113 	if (!iFbs)
   115 	if (!iFbs)
   114 		return KErrCouldNotConnect;
   116 		return KErrCouldNotConnect;
   115 	if (!aFontHandle)
   117 	if (!aFontHandle)
   116 		return KErrUnknown;
   118 		return KErrUnknown;
   117 	// close any existing handle
   119 	// close any existing handle
   118 	Reset();
   120 	Reset();	
   119 	// ask server to create the duplicate handle
   121 	// ask server to create the duplicate handle
   120 	TPckgBuf<TFontInfo> tfpckg;
   122 	TPckgBuf<TFontInfo> tfpckg;
   121 	TIpcArgs args(aFontHandle,&tfpckg);
   123 	TIpcArgs args(aFontHandle,&tfpckg);
   122 	TInt ret = iFbs->SendCommand(EFbsMessFontDuplicate,args);
   124 	TInt ret = iFbs->SendCommand(EFbsMessFontDuplicate,args);
   123 	if (ret != KErrNone || !tfpckg().iHandle)
   125 	if (ret != KErrNone || !tfpckg().iHandle)
   135 @released
   137 @released
   136 */
   138 */
   137 EXPORT_C TInt CFbsFont::Handle() const
   139 EXPORT_C TInt CFbsFont::Handle() const
   138 	{
   140 	{
   139 	if (!iHandle)
   141 	if (!iHandle)
       
   142 		{
   140 		return 0;
   143 		return 0;
       
   144 		}
   141 	return iServerHandle;
   145 	return iServerHandle;
   142 	}
   146 	}
   143 
   147 
   144 /** Gets how much of the specified descriptor can be displayed in this font without 
   148 /** Gets how much of the specified descriptor can be displayed in this font without 
   145 exceeding the specified width.
   149 exceeding the specified width.
   634 	iFbs->SendCommand(EFbsMessShapeDelete,iHandle,PointerToOffset(aParam->iShapeHeader, iFbs->HeapBase()));
   638 	iFbs->SendCommand(EFbsMessShapeDelete,iHandle,PointerToOffset(aParam->iShapeHeader, iFbs->HeapBase()));
   635 	return KErrNone;
   639 	return KErrNone;
   636 	}
   640 	}
   637 
   641 
   638 
   642 
       
   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     }   
   639 /** API extension system that enables the caller to access a particular API
   725 /** API extension system that enables the caller to access a particular API
   640 extension function. As an overload of this function in a derived class
   726 extension function. As an overload of this function in a derived class
   641 it calls its immediate parent implementation for any extension function Uid
   727 it calls its immediate parent implementation for any extension function Uid
   642 that it does not recognize and handle.
   728 that it does not recognize and handle.
   643 @param aInterfaceId UID of the required extension function
   729 @param aInterfaceId UID of the required extension function
   644 @param aParam Pointer to an arbitrary parameter block that can be used to
   730 @param aParam Pointer to an arbitrary parameter block that can be used to
   645 provide and/or return information to/from the particular extension function,
   731 provide and/or return information to/from the particular extension function,
   646 defaults to NULL.
   732 defaults to NULL.
   647 @return Integer return value from extension function, a system wide error code.
   733 @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.
   648 @internalTechnology
   737 @internalTechnology
   649 @released
   738 @released
   650 */
   739 */
   651 EXPORT_C TInt CFbsFont::DoExtendedFunction(TUid aFunctionId, TAny* aParam) const
   740 EXPORT_C TInt CFbsFont::DoExtendedFunction(TUid aFunctionId, TAny* aParam) const
   652 	{
   741 	{
   672 		else if (aFunctionId == KTextInContextWidthInPixelsUid)
   761 		else if (aFunctionId == KTextInContextWidthInPixelsUid)
   673 			{
   762 			{
   674 			TTextWidthInternal* contextParam = (TTextWidthInternal*)aParam;
   763 			TTextWidthInternal* contextParam = (TTextWidthInternal*)aParam;
   675 			return DoTextWidthInPixels(contextParam->iText,&contextParam->iParam);
   764 			return DoTextWidthInPixels(contextParam->iText,&contextParam->iParam);
   676 			}
   765 			}
       
   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             }
   677 		}
   782 		}
   678 	return CFont::DoExtendedFunction(aFunctionId, aParam);
   783 	return CFont::DoExtendedFunction(aFunctionId, aParam);
   679 	}
   784 	}
   680 
   785