Example #1
0
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig);

    if (!newAtlas)
        return false;

    if (initWithFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true))
    {
        _fontConfig = ttfConfig;
        if (ttfConfig.outlineSize > 0)
        {
            _fontConfig.distanceFieldEnabled = false;
            _useDistanceField = false;
            _useA8Shader = false;
            _currLabelEffect = LabelEffect::OUTLINE;
            initProgram();
        }
        else if(ttfConfig.distanceFieldEnabled)
        {
            this->setFontScale(1.0f * ttfConfig.fontSize / DefultFontSize);
        }
        _currentLabelType = LabelType::TTF;
        return true;
    }
    else
    {
        return false;
    }
}
Example #2
0
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset /* = Point::ZERO */)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);

    if (!newAtlas)
        return false;

    return initWithFontAtlas(newAtlas);
}
Example #3
0
bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap);

    if (!newAtlas)
        return false;

    return initWithFontAtlas(newAtlas);
}
Example #4
0
bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(texture,itemWidth,itemHeight,startCharMap);

    if (!newAtlas)
        return false;

    return initWithFontAtlas(newAtlas);
}
Example #5
0
bool Label::setCharMap(const std::string& plistFile)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile);

    if (!newAtlas)
        return false;

    return initWithFontAtlas(newAtlas);
}
Example #6
0
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
{
    FontAtlas *newAtlas = nullptr;
    if(ttfConfig.distanceFieldEnabled)
        newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig.fontFilePath, DISTANCEFIELD_ATLAS_FONTSIZE, ttfConfig.glyphs, ttfConfig.customGlyphs,true);
    else
        newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig.fontFilePath, ttfConfig.fontSize, ttfConfig.glyphs, ttfConfig.customGlyphs,false);

    if (!newAtlas)
        return false;

    return initWithFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
}
Example #7
0
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset /* = Point::ZERO */)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);

    if (!newAtlas)
        return false;

    if (initWithFontAtlas(newAtlas))
    {
        _currentLabelType = LabelType::BMFONT;
        return true;
    }

    return false;
}
Example #8
0
bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap);

    if (!newAtlas)
        return false;

    if (initWithFontAtlas(newAtlas))
    {
        _currentLabelType = LabelType::CHARMAP;
        return true;
    }

    return false;
}
Example #9
0
bool Label::setCharMap(const std::string& plistFile)
{
    FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile);

    if (!newAtlas)
        return false;

    if (initWithFontAtlas(newAtlas))
    {
        _currentLabelType = LabelType::CHARMAP;
        return true;
    }

    return false;
}