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
void
DialogLook::Initialise()
{
  const FontDescription text_font_d(std::min(Layout::FontScale(12),
                                             Layout::min_screen_pixels / 20));
  const FontDescription small_font_d =
    text_font_d.WithHeight(text_font_d.GetHeight() * 3u / 4u);

  text_font.Load(text_font_d);
  small_font.Load(small_font_d);

  bold_font.Load(text_font_d.WithBold());

  caption.text_color = COLOR_BLACK;
  caption.font = &text_font;

#ifdef EYE_CANDY
  caption.background_bitmap.Load(IDB_DIALOGTITLE);
#endif

  caption.background_color = IsDithered() ? COLOR_BLACK : COLOR_XCSOAR_DARK;
  caption.inactive_background_color = COLOR_GRAY;

  if (IsDithered())
    SetBackgroundColor(COLOR_WHITE);
  else
    SetBackgroundColor(Color(0xe2, 0xdc, 0xbe));
  text_color = COLOR_BLACK;

  button.Initialise(bold_font);
  check_box.Initialise(text_font);

  focused.background_color = COLOR_XCSOAR_DARK;
  focused.text_color = COLOR_WHITE;
  focused.border_pen.Create(Layout::FastScale(1) + 2, COLOR_BLACK);

  list.background_color = COLOR_WHITE;
  list.text_color = COLOR_BLACK;
  list.selected.background_color = IsDithered()
    ? COLOR_VERY_LIGHT_GRAY : COLOR_XCSOAR_LIGHT;
  list.selected.text_color = COLOR_BLACK;
  list.focused.background_color = IsDithered() ? COLOR_BLACK : COLOR_XCSOAR;
  list.focused.text_color = COLOR_WHITE;
  list.pressed.background_color = COLOR_YELLOW;
  list.pressed.text_color = COLOR_BLACK;
  list.font = &text_font;
  list.font_bold = &bold_font;
}
Example #3
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;
  }