Common/font/ttffontrenderer.cpp
// Loads a TTF font of a certain size, optionally fill the FontMetrics struct
Loads a TTF font of a certain size, optionally fill the FontMetrics struct
Loads a TTF font of a certain size optionally fill the FontMetrics struct
static ALFONT_FONT *LoadTTF(const String &filename, int fontSize,
    int alfont_flags, FontMetrics *metrics)
{
    std::unique_ptr<Stream> reader(AssetMgr->OpenAsset(filename));
    if (!reader)
        return nullptr;
    const size_t lenof = reader->GetLength();
    std::vector<char> buf; buf.resize(lenof);
    reader->Read(&buf.front(), lenof);
    reader.reset();
    ALFONT_FONT *alfptr = alfont_load_font_from_mem(&buf.front(), lenof);
    if (!alfptr)
        return nullptr;
    alfont_set_font_size_ex(alfptr, fontSize, alfont_flags);
    if (metrics)
    {
        metrics->Height = alfont_get_font_height(alfptr);
        metrics->RealHeight = alfont_get_font_real_height(alfptr);
    }
    return alfptr;
}
static ALFONT_FONT * LoadTTF ( const String & filename , int fontSize , int alfont_flags , FontMetrics * metrics ) { std :: unique_ptr < Stream > reader ( AssetMgr -> OpenAsset ( filename ) ) ; if ( ! reader ) return nullptr ; const size_t lenof = reader -> GetLength ( ) ; std :: vector < char > buf ; buf . resize ( lenof ) ; reader -> Read ( & buf . front ( ) , lenof ) ; reader . reset ( ) ; ALFONT_FONT * alfptr = alfont_load_font_from_mem ( & buf . front ( ) , lenof ) ; if ( ! alfptr ) return nullptr ; alfont_set_font_size_ex ( alfptr , fontSize , alfont_flags ) ; if ( metrics ) { metrics -> Height = alfont_get_font_height ( alfptr ) ; metrics -> RealHeight = alfont_get_font_real_height ( alfptr ) ; } return alfptr ; }
Loads a TTF font of a certain size, optionally fill the FontMetrics struct
Loads a TTF font of a certain size optionally fill the FontMetrics struct