
#include "kjs/wk_config.h"
#include "BCFontPlatformDataPrivateDirectFB.h"
#include <font/BTFontCache.h>

#include <font/Font.h>
#include <font/FontData.h>

#include "BTLogHelper.h"

namespace BAL {

void BTFontCache::platformInit()
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nBTFontCache::platformInit()\n");
}

const FontData* BTFontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nBTFontCache::getFontDataForCharacters()\n");
    FontPlatformData* fontPlatformData = new FontPlatformData(font.fontDescription(), font.family().family());
    FontData* fontData = 0;
    fontData = new FontData(*fontPlatformData);
    return fontData;
}

FontPlatformData* BTFontCache::getSimilarFontPlatformData(const Font& font)
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nBTFontCache::getSimilarFontPlatformData()\n");
    return new FontPlatformData(font.fontDescription(), font.family().family());
}

FontPlatformData* BTFontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nBTFontCache::getLastResortFallbackFont()\n");
    // FIXME: Would be even better to somehow get the user's default font here.
    // For now we'll pick the default that the user would get without changing any prefs.
    static AtomicString timesStr("Vera");
    return getCachedFontPlatformData(fontDescription, timesStr);
}

bool BTFontCache::fontExists(const FontDescription& fontDescription, const AtomicString& family)
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nNOT IMPLEMENTED: BTFontCache::fontExists()\n");
    // TODO: vou assumir que sempre existe uma fonte qualquer.
    return true;
}

FontPlatformData* BTFontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
    DBGML(MODULE_FONTS, LEVEL_INFO, "\nBTFontCache::createFontPlatformData(fontDescription,family)\n");
    return new FontPlatformData(fontDescription, family);
}

}
