|
41 | 41 | #include "qhaikutheme.h"
|
42 | 42 | #include "qhaikusettings.h"
|
43 | 43 | #include "qhaikuplatformdialoghelpers.h"
|
44 |
| -#include "qhaikusystemsettings.h" |
45 | 44 | #include "qhaikuintegration.h"
|
46 | 45 | #include "qhaikusystemtrayicon.h"
|
47 | 46 |
|
@@ -216,8 +215,76 @@ const QFont *QHaikuTheme::font(Font type) const
|
216 | 215 | {
|
217 | 216 | QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase();
|
218 | 217 |
|
219 |
| - if (fontDatabase && m_fonts.isEmpty()) |
220 |
| - m_fonts = qt_haiku_createRoleFonts(fontDatabase); |
| 218 | + if (fontDatabase && m_fonts.isEmpty()) { |
| 219 | + QFontDatabase db; |
| 220 | + |
| 221 | + font_family plainFontFamily; |
| 222 | + font_style plainFontStyle; |
| 223 | + BFont haikuPlainFont = *be_plain_font; |
| 224 | + haikuPlainFont.GetFamilyAndStyle(&plainFontFamily, &plainFontStyle); |
| 225 | + |
| 226 | + font_family boldFontFamily; |
| 227 | + font_style boldFontStyle; |
| 228 | + BFont haikuBoldFont = *be_bold_font; |
| 229 | + haikuBoldFont.GetFamilyAndStyle(&boldFontFamily, &boldFontStyle); |
| 230 | + |
| 231 | + font_family fixedFontFamily; |
| 232 | + font_style fixedFontStyle; |
| 233 | + BFont haikuFixedFont = *be_fixed_font; |
| 234 | + haikuFixedFont.GetFamilyAndStyle(&fixedFontFamily, &fixedFontStyle); |
| 235 | + |
| 236 | + menu_info haikuMenuFontInfo; |
| 237 | + get_menu_info(&haikuMenuFontInfo); |
| 238 | + |
| 239 | + float kSmallFont = 0.7; |
| 240 | + float kBold = 0.96; |
| 241 | + |
| 242 | + QFont baseFont = db.font(plainFontFamily, plainFontStyle, haikuPlainFont.Size()); |
| 243 | + if (haikuPlainFont.Size() >= 0) |
| 244 | + baseFont.setPointSizeF(haikuPlainFont.Size()); |
| 245 | + baseFont.setStretch(QFont::Unstretched); |
| 246 | + |
| 247 | + QFont boldFont = db.font(boldFontFamily, boldFontStyle, haikuBoldFont.Size() * kBold); |
| 248 | + if (haikuBoldFont.Size() >= 0) |
| 249 | + boldFont.setPointSizeF(haikuBoldFont.Size() * kBold); |
| 250 | + boldFont.setStretch(QFont::Unstretched); |
| 251 | + |
| 252 | + QFont monoFont = db.font(fixedFontFamily, fixedFontStyle, haikuFixedFont.Size()); |
| 253 | + if (haikuFixedFont.Size() >= 0) |
| 254 | + monoFont.setPointSizeF(haikuFixedFont.Size()); |
| 255 | + monoFont.setStretch(QFont::Unstretched); |
| 256 | + |
| 257 | + QFont menuFont = db.font(haikuMenuFontInfo.f_family, haikuMenuFontInfo.f_style, haikuMenuFontInfo.font_size); |
| 258 | + if (haikuMenuFontInfo.font_size >= 0) |
| 259 | + menuFont.setPointSizeF(haikuMenuFontInfo.font_size); |
| 260 | + menuFont.setStretch(QFont::Unstretched); |
| 261 | + |
| 262 | + QHash<QPlatformTheme::Font, QFont *> fonts; |
| 263 | + fonts.insert(QPlatformTheme::SystemFont, new QFont(baseFont)); |
| 264 | + fonts.insert(QPlatformTheme::PushButtonFont, new QFont(baseFont)); |
| 265 | + fonts.insert(QPlatformTheme::ListViewFont, new QFont(baseFont)); |
| 266 | + fonts.insert(QPlatformTheme::ListBoxFont, new QFont(baseFont)); |
| 267 | + fonts.insert(QPlatformTheme::TitleBarFont, new QFont(boldFont)); |
| 268 | + fonts.insert(QPlatformTheme::GroupBoxTitleFont, new QFont(boldFont)); |
| 269 | + fonts.insert(QPlatformTheme::MdiSubWindowTitleFont, new QFont(boldFont)); |
| 270 | + fonts.insert(QPlatformTheme::MenuFont, new QFont(menuFont)); |
| 271 | + fonts.insert(QPlatformTheme::MenuBarFont, new QFont(menuFont)); |
| 272 | + fonts.insert(QPlatformTheme::ComboMenuItemFont, new QFont(menuFont)); |
| 273 | + fonts.insert(QPlatformTheme::HeaderViewFont, new QFont(baseFont)); |
| 274 | + fonts.insert(QPlatformTheme::TipLabelFont, new QFont(baseFont)); |
| 275 | + fonts.insert(QPlatformTheme::LabelFont, new QFont(baseFont)); |
| 276 | + fonts.insert(QPlatformTheme::ToolButtonFont, new QFont(baseFont)); |
| 277 | + fonts.insert(QPlatformTheme::MenuItemFont, new QFont(menuFont)); |
| 278 | + fonts.insert(QPlatformTheme::ComboLineEditFont, new QFont(baseFont)); |
| 279 | + fonts.insert(QPlatformTheme::FixedFont, new QFont(monoFont)); |
| 280 | + |
| 281 | + QFont smallFont(baseFont); |
| 282 | + smallFont.setPointSizeF(haikuPlainFont.Size() * kSmallFont); |
| 283 | + fonts.insert(QPlatformTheme::SmallFont, new QFont(smallFont)); |
| 284 | + fonts.insert(QPlatformTheme::MiniFont, new QFont(smallFont)); |
| 285 | + |
| 286 | + m_fonts = fonts; |
| 287 | + } |
221 | 288 | return m_fonts.value(type, 0);
|
222 | 289 | }
|
223 | 290 |
|
|
0 commit comments