Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
nsFontEnumeratorPh Class Reference

#include <nsFontMetricsPh.h>

Inheritance diagram for nsFontEnumeratorPh:
Inheritance graph
[legend]
Collaboration diagram for nsFontEnumeratorPh:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFontEnumeratorPh ()
NS_DECL_ISUPPORTS NS_IMETHODIMP HaveFontFor (const char *aLangGroup, PRBool *aResult)
NS_IMETHODIMP GetDefaultFont (const char *aLangGroup, const char *aGeneric, PRUnichar **aResult)
NS_IMETHODIMP UpdateFontList (PRBool *updateFontList)
NS_IMETHODIMP EnumerateAllFonts (PRUint32 *aCount, PRUnichar ***aResult)
NS_IMETHOD EnumerateFonts (const char *aLangGroup, const char *aGeneric, PRUint32 *aCount, PRUnichar ***aResult)
void EnumerateAllFonts (out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult)
 Return a sorted array of the names of all installed fonts.
void EnumerateFonts (in string aLangGroup, in string aGeneric, out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult)
 Return a sorted array of names of fonts that support the given language group and are suitable for use as the given CSS generic font.
void HaveFontFor (in string aLangGroup,[retval] out boolean aResult)
wstring getDefaultFont (in string aLangGroup, in string aGeneric)
boolean updateFontList ()
 update the global font list return true if font list is changed

Detailed Description

Definition at line 206 of file nsFontMetricsPh.h.


Constructor & Destructor Documentation

Definition at line 299 of file nsFontMetricsPh.cpp.

{
}

Member Function Documentation

void nsIFontEnumerator::EnumerateAllFonts ( out PRUint32  aCount,
[retval, array, size_is(aCount)] out wstring  aResult 
) [inherited]

Return a sorted array of the names of all installed fonts.

Parameters:
aCountreturns number of names returned
aResultreturns array of names
Returns:
void
NS_IMETHODIMP nsFontEnumeratorPh::EnumerateAllFonts ( PRUint32 aCount,
PRUnichar ***  aResult 
) [inline]

Definition at line 236 of file nsFontMetricsPh.h.

Here is the call graph for this function:

void nsIFontEnumerator::EnumerateFonts ( in string  aLangGroup,
in string  aGeneric,
out PRUint32  aCount,
[retval, array, size_is(aCount)] out wstring  aResult 
) [inherited]

Return a sorted array of names of fonts that support the given language group and are suitable for use as the given CSS generic font.

Parameters:
aLangGrouplanguage group
aGenericCSS generic font
aCountreturns number of names returned
aResultreturns array of names
Returns:
void
NS_IMETHODIMP nsFontEnumeratorPh::EnumerateFonts ( const char *  aLangGroup,
const char *  aGeneric,
PRUint32 aCount,
PRUnichar ***  aResult 
)

Definition at line 336 of file nsFontMetricsPh.cpp.

{

       NS_ENSURE_ARG_POINTER(aResult);
       *aResult = nsnull;
       NS_ENSURE_ARG_POINTER(aCount);
       *aCount = 0;

       // aLangGroup=null or ""  means any (i.e., don't care)
       // aGeneric=null or ""  means any (i.e, don't care)
       const char* generic = nsnull;
       if (aGeneric && *aGeneric)
              generic = aGeneric;

       int i;
       if(!gFontDetails)
         {
                gnFonts = PfQueryFonts('a', PHFONT_DONT_SHOW_LEGACY, NULL, 0);
                if(gnFonts>0)
                     {
                            gFontDetails = new FontDetails[gnFonts];
                            if(gFontDetails)
                              {
                                   gFontNames = (nsCString**) nsMemory::Alloc(gnFonts * sizeof(nsCString*));
                                   PfQueryFonts('a', PHFONT_DONT_SHOW_LEGACY, gFontDetails, gnFonts);

                                   int total = 0;
                                   for(i=0;i<gnFonts;i++) {
                                          gFontNames[total++] = new nsCString(gFontDetails[i].desc);
                                          }
                                   gnFonts = total;
                              }

                     }
         }

       if( gnFonts > 0 )
         {
                PRUnichar** array = (PRUnichar**) nsMemory::Alloc(gnFonts * sizeof(PRUnichar*));
                if(!array)
                      return NS_ERROR_OUT_OF_MEMORY;

                int nCount = 0;
                for(i=0;i<gnFonts;i++)
                     {
                            if(!generic) /* select all fonts */
                              {
                                     if (gFontDetails[i].flags & PHFONT_INFO_PROP) /* always use proportional fonts */
                                          array[nCount++] = ToNewUnicode(*gFontNames[i]);
                              }
                            else if(stricmp(generic, "monospace") == 0)
                              {
                                     if(gFontDetails[i].flags & PHFONT_INFO_FIXED)
                                           array[nCount++] = ToNewUnicode(*gFontNames[i]);
                              }
                            /* other possible vallues for generic are: serif, sans-serif, cursive, fantasy */
                            else
                              {
                                     if (gFontDetails[i].flags & PHFONT_INFO_PROP) /* always use proportional fonts */
                                           array[nCount++] = ToNewUnicode(*gFontNames[i]);
                              }
                     }
                *aCount = nCount;
                *aResult = array;
                return NS_OK;
         }

       return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

wstring nsIFontEnumerator::getDefaultFont ( in string  aLangGroup,
in string  aGeneric 
) [inherited]
Parameters:
aLangGrouplanguage group
aGenericCSS generic font
Returns:
suggested default font for this language group and generic family
NS_IMETHODIMP nsFontEnumeratorPh::GetDefaultFont ( const char *  aLangGroup,
const char *  aGeneric,
PRUnichar **  aResult 
) [inline]

Definition at line 221 of file nsFontMetricsPh.h.

              {
                // aLangGroup=null or ""  means any (i.e., don't care)
                // aGeneric=null or ""  means any (i.e, don't care)
                NS_ENSURE_ARG_POINTER(aResult);
                *aResult = nsnull;
                return NS_OK;
              }
void nsIFontEnumerator::HaveFontFor ( in string  aLangGroup,
[retval] out boolean  aResult 
) [inherited]
Parameters:
aLangGrouplanguage group
Returns:
bool do we have a font for this language group
NS_DECL_ISUPPORTS NS_IMETHODIMP nsFontEnumeratorPh::HaveFontFor ( const char *  aLangGroup,
PRBool aResult 
) [inline]

Definition at line 213 of file nsFontMetricsPh.h.

              {
                NS_ENSURE_ARG_POINTER(aResult);
                *aResult = PR_TRUE; // always return true for now.
                return NS_OK;
              }

update the global font list return true if font list is changed

Definition at line 230 of file nsFontMetricsPh.h.

              {
                *updateFontList = PR_FALSE; // always return false for now
                return NS_OK;
              }

The documentation for this class was generated from the following files: