Exemple #1
0
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, bool monochrome, const uint32 *mapping) {
	TTFFont *font = new TTFFont();

	if (!font->load(stream, size, monochrome, mapping)) {
		delete font;
		return 0;
	}

	return font;
}
Exemple #2
0
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) {
	TTFFont *font = new TTFFont();

	if (!font->load(stream, size, dpi, renderMode, mapping)) {
		delete font;
		return 0;
	}

	return font;
}
TTFSurfacePtr
TTFSurfaceManager::create_surface(const TTFFont& font, const std::string& text)
{
  auto key = Key(font.get_ttf_font(), text);
  auto it = m_cache.find(key);
  if (it != m_cache.end())
  {
    auto& entry = m_cache[key];
    entry.last_access = g_game_time;
    return entry.ttf_surface;
  }
  else
  {
    if ((false))
    {
      // Font debug output should go to 'std::cerr', not any of the
      // log_* functions, as those are mirrored on the console which
      // in turn will lead to the creation of more TTFSurface's and
      // screw up the results.
      print_debug_info(std::cerr);
    }

    cache_cleanup_step();

    TTFSurfacePtr ttf_surface = TTFSurface::create(font, text);
    m_cache[key] = ttf_surface;
    return ttf_surface;
  }
}
void
ListView::draw()
{
    TTFFont* font = Fonts::vera20;

    float x = rect.left;
    float y = rect.top + font->get_height();
    float padding = 10;

    for(int i = 0; i < int(columns.size()); ++i)
    {
        // FIXME: Poor mans outline effect
        font->draw_center(x + columns[i].width/2 + 1, y - 1, columns[i].title);
        font->draw_center(x + columns[i].width/2 - 1, y - 1, columns[i].title);
        font->draw_center(x + columns[i].width/2 + 1, y + 1, columns[i].title);
        font->draw_center(x + columns[i].width/2 - 1, y + 1, columns[i].title);
        font->draw_center(x + columns[i].width/2, y, columns[i].title, Color(0.0f, 0.0f, 0.0f));
        x += columns[i].width;
    }

    for(int j = 0; j < int(items.size()); ++j)
    {
        x = rect.left;

        if (j == current_item)
            Display::fill_rect(Rectf(x, y,
                                     rect.right, y + font->get_height()),
                               is_active() ? Color(0.5f, 0.5f, 1.0f, 0.8f) : Color(0.5f, 0.5f, 1.0f, 0.3f));

        y += font->get_height();

        for(int i = 0; i < int(items[j].columns.size()) && i < int(columns.size()); ++i)
        {
            font->draw(x + padding, y, items[j].columns[i]);

            x += columns[i].width;
        }
    }
}