Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsFontMetricsQt.cpp File Reference
#include "nsQuickSort.h"
#include "nsFontMetricsQt.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsISaveAsCharset.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsCOMPtr.h"
#include "nspr.h"
#include "nsHashtable.h"
#include "nsDrawingSurfaceQt.h"
#include "nsRenderingContextQt.h"
#include "nsILanguageAtomService.h"
#include <qapplication.h>
#include <qfont.h>
#include <qfontdatabase.h>
#include "qtlog.h"

Go to the source code of this file.

Functions

static nsresult EnumFonts (nsIAtom *aLangGroup, const char *aGeneric, PRUint32 *aCount, PRUnichar ***aResult)

Function Documentation

static nsresult EnumFonts ( nsIAtom aLangGroup,
const char *  aGeneric,
PRUint32 aCount,
PRUnichar ***  aResult 
) [static]

Definition at line 287 of file nsFontMetricsQt.cpp.

{
    *aResult = nsnull;
    *aCount = 0;
    /* Get list of all fonts */
    QStringList qFamilies = QFontDatabase().families();
    int count = qFamilies.count();

    PRUnichar **array = (PRUnichar**)nsMemory::Alloc(count * sizeof(PRUnichar*));
    NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);

    int i = 0;
    for (QStringList::ConstIterator famIt = qFamilies.begin(); famIt != qFamilies.end(); ++famIt) {
        QString family = *famIt;
        array[i] = new PRUnichar[family.length()];
        if (array[i]) {
            memcpy(array[i], family.unicode(), family.length()*sizeof(PRUnichar));
            i++;
        }
        else {
            // OOM. Decrease the count and resize the array accordingly.
            count--;
            array = (PRUnichar**)nsMemory::Realloc((void*)array, count * sizeof(PRUnichar*));
        }
    }

    *aCount = count;
    *aResult = array;
    return NS_OK;
}

Here is the call graph for this function: