Exemplo n.º 1
0
FontAtlas * FontAtlasCache::getFontAtlasTTF(const std::string& fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField)
{
    std::string atlasName = generateFontName(fontFileName, size, glyphs, useDistanceField);
    FontAtlas  *tempAtlas = _atlasMap[atlasName];
    
    if ( !tempAtlas )
    {
        FontFreeType *font = FontFreeType::create(fontFileName, size, glyphs, customGlyphs);
        if (font)
        {
            font->setDistanceFieldEnabled(useDistanceField);
            tempAtlas = font->createFontAtlas();
            if (tempAtlas)
                _atlasMap[atlasName] = tempAtlas;
        }
        else
        {
            return nullptr;
        }
    }
    else
    {
        tempAtlas->retain();
    }

    return tempAtlas;
}
Exemplo n.º 2
0
FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& plistFile)
{
    std::string atlasName = generateFontName(plistFile, 0, GlyphCollection::CUSTOM,false);
    FontAtlas *tempAtlas = _atlasMap[atlasName];

    if ( !tempAtlas )
    {
        Font *font = FontCharMap::create(plistFile);

        if(font)
        {
            tempAtlas = font->createFontAtlas();
            if (tempAtlas)
                _atlasMap[atlasName] = tempAtlas;
        }
        else
        {
            return nullptr;
        }
    }
    else
    {
        tempAtlas->retain();
    }

    return tempAtlas;
}
Exemplo n.º 3
0
FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
{
    char tmp[30];
    sprintf(tmp,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap);
    std::string atlasName = generateFontName(tmp, 0, GlyphCollection::CUSTOM,false);
    FontAtlas *tempAtlas = _atlasMap[atlasName];

    if ( !tempAtlas )
    {
        Font *font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap);

        if(font)
        {
            tempAtlas = font->createFontAtlas();
            if (tempAtlas)
                _atlasMap[atlasName] = tempAtlas;
        }
        else
        {
            return nullptr;
        }
    }
    else
    {
        tempAtlas->retain();
    }

    return tempAtlas;
}