First public contribution.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <linkedfonts.h>
20 #include "FbsMessage.H"
22 GLREF_C void Panic(TFbsPanic aPanic);
24 CFbsTypefaceStore::CFbsTypefaceStore(CGraphicsDevice* aDevice):
35 EXPORT_C CFbsTypefaceStore::~CFbsTypefaceStore()
44 /** Allocates and constructs a CFbsTypefaceStore, specifying a graphics device.
45 @param aDevice A pointer to a graphics device.
46 @return A pointer to the newly created typeface store.
50 EXPORT_C CFbsTypefaceStore* CFbsTypefaceStore::NewL(CGraphicsDevice* aDevice)
52 CFbsTypefaceStore* thisptr=new(ELeave) CFbsTypefaceStore(aDevice);
53 CleanupStack::PushL(thisptr);
54 thisptr->ConstructL();
60 void CFbsTypefaceStore::ConstructL()
62 // get the session info from the Tls
63 iFbs = RFbsSession::GetSession();
66 User::Leave(KErrCouldNotConnect);
68 CTypefaceStore::ConstructL();
69 iTwipsCache = new(ELeave) CFontCache;
73 /** Installs a font store file into the typeface store.
74 All the fonts in added and installed font files are available to the
75 GetNearestFont...() family of functions.
76 Additionally Bitmap Fonts are also available to GetFontById().
78 Installed files remain in the typeface store even after the client which added
79 them is destroyed. They can be removed using RemoveFile().
80 @param aName The name of the file to be installed.
81 @param aId On return, contains the id of the installed file.
82 @return KErrNone if successful, otherwise another of the system-wide error
87 @see GetNearestFontToDesignHeightInTwips()
88 @see GetNearestFontToDesignHeightInPixels()
89 @see GetNearestFontToMaxHeightInTwips()
90 @see GetNearestFontToMaxHeightInPixels()
94 EXPORT_C TInt CFbsTypefaceStore::InstallFile(const TDesC& aName,TInt& aId)
96 TPckgBuf<TIntParcel> ip;
98 TIpcArgs args(&aName,aName.Length(),&ip);
99 TInt ret=iFbs->SendCommand(EFbsMessInstallFontStoreFile,args);
105 /** Adds a font store file to the typeface store.
106 All the fonts in added and installed font files are available to the
107 GetNearestFont...() family of functions.
108 Additionally Bitmap Fonts are also available to GetFontById().
110 This function adds the typeface to a reference counted list of fonts. Each
111 client that adds the typeface to the store increases the reference count.
112 The count is decremented when a client using the typeface is destroyed or
113 calls the RemoveFile() function. The typeface is removed from the store only
114 when the the reference count is zero (it is not being used by any clients).
115 The InstallFile() function is similar, except that the typeface is not reference
116 counted, and is hence not removed when all the clients using it are destroyed.
117 @param aName A descriptor containing the filename of the typeface store
118 @param aId On return, contains the id of the typeface.
119 @return KErrNone if successful, otherwise another of the system-wide error
124 @see GetNearestFontToDesignHeightInTwips()
125 @see GetNearestFontToDesignHeightInPixels()
126 @see GetNearestFontToMaxHeightInTwips()
127 @see GetNearestFontToMaxHeightInPixels()
131 EXPORT_C TInt CFbsTypefaceStore::AddFile(const TDesC& aName,TInt& aId)
133 TPckgBuf<TIntParcel> ip;
135 TIpcArgs args(&aName,aName.Length(),&ip);
136 TInt ret=iFbs->SendCommand(EFbsMessAddFontStoreFile,args);
142 /** Decrements the reference count of a file which was added using
143 AddFile(), and removes it from the store if the reference count reaches zero.
144 If the font was not found in the list of reference-counted files (see AddFile())
145 it is assumed to be an installed file (see InstallFile()) and an attempt is
146 made to remove it anyway.
148 If the id given is 0, an attempt is made to remove all font objects from the
149 font store provided none of the fonts in the store are currently accessed,
150 otherwise it has no effect.
153 The id passed to this function has a different meaning depending on whether
154 or not the file is a Symbian-format bitmap file. If it is a Symbian-format
155 bitmap file the id is a UID, and is the same from one session to the next.
156 If it is an Open Font System file (e.g., a TrueType file) the id is an arbitrary
157 number. Consequently the id may vary from one session to the next, and should
158 not be saved in a file: however it may be kept and used by a client as
159 long as the client is running.
161 @param aId The id of the file to be removed/decremented, set by AddFile()
168 EXPORT_C void CFbsTypefaceStore::RemoveFile(TInt aId)
170 iFbs->SendCommand(EFbsMessRemoveFontStoreFile,aId);
173 /** Gets the number of typefaces supported by this store.
174 @return The number of supported typefaces.
175 @see CTypefaceStore::NumTypefaces()
179 EXPORT_C TInt CFbsTypefaceStore::NumTypefaces() const
181 return(iFbs->SendCommand(EFbsMessNumTypefaces));
185 Gets the font which is the nearest to the given font specification.
187 When the font is no longer needed, call @c ReleaseFont().
189 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
190 yielding (virtually) the same result. However clients are strongly encouraged to use the new
191 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
192 character within any given text string will fit within the given amount of twips, whereas the design
193 height is an aesthetic unit decided by the font designer without strict physical meaning, which
194 may result in cropped characters.
196 Chooses from the fonts loaded at system startup or through the AddFile()
197 or InstallFile() APIs.
199 @param aFont On return, contains a pointer to the nearest font.
200 @param aFontSpec The specification of the font to be matched.
201 @return KErrNone if successful; a system-wide error code otherwise.
203 @see GetNearestFontToDesignHeightInTwips()
204 @see GetNearestFontToMaxHeightInTwips()
208 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
210 return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
214 Gets the font which is the nearest to the given font specification.
216 When the font is no longer needed, call @c ReleaseFont().
218 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels()
219 yielding (virtually) the same result. However clients are strongly encouraged to use the new
220 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
221 character within any given text string will fit within the given amount of pixels, whereas the design
222 height is an aesthetic unit decided by the font designer without strict physical meaning, which
223 may result in cropped characters.
225 Chooses from the fonts loaded at system startup or through the AddFile()
226 or InstallFile() APIs.
228 @param aFont On return, contains a pointer to the nearest font.
229 @param aFontSpec The specification of the font to be matched.
230 @return KErrNone if successful; a system-wide error code otherwise.
232 @deprecated Use GetNearestFontToDesignHeightInPixels
233 @see GetNearestFontToDesignHeightInPixels()
234 @see GetNearestFontToMaxHeightInPixels()
238 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontInPixels(CFont*& aFont,const TFontSpec& aFontSpec)
240 return GetNearestFontToDesignHeightInPixels(aFont, aFontSpec);
243 TInt CFbsTypefaceStore::GetNearestFontInTwipsAndCreateFont(
245 TInt aFbsMessage, // a TFbsMessage
246 const TFontSpec& aFontSpec,
249 aFont = iTwipsCache->Search(aFontSpec);
252 if (IncrementFontCount(aFont))
256 Panic(EFbsTypefaceStoreError);
259 TInt ret = SendGetNearestFontCommandNCreateFont(
260 aFont, aFbsMessage, aFontSpec, aMaxHeight);
266 CFont* discard = NULL;
267 /* We are deliberately storing in the cache the TFontSpec requested by the client
268 * and not the REAL TFontSpec of the font returned by the font matcher.
269 * We are doing this for performance reasons: to use the Font Cache as much as possible.
270 * Unless the requested font spec is really complete, including all the different flags
271 * and sub fields, there is only a very small chance that the TFontSpec requested
272 * by the client would be exactly the same as the best match returned by the server.
273 * Since some flags (iFontStyle.iFlags and iTypeFace.iFlags) are quite complex and
274 * in general the client don't set up all of them perfectly.
275 * So in order to decrease the number of entries in the cache AND also the requests
276 * to the server, it's better to associate the TFontSpec asked for by the client
277 * with the CFont found so that next time we ask for it, it will be in the cache.
279 * If we request 2 different font specs that both have the same real font as their
280 * best match then each will appear in the cache but the CFont pointer in both entries
281 * will point to the same real CFont (no copies)
283 * PS: a problem is known because of doing this:
284 * if we try to get a Font which is not in the system, we obtain the best match
285 * then if we add this Font in the system (AddFile) and ask again for this Font,
286 * we will still have the previous one which is in the Cache and not the one added.
287 * This problem is the result of "bad" programming/testing, in general when we use a Font,
288 * we know it's here...
290 TRAP(ret, discard = iTwipsCache->AddEntryL(aFont,aFontSpec));
293 // Font has been added to cache. Increment reference count, so that this font
294 // will only be destroyed once all client handles to it are released, AND it can
295 // not fit in the cache. Even if no clients have a handle to this font, the object
296 // will still persist until other fonts force it out of the cache.
297 IncrementFontCount(aFont);
300 { // a font was bumped out of the cache
301 ReleaseFont(discard);
308 get pixel size in Twips * 1000
311 void CFbsTypefaceStore::GetPixelSizeInTwips(TSize& aSize) const
315 aSize.iWidth = iDevice->HorizontalPixelsToTwips(1000);
316 aSize.iHeight = iDevice->VerticalPixelsToTwips(1000);
318 if(aSize.iWidth==0 || aSize.iHeight==0)
320 TMachineInfoV1Buf mibuf;
321 UserHal::MachineInfo(mibuf);
322 TSize twipsize = mibuf().iPhysicalScreenSize;
323 TSize pixelsize = mibuf().iDisplaySizeInPixels;
324 aSize.iWidth = twipsize.iWidth*1000 / pixelsize.iWidth;
325 aSize.iHeight = twipsize.iHeight*1000 / pixelsize.iHeight;
330 TInt CFbsTypefaceStore::SendGetNearestFontCommandNCreateFont(
332 TInt aFbsMessage, // a TFbsMessage
333 const TFontSpec& aFontSpec,
336 TPckgBuf<TFontSpec> pckgFontSpec(aFontSpec);
338 GetPixelSizeInTwips(pixelSize);
339 TSizeInfo info(aMaxHeight, pixelSize);
340 TPckgBuf<TSizeInfo> pckgMaxHeight(info);
341 TPckgBuf<TFontInfo> pckgFontInfo;
342 TIpcArgs args(&pckgFontSpec, &pckgFontInfo, &pckgMaxHeight);
343 const TInt ret = iFbs->SendCommand(aFbsMessage, args);
348 return CreateFont(aFont, pckgFontInfo());
352 Gets the font which is the nearest to the given font specification.
354 When the font is no longer needed, call @c ReleaseFont().
356 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
357 same result. However clients are strongly encouraged to use the new
358 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
359 character within any given text string will fit within the given amount of twips, whereas the design
360 height is an aesthetic unit decided by the font designer without strict physical meaning, which
361 may result in cropped characters.
363 Chooses from the fonts loaded at system startup or through the AddFile()
364 or InstallFile() APIs.
366 @param aFont On return, contains a pointer to the nearest font.
367 @param aFontSpec The specification of the font to be matched.
368 @return KErrNone if successful; a system-wide error code otherwise.
371 @see GetNearestFontToMaxHeightInTwips()
375 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
377 return GetNearestFontInTwipsAndCreateFont(aFont, EFbsMessGetNearestFontToDesignHeightInTwips, aFontSpec);
381 Gets the font which is the nearest to the given font specification.
383 When the font is no longer needed, call @c ReleaseFont().
385 This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the
386 same result. However clients are strongly encouraged to use the new
387 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
388 character within any given text string will fit within the given amount of pixels, whereas the design
389 height is an aesthetic unit decided by the font designer without strict physical meaning, which
390 may result in cropped characters.
392 Chooses from the fonts loaded at system startup or through the AddFile()
393 or InstallFile() APIs.
395 @param aFont On return, contains a pointer to the nearest font.
396 @param aFontSpec The specification of the font to be matched.
397 @return KErrNone if successful; a system-wide error code otherwise.
400 @see GetNearestFontToMaxHeightInPixels()
404 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec)
406 return SendGetNearestFontCommandNCreateFont(aFont, EFbsMessGetNearestFontToDesignHeightInPixels, aFontSpec);
410 Gets the font which is the nearest to the given font specification.
412 When the font is no longer needed, call @c ReleaseFont().
414 The font and bitmap server returns a pointer to the nearest matching font
415 from those available. Matches to max height of font - this does its best
416 to return a font that will fit within the maximum height specified (but
417 note that variations due to hinting algorithms may rarely result in this
418 height being exceeded by up to one pixel). Problems can also be
419 encountered with bitmap fonts where the typeface exists but doesn't have
422 Chooses from the fonts loaded at system startup or through the AddFile()
423 or InstallFile() APIs.
425 @param aFont On return, contains a pointer to the nearest font.
426 @param aFontSpec The specification of the font to be matched.
427 @param aMaxHeight The maximum height within which the font must fit.
428 This overrides the height specified in aFontSpec.
429 @return KErrNone if successful; a system-wide error code otherwise.
432 @see GetNearestFontToDesignHeightInTwips()
436 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight)
438 return GetNearestFontInTwipsAndCreateFont(aFont, EFbsMessGetNearestFontToMaxHeightInTwips, aFontSpec, aMaxHeight);
442 Gets the font which is the nearest to the given font specification.
444 When the font is no longer needed, call @c ReleaseFont().
446 The font and bitmap server returns a pointer to the nearest matching font
447 from those available. Matches to max height of font - this does its best
448 to return a font that will fit within the maximum height specified (but
449 note that variations due to hinting algorithms may rarely result in this
450 height being exceeded by up to one pixel). Problems can also be
451 encountered with bitmap fonts where the typeface exists but doesn't have
454 Chooses from the fonts loaded at system startup or through the AddFile()
455 or InstallFile() APIs.
457 @param aFont On return, contains a pointer to the nearest font.
458 @param aFontSpec The specification of the font to be matched.
459 @param aMaxHeight The maximum height within which the font must fit.
460 This overrides the height specified in aFontSpec.
461 @return KErrNone if successful; a system-wide error code otherwise.
464 @see GetNearestFontToDesignHeightInPixels()
468 EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight)
470 return SendGetNearestFontCommandNCreateFont(aFont, EFbsMessGetNearestFontToMaxHeightInPixels, aFontSpec, aMaxHeight);
473 /** Gets a Bitmap Font by unique identifier and algorithmic drawing style.
474 Chooses from the Bitmap fonts loaded at system startup or through the AddFile()
475 or InstallFile() APIs.
477 @param aFont On return, contains a pointer to the retrieved font.
478 @param aUid The unique identifier of the font to be retrieved.
479 @param aAlgStyle Algorithmic style to be applied. e.g. Sets things like algorithmic
480 bolding, or slant for pseudo-italics.
481 @return KErrNone if successful, otherwise another of the system-wide error
485 @see GetNearestFontToMaxHeightInTwips()
486 @see GetNearestFontToDesignHeightInTwips()
487 @see GetNearestFontToMaxHeightInPixels()
488 @see GetNearestFontToDesignHeightInPixels()
492 EXPORT_C TInt CFbsTypefaceStore::GetFontById(CFont*& aFont,TUid aUid,const TAlgStyle& aAlgStyle)
494 TPckgBuf<TFontInfo> tfpckg;
496 GetPixelSizeInTwips(pixelSize);
497 TPckgBuf<TSize> sizePkg(pixelSize);
498 TPckgBuf<TAlgStyle> stylepckg(aAlgStyle);
499 TIpcArgs args(&tfpckg,&stylepckg,aUid.iUid, &sizePkg);
500 TInt ret=iFbs->SendCommand(EFbsMessGetFontById,args);
501 if(ret!=KErrNone) return(ret);
502 return(CreateFont(aFont,tfpckg()));
505 TInt CFbsTypefaceStore::CreateFont(CFont*& aFont, const TFontInfo& aFontInfo)
507 if (!aFontInfo.iHandle)
509 Panic(EFbsFontCreateFailed);
511 if (IsFontLoaded(aFont, aFontInfo))
513 // By now, a new server-side font object has been created for the requested
514 // TFontSpec. However IsFontLoaded() is true, meaning the client already has a
515 // font at this address. This can happen if a closely matching (but not exact,
516 // otherwise it would be found in the twipscache already) TFontSpec is sent to
518 // This means the new server-side font is a duplicate another server-side font.
519 // Therefore tell the server to destroy the one just created, and return the
520 // font that was already created.
521 iFbs->SendCommand(EFbsMessClose, aFontInfo.iHandle);
525 CFbsFont* font = new CFbsFont;
528 iFbs->SendCommand(EFbsMessClose, aFontInfo.iHandle);
531 font->iHandle = aFontInfo.iHandle;
532 font->iServerHandle = aFontInfo.iServerHandle;
533 font->iAddressPointer = (CBitmapFont*)(iFbs->HeapBase() + aFontInfo.iAddressOffset);
534 TRAPD(ret, AddFontL(font));
546 TBool CFbsTypefaceStore::IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const
548 @see CFontStore::IsFontLoaded
549 @see CPdrTypefaceStore::IsFontLoaded
552 const TInt count = iFontAccess->Count();
553 for (TInt i = 0; i < count; i++)
555 CFont* font = (*iFontAccess)[i].iFont;
556 if (((CFbsFont*)font)->iAddressPointer ==
557 (CBitmapFont*)(iFbs->HeapBase() + aFontInfo.iAddressOffset))
559 (*iFontAccess)[i].iAccessCount++;
567 /** Gets typeface information for a specified typeface index.
568 This information is returned in aTypefaceSupport, and includes the typeface
569 name and typeface attributes, the number of font heights, the maximum and
570 minimum font heights, and whether it is a scaleable typeface.
572 Returns benignly with an empty TTypefaceSupport if the index is too high;
573 this can happen if another process removes a typeface after the first process
574 has already got the number of typefaces. However, if the aTypefaceIndex<0
575 the function panics with EFbsTypefaceIndexOutOfRange.
577 @param aTypefaceSupport On return, if the function executed successfully,
578 this object contains the typeface information.
579 @param aTypefaceIndex A typeface index number, in the range: zero to (NumTypefaces() - 1).
580 @see CTypefaceStore::TypefaceSupport()
584 EXPORT_C void CFbsTypefaceStore::TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
586 __ASSERT_ALWAYS( aTypefaceIndex >= 0, Panic(EFbsTypefaceIndexOutOfRange) );
588 GetPixelSizeInTwips(pixelSize);
589 TPckgBuf<TSize> sizePkg(pixelSize);
590 TPckgBuf<TTypefaceSupport> tfi;
591 TIpcArgs args(aTypefaceIndex,&tfi, &sizePkg);
592 iFbs->SendCommand(EFbsMessTypefaceSupport,args);
593 aTypefaceSupport=tfi();
596 /** Gets the height of the font with specified height and typeface indices, in
598 The value returned is rounded up or down to the nearest font height in twips.
600 If aTypefaceIndex<0 the function panics with EFbsTypefaceIndexOutOfRange.
601 If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0
602 then the function returns 0. If aHeightIndex is greater than the number of
603 heights then the function returns the biggest height.
605 @param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1).
606 @param aHeightIndex A font height index number, in the range: 0 to (TTypefaceSupport::iNumHeights - 1).
607 Note: TTypefaceSupport::iNumHeights is returned by TypefaceSupport().
608 @return The height of the font, in twips.
609 @see CTypefaceStore::FontHeightInTwips()
613 EXPORT_C TInt CFbsTypefaceStore::FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
615 return FontHeight(aTypefaceIndex,aHeightIndex,EFbsMessFontHeightInTwips);
618 /** Gets the height of the font with specified height and typeface indices, in
620 The value returned is rounded up or down to the nearest font height in pixels.
622 If aTypefaceIndex<0 the function panics with EFbsTypefaceIndexOutOfRange.
623 If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0
624 then the function returns 0. If aHeightIndex is greater than the number of
625 heights then the function returns the biggest height.
627 @param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1).
628 @param aHeightIndex A font height index number, in the range: 0 to (TTypefaceSupport::iNumHeights - 1).
629 Note: TTypefaceSupport::iNumHeights is returned by TypefaceSupport().
630 @return The height of the font, in pixels.
634 EXPORT_C TInt CFbsTypefaceStore::FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const
636 return FontHeight(aTypefaceIndex,aHeightIndex,EFbsMessFontHeightInPixels);
639 TInt CFbsTypefaceStore::FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const
641 __ASSERT_ALWAYS( aTypefaceIndex >= 0, Panic(EFbsTypefaceIndexOutOfRange) );
643 GetPixelSizeInTwips(pixelSize);
644 TPckgBuf<TSize> sizePkg(pixelSize);
645 TIpcArgs args(aTypefaceIndex, aHeightIndex, &sizePkg);
646 return iFbs->SendCommand(aMessage, args);
649 /** Gets the default anti-aliasing setting for scalable fonts.
650 @return Indicates whether or not scalable fonts should be drawn using
655 EXPORT_C TGlyphBitmapType CFbsTypefaceStore::DefaultBitmapType() const
657 return (TGlyphBitmapType)iFbs->SendCommand(EFbsMessGetDefaultGlyphBitmapType);
660 /** Sets the default anti-aliasing setting for scalable fonts. Unless this
661 default setting is overridden so that a font is explicitly requested with
662 anti-aliasing turned on or off, (see TOpenFontSpec::SetBitmapType() or
663 TFontStyle::SetBitmapType()), fonts will use the default setting. The default
664 setting would typically only be changed via the Control Panel. The new setting
665 affects fonts requested after the change has been made.
666 There is currently no anti-aliasing support for bitmapped fonts.
667 @param aType Indicates whether or not scalable fonts should be drawn using
669 @see TOpenFontSpec::SetBitmapType()
670 @see TFontStyle::SetBitmapType()
674 EXPORT_C void CFbsTypefaceStore::SetDefaultBitmapType(TGlyphBitmapType aType) const
676 iFbs->SendCommand(EFbsMessSetDefaultGlyphBitmapType,aType);
679 /** Sets an alias for a font name.
681 If a requested font cannot be found and its name occurs in the alias list
682 then it will be searched for again using the font name corresponding to
683 that alias. If an empty font name is passed then the alias will be removed
685 @param TDesC& The font name alias to set.
686 @param TDesC& The actual font name to use for this alias. May be empty.
690 EXPORT_C void CFbsTypefaceStore::SetFontNameAliasL(const TDesC& aFontAlias,const TDesC& aFontName) const
692 TIpcArgs args(&aFontAlias,aFontAlias.Length(),&aFontName,aFontName.Length());
693 User::LeaveIfError(iFbs->SendCommand(EFbsMessFontNameAlias,args));
696 /** Specifies the default language with which font metrics calculation will be based on.
697 The default language will be used if none is set on the font specification.
700 @see TFontSpec::SetScriptTypeForMetrics
702 EXPORT_C void CFbsTypefaceStore::SetDefaultLanguageForMetrics(TLanguage aLanguage) const
704 iFbs->SendCommand(EFbsMessDefaultLanguageForMetrics, aLanguage);
708 Unload all fonts loaded from RAM or removable media
712 EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL()
714 User::Leave(KErrNotSupported);
718 Unload all fonts (of specified type) loaded from named drive
721 EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL(const TDesC& /*aDrive*/, TBool /*aAllFonts*/)
723 User::Leave(KErrNotSupported);
727 Unload the named font file
730 EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL(const TDesC& /*aFileName*/)
732 User::Leave(KErrNotSupported);
735 /** Reset the twips cache.
737 The Typeface Store remembers font matches found through GetNearestFont...InTwips() family
738 of functions in a cache for quicker matching. This function empties the cache, and should be
739 called after the screen mode is changed as the Twips to pixels relationship may have changed.
742 EXPORT_C void CFbsTypefaceStore::ReleaseTwipsCache()
746 CFont* font=iTwipsCache->RemoveFirstEntry();
750 font=iTwipsCache->RemoveFirstEntry();
756 Sets the system default font typeface. This font will be used when finding the nearest font and the font specified is
758 If the system default font is not set, then the default behaviour is to find the nearest match.
760 @capability WriteDeviceData
761 @param aFontTypefacename is the font typeface to use as the system default. A font alias cannot be used.
763 EXPORT_C void CFbsTypefaceStore::SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName)
765 if (aFontTypefaceName.Length() <= KMaxTypefaceNameLength)
767 TIpcArgs args(&aFontTypefaceName);
768 User::LeaveIfError(iFbs->SendCommand(EFbsSetSystemDefaultTypefaceName, args));
771 User::Leave(KErrTooBig); // Typeface name is too large
775 Function to add a CLinkedTypefaceSpecification to the font and bitmap server typeface store.
776 @capability ECapabilityWriteDeviceData
779 @param aLinkedTypefaceSpec The typeface specification to be added. Ownership is not transferred.
780 @param aId A unique identifier
781 @return A global error code
782 @see CLinkedTypefaceSpecification
785 EXPORT_C TInt CFbsTypefaceStore::RegisterLinkedTypeface(const CLinkedTypefaceSpecification& /*aLinkedTypefaceSpec*/, TInt& /*aId*/)
787 return KErrNotSupported;
791 Function to add a CLinkedTypefaceSpecification to the font and bitmap server typeface store.
792 @capability ECapabilityWriteDeviceData
795 @param aLinkedTypefaceSpec. The typeface specification to be added. Ownership is not transferred.
796 @return a global error code
797 @see CLinkedTypefaceSpecification
799 EXPORT_C TInt CFbsTypefaceStore::RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
801 __ASSERT_ALWAYS(iFbs,Panic(EFbsPanicNoConnection));
804 TPckgBuf <TLinkedTypefaceSpecificationArgs> pckgbuf;
805 TLinkedTypefaceSpecificationArgs &typefaceArgs=pckgbuf();
807 typefaceArgs = aLinkedTypefaceSpec;
809 TIpcArgs args(&pckgbuf,sizeof(TPckgBuf <TLinkedTypefaceSpecificationArgs>));
811 return iFbs->SendCommand(EFbsMessRegisterLinkedTypeface,args);
814 Function to retrieve a linked typeface specification from the installed rasterizer.
815 If there is not a rasterizer present supporting font linking then KErrNotSupported will be returned.
816 The rasterizer is name specified within the passed specification and fills in the elements and
817 groups if the typeface exists.
819 @param CLinkedTypefaceSpecificaion& The typeface Specification with the name set to be the typeface to be retrieved.
821 @leave KErrNoMemory if there is insufficient memory available
822 @leave KErrServerTerminated if the server no longer present
823 @leave KErrServerBusy if there are no message slots available
825 EXPORT_C void CFbsTypefaceStore::GetLinkedTypefaceL(CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
827 TBuf<KMaxTypefaceNameLength> linkedName = aLinkedTypefaceSpec.Name();
829 TLinkedTypefaceSpecificationArgs returnSpec;
830 TPckgBuf<TLinkedTypefaceSpecificationArgs> specPkg;
833 args.Set(0,&linkedName);
834 args.Set(2,&specPkg);
836 User::LeaveIfError(iFbs->SendCommand(EFbsMessFetchLinkedTypeface, args));
838 aLinkedTypefaceSpec.Clear();
839 returnSpec = specPkg();
842 for (i = 0 ; i < returnSpec.iGroupSize ; i++)
844 CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(returnSpec.iGroups[i].iGroupId);
845 grp->SetBaselineShift(returnSpec.iGroups[i].iBaselineShift);
846 grp->SetScalingOption(returnSpec.iGroups[i].iScalingOption);
847 grp->SetBoldnessPercentage(returnSpec.iGroups[i].iBoldnessPercentage);
848 grp->SetItalicAngle(returnSpec.iGroups[i].iItalicAngle);
849 aLinkedTypefaceSpec.AddLinkedTypefaceGroupL(*grp);
850 CleanupStack::Pop(grp);
852 for (i = 0 ; i < returnSpec.iSize ; i++)
854 CLinkedTypefaceElementSpec* ele = CLinkedTypefaceElementSpec::NewLC(returnSpec.iTypefaces[i].iName, returnSpec.iTypefaces[i].iGroupId);
855 ele->SetCanonical(returnSpec.iTypefaces[i].iIsCanonical);
856 aLinkedTypefaceSpec.AddTypefaceAtBackL(*ele);
857 CleanupStack::Pop(ele);
862 Function to update an existing linked typeface with a new specification. If successful a temporary file is generated and this will replace the
863 linked font after a reboot. Calls to FetchLinkedTypefaceSpecificationL will return the currently loaded linked font spec and not the
864 updated specification.
866 @param aLinkedTypefaceSpec A new linked font specification to replace an existing file
868 @panic EFbsPanicNoConnection There is no connection to FontBitmap Server
870 @return TInt One of the system wide error codes
872 EXPORT_C TInt CFbsTypefaceStore::UpdateLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
874 __ASSERT_ALWAYS(iFbs,Panic(EFbsPanicNoConnection));
876 TPckgBuf <TLinkedTypefaceSpecificationArgs> pckgbuf;
877 TLinkedTypefaceSpecificationArgs &typefaceArgs=pckgbuf();
879 typefaceArgs = aLinkedTypefaceSpec;
881 TIpcArgs args(&pckgbuf,sizeof(TPckgBuf <TLinkedTypefaceSpecificationArgs>));
883 return iFbs->SendCommand(EFbsMessUpdateLinkedTypeface,args);