11#ifndef __SFONTPOOL__H__
12#define __SFONTPOOL__H__
14#include <core/SSingletonMap.h>
15#include <interface/SRender-i.h>
16#include <res.mgr/SFontInfo.h>
17#include <helper/obj-ref-impl.hpp>
19#define FF_DEFAULTFONT L""
38class CElementTraits<
FontInfo> :
public CElementTraitsBase<FontInfo> {
45 static ULONG
Hash(INARGTYPE fontKey)
47 ULONG uRet = SNS::CElementTraits<SStringW>::Hash(fontKey.strFaceName);
48 uRet = (uRet << 5) + SNS::CElementTraits<SStringW>::Hash(fontKey.strPropEx);
49 uRet = (uRet << 5) + (UINT)fontKey.style.syle + 1 + fontKey.scale;
61 return element1.strFaceName == element2.strFaceName && element1.strPropEx == element2.strPropEx && element1.style.syle == element2.style.syle && element1.scale == element2.scale;
72 int nRet = element1.strFaceName.Compare(element2.strFaceName);
74 nRet = element1.strPropEx.Compare(element2.strPropEx);
76 nRet = (int)(element1.style.syle - element2.style.syle);
78 nRet = (int)(element1.scale - element2.scale);
85typedef BOOL (*FunFontCheck)(
const SStringW &strFontName);
static bool CompareElements(INARGTYPE element1, INARGTYPE element2)
Compare two FontInfo objects for equality.
static ULONG Hash(INARGTYPE fontKey)
Calculate the hash value of a FontInfo object.
static int CompareElementsOrdered(INARGTYPE element1, INARGTYPE element2)
Compare two FontInfo objects in order.
Smart pointer class for managing COM-style reference-counted objects.
SCmnMap(void(*funOnKeyRemoved)(const IFontPtr &)=NULL)
static FunFontCheck s_funFontCheck
const FontInfo & _GetDefFontInfo() const
Get constant reference to default font information.
static FontInfo FontInfoFromString(const SStringW &strFontInfo, const FontInfo &defFontInfo)
Convert font description to FontInfo.
static void OnKeyRemoved(const IFontPtr &obj)
Callback function when FontInfo is removed.
static void SetFontChecker(FunFontCheck fontCheck)
Set the callback function for checking fonts.
SAutoRefPtr< IRenderFactory > m_RenderFactory
SFontPool(IRenderFactory *fac)
Constructor.
void SetRenderFactory(IRenderFactory *fac)
Set render factory object.
static BOOL CheckFont(const SStringW &strFontName)
Check if a font is valid.
static IFontPtr GetFont(const SStringW &strFont, int scale)
Get IFontPtr corresponding to the specified description string.
IFontPtr _GetFont(const SStringW &strFont, int scale)
Get IFontPtr corresponding to the specified description string.
void _SetDefFontInfo(const SStringW &strFontInfo)
Set default font description string.
static SStringW FontInfoToString(const FontInfo &fi)
Convert FontInfo to font description.
IFontPtr _CreateFont(const FontInfo &fontInfo)
Create font object corresponding to FontInfo.
static void SetDefFontInfo(const SStringW &strFontInfo)
Set default font.
static FontInfo GetDefFontInfo()
Get default font information.
A class representing an ASCII string.
Font information structure.