Example #1
0
bool
Font::Load(const FontDescription &d)
{
  assert(IsScreenInitialized());

  bool bold = d.IsBold();
  bool italic = d.IsItalic();
  const char *path = nullptr;

  /* check for presence of "real" font and clear the bold or italic
   * flags if found so that freetype does not apply them again to
   * produce a "synthetic" bold or italic version of the font */
  if (italic && bold && bold_italic_font_path != nullptr) {
    path = bold_italic_font_path;
    bold = false;
    italic = false;
  } else if (italic && italic_font_path != nullptr) {
    path = italic_font_path;
    italic = false;
  } else if (d.IsMonospace() && monospace_font_path != nullptr) {
    path = monospace_font_path;
  } else if (bold && bold_font_path != nullptr) {
    path = bold_font_path;
    bold = false;
  } else {
    path = font_path;
  }

  if (path == nullptr)
    return false;

  return LoadFile(path, d.GetHeight(), bold, italic);
}
Example #2
0
//------------------------------------------------------------------------------
bool
Font::Load(const FontDescription& d)
  {
  if (d.IsBold() == true)
    this->font.setWeight(QFont::Bold);
  else
    this->font.setWeight(QFont::Normal);
  if (d.IsItalic() == true)
    this->font.setStyle(QFont::StyleItalic);
  else
    this->font.setStyle(QFont::StyleNormal);
  if (d.IsMonospace() == true)
    this->font.setFamily("Courier");
  else
    this->font.setFamily("Sans");
  this->font.setPointSize(d.GetHeight());

  QFontMetrics m(this->font);
  this->height = m.height();
  this->ascent_height = m.ascent();
  this->capital_height = this->height;
  this->initialized = true;
  return true;
  }