Пример #1
0
bool
Font::Set(const LOGFONT &log_font)
{
  assert(IsScreenInitialized());

  Reset();

  font = ::CreateFontIndirect(&log_font);
  if (font == NULL)
    return false;

  if (GetObjectType(font) != OBJ_FONT) {
    Reset();
    return false;
  }

  CalculateHeights();

  return true;
}
Пример #2
0
bool
Font::_set(const char *file, UPixelScalar ptsize, bool bold, bool italic)
{
  assert(IsScreenInitialized());

  Reset();

  font = TTF_OpenFont(file, ptsize);
  if (font == NULL)
    return false;

  int style = TTF_STYLE_NORMAL;
  if (bold)
    style |= TTF_STYLE_BOLD;
  if (italic)
    style |= TTF_STYLE_ITALIC;
  TTF_SetFontStyle(font, style);

  CalculateHeights();

  return true;
}