diff --git a/kcms/fonts/fonts.cpp b/kcms/fonts/fonts.cpp index f336518a7..ec82c0f14 100644 --- a/kcms/fonts/fonts.cpp +++ b/kcms/fonts/fonts.cpp @@ -1,711 +1,711 @@ /* Copyright 1997 Mark Donohoe Copyright 1999 Lars Knoll Copyright 2000 Rik Hemsley Copyright 2015 Antonis Tsiapaliokas Copyright 2017 Marco Martin Ported to kcontrol2 by Geert Jansen. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "fonts.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../krdb/krdb.h" #include "previewimageprovider.h" /**** DLL Interface ****/ K_PLUGIN_FACTORY_WITH_JSON(KFontsFactory, "kcm_fonts.json", registerPlugin();) //from KFontRequester // Determine if the font with given properties is available on the system, // otherwise find and return the best fitting combination. static QFont nearestExistingFont(const QFont &font) { QFontDatabase dbase; // Initialize font data according to given font object. QString family = font.family(); QString style = dbase.styleString(font); qreal size = font.pointSizeF(); // Check if the family exists. const QStringList families = dbase.families(); if (!families.contains(family)) { // Chose another family. family = QFontInfo(font).family(); // the nearest match if (!families.contains(family)) { family = families.count() ? families.at(0) : QStringLiteral("fixed"); } } // Check if the family has the requested style. // Easiest by piping it through font selection in the database. QString retStyle = dbase.styleString(dbase.font(family, style, 10)); style = retStyle; // Check if the family has the requested size. // Only for bitmap fonts. if (!dbase.isSmoothlyScalable(family, style)) { QList sizes = dbase.smoothSizes(family, style); if (!sizes.contains(size)) { // Find nearest available size. int mindiff = 1000; int refsize = size; Q_FOREACH (int lsize, sizes) { int diff = qAbs(refsize - lsize); if (mindiff > diff) { mindiff = diff; size = lsize; } } } } // Select the font with confirmed properties. QFont result = dbase.font(family, style, int(size)); if (dbase.isSmoothlyScalable(family, style) && result.pointSize() == floor(size)) { result.setPointSizeF(size); } return result; } /**** FontAASettings ****/ #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) FontAASettings::FontAASettings(QObject *parent) : QObject(parent) , m_subPixelOptionsModel(new QStandardItemModel(this)) , m_hintingOptionsModel(new QStandardItemModel(this)) { for (int t = KXftConfig::SubPixel::NotSet; t <= KXftConfig::SubPixel::Vbgr; ++t) { QStandardItem *item = new QStandardItem(KXftConfig::description((KXftConfig::SubPixel::Type)t)); m_subPixelOptionsModel->appendRow(item); } for (int s = KXftConfig::Hint::NotSet; s <= KXftConfig::Hint::Full; ++s) { QStandardItem * item = new QStandardItem(KXftConfig::description((KXftConfig::Hint::Style)s)); m_hintingOptionsModel->appendRow(item); } } void FontAASettings::load() { double from, to; KXftConfig xft; if (xft.getExcludeRange(from, to)) { m_excludeFrom = from; m_excludeTo = to; setExclude(true); } else { m_excludeFrom = 8; m_excludeTo = 15; setExclude(false); } m_excludeFromOriginal = m_excludeFrom; m_excludeToOriginal = m_excludeTo; excludeToChanged(); excludeFromChanged(); KXftConfig::SubPixel::Type spType; xft.getSubPixelType(spType); setSubPixelCurrentIndex(spType); m_subPixelCurrentIndexOriginal = spType; KXftConfig::Hint::Style hStyle; if (!xft.getHintStyle(hStyle) || KXftConfig::Hint::NotSet == hStyle) { KConfig kglobals("kdeglobals", KConfig::NoGlobals); hStyle = KXftConfig::Hint::NotSet; xft.setHintStyle(hStyle); KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle)); kglobals.sync(); runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); } setHintingCurrentIndex(hStyle); m_hintingCurrentIndexOriginal = hStyle; KConfig _cfgfonts("kcmfonts"); KConfigGroup cfgfonts(&_cfgfonts, "General"); int dpicfg; if (KWindowSystem::isPlatformWayland()) { dpicfg = cfgfonts.readEntry("forceFontDPIWayland", 0); } else { dpicfg = cfgfonts.readEntry("forceFontDPI", 0); } if (dpicfg <= 0) { m_dpiOriginal = 0; } else { m_dpiOriginal = dpicfg; }; setDpi(dpicfg); KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); KConfigGroup cg(config, "General"); if (cfgfonts.readEntry("dontChangeAASettings", true)) { setAntiAliasing(1); //AASystem } else if (cg.readEntry("XftAntialias", true)) { setAntiAliasing(0); //AAEnabled } else { setAntiAliasing(2); //AADisabled } m_antiAliasingOriginal = m_antiAliasing; } bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState) { KXftConfig xft; KConfig kglobals("kdeglobals", KConfig::NoGlobals); KConfigGroup grp(&kglobals, "General"); xft.setAntiAliasing(aaState); if (m_exclude) { xft.setExcludeRange(m_excludeFrom, m_excludeTo); } else { xft.setExcludeRange(0, 0); } KXftConfig::SubPixel::Type spType = (KXftConfig::SubPixel::Type)m_subPixelCurrentIndex; xft.setSubPixelType(spType); grp.writeEntry("XftSubPixel", KXftConfig::toStr(spType)); if (aaState == KXftConfig::AntiAliasing::NotSet) { grp.revertToDefault("XftAntialias"); } else { grp.writeEntry("XftAntialias", aaState == KXftConfig::AntiAliasing::Enabled); } bool mod = false; KXftConfig::Hint::Style hStyle = (KXftConfig::Hint::Style)m_hintingCurrentIndex; xft.setHintStyle(hStyle); QString hs(KXftConfig::toStr(hStyle)); if (hs != grp.readEntry("XftHintStyle")) { if (KXftConfig::Hint::NotSet == hStyle) { grp.revertToDefault("XftHintStyle"); } else { grp.writeEntry("XftHintStyle", hs); } } mod = true; kglobals.sync(); if (!mod) { mod = xft.changed(); } xft.apply(); KConfig _cfgfonts("kcmfonts"); KConfigGroup cfgfonts(&_cfgfonts, "General"); if (KWindowSystem::isPlatformWayland()) { cfgfonts.writeEntry("forceFontDPIWayland", m_dpi); } else { cfgfonts.writeEntry("forceFontDPI", m_dpi); } cfgfonts.sync(); #if HAVE_X11 // if the setting is reset in the module, remove the dpi value, // otherwise don't explicitly remove it and leave any possible system-wide value if (m_dpi == 0 && m_dpiOriginal != 0 && !KWindowSystem::isPlatformWayland()) { QProcess proc; proc.setProcessChannelMode(QProcess::ForwardedChannels); proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp"); if (proc.waitForStarted()) { proc.write(QByteArray("Xft.dpi\n")); proc.closeWriteChannel(); proc.waitForFinished(); } } #endif QApplication::processEvents(); // Process font change ourselves // Don't overwrite global settings unless explicitly asked for - e.g. the system // fontconfig setup may be much more complex than this module can provide. // TODO: With AASystem the changes already made by this module should be reverted somehow. #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) if (mod || (m_antiAliasing != m_antiAliasingOriginal) || m_dpi != m_dpiOriginal) { KMessageBox::information(nullptr, i18n( "

Some changes such as anti-aliasing or DPI will only affect newly started applications.

" ), i18n("Font Settings Changed"), "FontSettingsChanged"); m_antiAliasingOriginal = m_antiAliasing; m_dpiOriginal = m_dpi; } #else #if HAVE_X11 if (m_dpi != m_dpiOriginal) { KMessageBox::information(0, i18n( "

Some changes such as DPI will only affect newly started applications.

" ), i18n("Font Settings Changed"), "FontSettingsChanged"); m_dpiOriginal = m_dpi; } #endif #endif m_excludeToOriginal = m_excludeTo; m_excludeFromOriginal = m_excludeFrom; m_subPixelCurrentIndexOriginal = m_subPixelCurrentIndex; m_hintingCurrentIndexOriginal = m_hintingCurrentIndex; return mod; } void FontAASettings::defaults() { setExcludeTo(15); setExcludeFrom(8); setAntiAliasing(1); m_antiAliasingOriginal = m_antiAliasing; setDpi(0); setSubPixelCurrentIndex(KXftConfig::SubPixel::NotSet); setHintingCurrentIndex(KXftConfig::Hint::NotSet); } #endif void FontAASettings::setExclude(bool exclude) { if (exclude == m_exclude) { return; } m_exclude = exclude; emit excludeChanged(); } bool FontAASettings::exclude() const { return m_exclude; } void FontAASettings::setExcludeTo(const int &excludeTo) { if (m_excludeTo == excludeTo) { return; } m_excludeTo = excludeTo; emit excludeToChanged(); } int FontAASettings::excludeTo() const { return m_excludeTo; } void FontAASettings::setExcludeFrom(const int &excludeTo) { if (m_excludeFrom == excludeTo) { return; } m_excludeFrom = excludeTo; emit excludeToChanged(); } int FontAASettings::excludeFrom() const { return m_excludeFrom; } void FontAASettings::setAntiAliasing(const int &antiAliasing) { if (m_antiAliasing == antiAliasing) { return; } m_antiAliasing = antiAliasing; emit aliasingChanged(); } int FontAASettings::antiAliasing() const { return m_antiAliasing; } void FontAASettings::setDpi(const int &dpi) { if (m_dpi == dpi) { return; } m_dpi = dpi; emit dpiChanged(); } int FontAASettings::dpi() const { return m_dpi; } void FontAASettings::setSubPixelCurrentIndex(int idx) { if (m_subPixelCurrentIndex == idx) { return; } m_subPixelCurrentIndex = idx; emit subPixelCurrentIndexChanged(); } int FontAASettings::subPixelCurrentIndex() { return m_subPixelCurrentIndex; } void FontAASettings::setHintingCurrentIndex(int idx) { if (m_hintingCurrentIndex == idx) { return; } m_hintingCurrentIndex = idx; emit hintingCurrentIndexChanged(); } int FontAASettings::hintingCurrentIndex() { return m_hintingCurrentIndex; } bool FontAASettings::needsSave() const { return m_excludeTo != m_excludeToOriginal || m_excludeFrom != m_excludeFromOriginal || m_antiAliasing != m_antiAliasingOriginal || m_dpi != m_dpiOriginal || m_subPixelCurrentIndex != m_subPixelCurrentIndexOriginal || m_hintingCurrentIndex != m_hintingCurrentIndexOriginal; } /**** KFonts ****/ KFonts::KFonts(QObject *parent, const QVariantList &args) : KQuickAddons::ConfigModule(parent, args) , m_fontAASettings(new FontAASettings(this)) { qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - KAboutData* about = new KAboutData("kcm_fonts", i18n("Configure Fonts"), + KAboutData* about = new KAboutData("kcm_fonts", i18n("Configure the system fonts"), "0.1", QString(), KAboutLicense::LGPL); about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); setAboutData(about); qmlRegisterType(); setButtons(Apply | Default | Help); auto updateState = [this]() { setNeedsSave(m_fontAASettings->needsSave()); }; connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState); connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState); connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, updateState); connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, updateState); connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, updateState); connect(m_fontAASettings, &FontAASettings::dpiChanged, this, updateState); } KFonts::~KFonts() { } void KFonts::defaults() { #ifdef Q_OS_MAC setGeneralFont(QFont("Lucida Grande", 13)); setMenuFont(QFont("Lucida Grande", 13)); setFixedWidthFont(QFont("Monaco", 10)); setToolbarFont(QFont("Lucida Grande", 11)); setSmallFont(QFont("Lucida Grande", 9)); setWindowTitleFont(QFont("Lucida Grande", 14)); #else setGeneralFont(QFont("Noto Sans", 10)); setMenuFont(QFont("Noto Sans", 10)); setFixedWidthFont(QFont("Hack", 9)); setToolbarFont(QFont("Noto Sans", 10)); setSmallFont(QFont("Noto Sans", 8)); setWindowTitleFont(QFont("Noto Sans", 10)); #endif m_fontAASettings->defaults(); } void KFonts::load() { KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); KConfigGroup cg(config, "General"); m_generalFont = m_generalFontOriginal = nearestExistingFont(cg.readEntry("font", m_defaultFont)); m_fixedWidthFont = m_fixedWidthFontOriginal = nearestExistingFont(cg.readEntry("fixed", QFont("Hack", 9))); m_smallFont = m_smallFontOriginal = nearestExistingFont(cg.readEntry("smallestReadableFont", m_defaultFont)); m_toolbarFont = m_toolbarFontOriginal = nearestExistingFont(cg.readEntry("toolBarFont", m_defaultFont)); m_menuFont = m_menuFontOriginal = nearestExistingFont(cg.readEntry("menuFont", m_defaultFont)); cg = KConfigGroup(config, "WM"); m_windowTitleFont = m_windowTitleFontOriginal = nearestExistingFont(cg.readEntry("activeFont", m_defaultFont)); engine()->addImageProvider("preview", new PreviewImageProvider(generalFont())); emit generalFontChanged(); emit fixedWidthFontChanged(); emit smallFontChanged(); emit toolbarFontChanged(); emit menuFontChanged(); emit windowTitleFontChanged(); m_fontAASettings->load(); setNeedsSave(false); } void KFonts::save() { KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); KConfigGroup cg(config, "General"); cg.writeEntry("font", m_generalFont.toString()); cg.writeEntry("fixed", m_fixedWidthFont.toString()); cg.writeEntry("smallestReadableFont", m_smallFont.toString()); cg.writeEntry("toolBarFont", m_toolbarFont.toString()); cg.writeEntry("menuFont", m_menuFont.toString()); cg.sync(); cg = KConfigGroup(config, "WM"); cg.writeEntry("activeFont", m_windowTitleFont.toString()); cg.sync(); m_defaultFontOriginal = m_defaultFont; m_generalFontOriginal = m_generalFont; m_fixedWidthFontOriginal = m_fixedWidthFont; m_smallFontOriginal = m_smallFont; m_toolbarFontOriginal = m_toolbarFont; m_menuFontOriginal = m_menuFont; m_windowTitleFontOriginal = m_windowTitleFont; KConfig _cfgfonts("kcmfonts"); KConfigGroup cfgfonts(&_cfgfonts, "General"); FontAASettings::AASetting aaSetting = (FontAASettings::AASetting)m_fontAASettings->antiAliasing(); cfgfonts.writeEntry("dontChangeAASettings", aaSetting == FontAASettings::AASystem); if (aaSetting == FontAASettings::AAEnabled) { m_fontAASettings->save(KXftConfig::AntiAliasing::Enabled); } else if (aaSetting == FontAASettings::AADisabled) { m_fontAASettings->save(KXftConfig::AntiAliasing::Disabled); } else { m_fontAASettings->save(KXftConfig::AntiAliasing::NotSet); } KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged); runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); emit fontsHaveChanged(); setNeedsSave(false); } void KFonts::updateNeedsSave() { setNeedsSave(m_defaultFontOriginal != m_defaultFont || m_generalFontOriginal != m_generalFont || m_fixedWidthFontOriginal != m_fixedWidthFont || m_smallFontOriginal != m_smallFont || m_toolbarFontOriginal != m_toolbarFont || m_menuFontOriginal != m_menuFont || m_windowTitleFontOriginal != m_windowTitleFont || m_fontAASettings->needsSave()); } void KFonts::setGeneralFont(const QFont &font) { if (m_generalFont == font) { return; } m_generalFont = font; emit generalFontChanged(); updateNeedsSave(); } QFont KFonts::generalFont() const { return m_generalFont; } void KFonts::setFixedWidthFont(const QFont &font) { if (m_fixedWidthFont == font) { return; } m_fixedWidthFont = font; emit fixedWidthFontChanged(); updateNeedsSave(); } QFont KFonts::fixedWidthFont() const { return m_fixedWidthFont; } void KFonts::setSmallFont(const QFont &font) { if (m_smallFont == font) { return; } m_smallFont = font; emit smallFontChanged(); updateNeedsSave(); } QFont KFonts::smallFont() const { return m_smallFont; } void KFonts::setToolbarFont(const QFont &font) { if (m_toolbarFont == font) { return; } m_toolbarFont = font; emit toolbarFontChanged(); updateNeedsSave(); } QFont KFonts::toolbarFont() const { return m_toolbarFont; } void KFonts::setMenuFont(const QFont &font) { if (m_menuFont == font) { return; } m_menuFont = font; emit menuFontChanged(); updateNeedsSave(); } QFont KFonts::menuFont() const { return m_menuFont; } void KFonts::setWindowTitleFont(const QFont &font) { if (m_windowTitleFont == font) { return; } m_windowTitleFont = font; emit windowTitleFontChanged(); updateNeedsSave(); } QFont KFonts::windowTitleFont() const { return m_windowTitleFont; } void KFonts::adjustAllFonts() { QFont font = m_generalFont; KFontChooser::FontDiffFlags fontDiffFlags; int ret = KFontDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags); if (ret == KDialog::Accepted && fontDiffFlags) { setGeneralFont(applyFontDiff(m_generalFont, font, fontDiffFlags)); setMenuFont(applyFontDiff(m_menuFont, font, fontDiffFlags)); { const QFont adjustedFont = applyFontDiff(m_fixedWidthFont, font, fontDiffFlags); if (QFontInfo(adjustedFont).fixedPitch()) { setFixedWidthFont(adjustedFont); } } setToolbarFont(applyFontDiff(m_toolbarFont, font, fontDiffFlags)); setSmallFont(applyFontDiff(m_smallFont, font, fontDiffFlags)); setWindowTitleFont(applyFontDiff(m_windowTitleFont, font, fontDiffFlags)); } } QFont KFonts::applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags) { QFont font(fnt); if (fontDiffFlags & KFontChooser::FontDiffSize) { font.setPointSizeF(newFont.pointSizeF()); } if ((fontDiffFlags & KFontChooser::FontDiffFamily)) { font.setFamily(newFont.family()); } if (fontDiffFlags & KFontChooser::FontDiffStyle) { font.setWeight(newFont.weight()); font.setStyle(newFont.style()); font.setUnderline(newFont.underline()); font.setStyleName(newFont.styleName()); } return font; } #include "fonts.moc" diff --git a/kcms/fonts/kcm_fonts.desktop b/kcms/fonts/kcm_fonts.desktop index 310653488..3bb48d393 100644 --- a/kcms/fonts/kcm_fonts.desktop +++ b/kcms/fonts/kcm_fonts.desktop @@ -1,199 +1,199 @@ [Desktop Entry] Exec=kcmshell5 fonts Icon=preferences-desktop-font Type=Service X-KDE-ServiceTypes=KCModule X-DocPath=kcontrol/fonts/index.html X-KDE-Library=kcm_fonts X-KDE-ParentApp=kcontrol X-KDE-System-Settings-Parent-Category=font X-KDE-Weight=50 Name=Fonts Name[af]=Skriftipes Name[ar]=الخطوط Name[be]=Шрыфты Name[be@latin]=Šryfty Name[bg]=Шрифтове Name[bn]=ফন্ট Name[bn_IN]=ফন্ট Name[br]=Fontoù Name[bs]=Fontovi Name[ca]=Tipus de lletra Name[ca@valencia]=Tipus de lletra Name[cs]=Písma Name[csb]=Fòntë Name[cy]=Ffontiau Name[da]=Skrifttyper Name[de]=Schriftarten Name[el]=Γραμματοσειρές Name[en_GB]=Fonts Name[eo]=Tiparoj Name[es]=Tipos de letra Name[et]=Fondid Name[eu]=Letra-tipoak Name[fa]=قلمها Name[fi]=Fontit Name[fr]=Polices de caractères Name[fy]=Lettertypen Name[ga]=Clónna Name[gl]=Tipos de letra Name[gu]=ફોન્ટ્સ Name[he]=גופנים Name[hi]=फ़ॉन्ट्स Name[hne]=फोंट Name[hr]=Fontovi Name[hsb]=Pisma Name[hu]=Betűtípusok Name[ia]=Fontes Name[id]=Font Name[is]=Letur Name[it]=Caratteri Name[ja]=フォント Name[ka]=ფონტები Name[kk]=Қаріптер Name[km]=ពុម្ព​អក្សរ Name[kn]=ಅಕ್ಷರಶೈಲಿಗಳು Name[ko]=글꼴 Name[ku]=Curenivîs Name[lt]=Šriftai Name[lv]=Fonti Name[mai]=फान्ट Name[mk]=Фонтови Name[ml]=അക്ഷരസഞ്ചയങ്ങള്‍ Name[mr]=फॉन्ट Name[ms]=Fon Name[nb]=Skrifttyper Name[nds]=Schriftoorden Name[ne]=फन्ट Name[nl]=Lettertypen Name[nn]=Skrifter Name[oc]=Poliças Name[or]=ଅକ୍ଷର ରୂପ Name[pa]=ਫੋਂਟ Name[pl]=Czcionki Name[pt]=Tipos de Letra Name[pt_BR]=Fontes Name[ro]=Fonturi Name[ru]=Шрифты Name[se]=Fonttat Name[si]=අකුරු Name[sk]=Písma Name[sl]=Pisave Name[sr]=Фонтови Name[sr@ijekavian]=Фонтови Name[sr@ijekavianlatin]=Fontovi Name[sr@latin]=Fontovi Name[sv]=Teckensnitt Name[ta]=எழுத்துருக்கள் Name[te]=ఫాంట్‍స్ Name[tg]=Ҳарфҳо Name[th]=แบบอักษรต่างๆ Name[tr]=Yazı Tipleri Name[ug]=خەت نۇسخىلىرى Name[uk]=Шрифти Name[uz]=Shriftlar Name[uz@cyrillic]=Шрифтлар Name[vi]=Phông chữ Name[wa]=Fontes Name[xh]=Uhlobo lwamagama Name[x-test]=xxFontsxx Name[zh_CN]=字体 Name[zh_TW]=字型 -Comment=Fonts +Comment=Configure the system fonts Comment[ar]=الخطوط Comment[bs]=Fontovi Comment[ca]=Tipus de lletra Comment[ca@valencia]=Tipus de lletra Comment[cs]=Písma Comment[da]=Skrifttyper Comment[de]=Schriftarten Comment[el]=Γραμματοσειρές Comment[en_GB]=Fonts Comment[eo]=Tiparoj Comment[es]=Tipos de letra Comment[et]=Fondid Comment[eu]=Letra-tipoak Comment[fi]=Fontit Comment[fr]=Polices de caractères Comment[gl]=Tipos de letra Comment[he]=גופנים Comment[hu]=Betűtípusok Comment[id]=Font Comment[is]=Letur Comment[it]=Caratteri Comment[ja]=フォント Comment[ko]=글꼴 Comment[lt]=Šriftai Comment[mr]=फॉन्ट Comment[nb]=Skrifttype Comment[nds]=Schriftoorden Comment[nl]=Lettertypen Comment[nn]=Skrifter Comment[pa]=ਫੋਂਟ Comment[pl]=Czcionki Comment[pt]=Tipos de Letra Comment[pt_BR]=Fontes Comment[ru]=Шрифты Comment[sk]=Písma Comment[sl]=Pisave Comment[sr]=Фонтови Comment[sr@ijekavian]=Фонтови Comment[sr@ijekavianlatin]=Fontovi Comment[sr@latin]=Fontovi Comment[sv]=Teckensnitt Comment[tr]=Yazı Tipleri Comment[uk]=Шрифти Comment[x-test]=xxFontsxx Comment[zh_CN]=字体 Comment[zh_TW]=字型 X-KDE-Keywords=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[ar]=خطوط,حجم الخط,أنماط,طقم محارف,طقوم محارف,لوحة,لوحة تحكّم,أسطح المكتب,مدير ملفات,أشرطة أدوات,قائمة,عنوان نافذة,عنوان,نقطة/بوصة,DPI,إزالة التسنّن,خطوط سطح المكتب,خطوط شريط الأدوات,محرف,خطوط عامة X-KDE-Keywords[bs]=slova,veličina slova,stil,znakovi,postaviti znakove,ploča,kontrolna ploča,pozadina,upravitelj datoteka,alatne trake,meni,naslov prozora,naslov,DPI,niskopropusni,slova pozadine,slova na alatnoj traci,obilježja,opći fontovi X-KDE-Keywords[ca]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de la finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general X-KDE-Keywords[ca@valencia]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de la finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general X-KDE-Keywords[da]=skrifttyper,skriftstørrelse,stile,tegnsæt,panel,kontrolpanel,skriveborde,filhåndtering,værktøjslinjer,menu,vinduestitel,titel,DPI,anti-aliasing,værktøjslinjer,tegn X-KDE-Keywords[de]=Schriftarten,Schriftgrößen,Stile,Zeichensätze,Kontrollleiste,Stile,Dateiverwaltung,Arbeitsflächen,Werkzeugleisten,Menüs,Fenstertitel,Titel,DPI,Antialiasing,Arbeitsflächenschriften,Werkzeugleistenschriften,Zeichen,Allgemeine Schriftarten X-KDE-Keywords[el]=γραμματοσειρές,μέγεθος γραμματοσειράς,στιλ,σύνολα χαρακτήρων,πίνακας,πίνακας ελέγχου,επιφάνειες εργασίας,διαχειριστής αρχείων,γραμμές εργαλείων,μενού,τίτλος παραθύρου,τίτλος,DPI,εξομάλυνση,γραμματοσειρές επιφάνειας εργασίας,γραμματοσειρές γραμμής εργαλείων,χαρακτήρας,γενικές γραμματοσειρές X-KDE-Keywords[en_GB]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[es]=tipos de letra,tamaño del tipo de letra,estilos,juegos de caracteres,panel,panel de control panel,escritorios,Gestor de archivos,Barras de herramientas,Menú,Título de la ventana,Título,DPI,suavizado de texto,tipos de letra del escritorio,tipos de letra de las barras de herramientas,carácter,tipos de letra generales X-KDE-Keywords[et]=fondid,fondi suurus,kodeering,kooditabel,paneel,juhtpaneel,töölauad,failihaldur,tööriistaribad,menüü,aken,tiitel,nimetus,nimi,DPI,antialias,töölaua fondid,tööriistariba fondid,märk,märgid,sümbolid,üldised fondid X-KDE-Keywords[eu]=letra-tipoak,letra-tamaina,estiloak,karaktere-jokoak,panela,kontrol-panela,mahaigain,fitxategi-kudeatzaile,tresna-barra,menu,leihoaren titulu,titulu,DPI,antialiasing,mahaigaineko letra-tripo,tresna-barrako letra-tipo,karaktere,letra-tipo orokor X-KDE-Keywords[fi]=kirjasimet,fontit,kirjasinkoko,fonttikoko,tyylit,merkistöt,paneeli,ohjauskeskus,työpöydät,Tiedostonhallinta,Työkalurivit,Työkalupalkit,Valikko,Ikkunan otsikko,Otsikko,DPI,antialiasointi,työpöytäkirjasimet,työpöytäfontit,työkalurivikirjasimet, työkalurivien kirjasimet, työkalurivifontit, työkalurivien fontit,merkki,yleiskirjasimet,yleiset kirjasimet,yleisfontit,yleiset fontit X-KDE-Keywords[fr]=polices, taille de police, styles, tables de caractères, jeux de caractères, tableau de bord, bureaux, Gestionnaire de Fichiers, Barre d'outils, Menu, Titre de fenêtre, Titre, DPI, anti crénelage, polices du bureau, police de barre d'outils, caractère, polices générales X-KDE-Keywords[ga]=clónna,clófhoirne,clómhéid,stíleanna,tacair charachtar,painéal,painéal rialaithe,deasca,Bainisteoir Comhad,Barraí Uirlisí,Roghchlár,Teideal Fuinneoige,Teideal,PSO,frithailiasáil,clónna deisce,clófhoirne deisce,clónna barra uirlisí,carachtar,clónna ginearálta,clófhoirne ginearálta X-KDE-Keywords[gl]=tipo de letra,letra,tamaño de letra,tamaño da letra,codificacións de caracteres,conxuntos de caracteres,panel,control,panel de control,escritorios,xestor de ficheiros,barras de ferramentas,menú,título de xanela,título,DPI,PPP,antialiasing,suavizado,tipos de letra do escritorio,tipos de letra das barras de ferramentas,carácter,tipos de letra xerais X-KDE-Keywords[hu]=betűkészletek,betűméret,stílusok,karakterkészletek,karakterkészletek,panel,beállítópanel,asztalok,Fájlkezelő,Eszköztárak,Menü,Ablakcím,Cím,DPI,élsimítás,asztal betűkészletek,eszköztár betűkészletek,karakter,általános betűkészletek X-KDE-Keywords[ia]=fonts,grandor de font,stilos,insimules de characteres,insimules de characteres,pannello,pannello de controlo,scriptorios,Gerente de File,Barra de instrumentos,menu,Titulo de Fenestra,Titulo,DPI,anti-aliasing,fonts de scriptorio, fonts de barra de titulo, character,fonts general X-KDE-Keywords[id]=fon,ukuran fon,gaya,charset,set karakter,panel,panel kendali,desktop,FileManager,Bilah Alat,Menu,Judul Window,Judul,DPI,anti-alias,font desktop,font bilah alat,karakter,font umum X-KDE-Keywords[it]=caratteri,dimensione dei caratteri,stili,codifiche,insiemi di caratteri,pannello,pannello di controllo,desktop,gestore dei file,barre degli strumenti,menu,titolo della finestra,titolo,DPI,anti-aliasing,caratteri del desktop,caratteri della barra degli strumenti,carattere,caratteri generali X-KDE-Keywords[kk]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[km]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[ko]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,글꼴,스타일,창 제목,글자 X-KDE-Keywords[mr]=फॉन्ट्स, फॉन्ट साईज, कॅरेक्टर, कॅरेक्टर सेटस, पँनल, कन्ट्रोल पँनल, डेस्कटॉप्स, फाईल मेनेजर, टूलबार्स, मेन्यू, चौकट टाईटल, टाईटल, डी पी आय , अन्टी अलायझिंग, डेस्कटॉप फॉन्टस, टूलबार फॉन्टस, कॅरेक्टर, जनरल फॉन्ट्स X-KDE-Keywords[nb]=skrifter,skriftstørrelse,stiler,tegnsett,panel,kontrollpanel,skrivebord,filbehandler,Verktøylinje,Meny,Vindiustittel,tittel,DPI,kantutjevning,skrivebordsskrifter,verktøylinjeskrifter,generelle skrifter X-KDE-Keywords[nds]=Schriftoorden,Schrift,Stilen,Tekensetten,Paneel,Stüerpaneel,Schriefdisch,Dateipleger,Warktüüchbalkens,Menü,Finstertitel,Titel,DPI,Kantstreken,anti-aliasing,Schriefdisch,Teken X-KDE-Keywords[nl]=lettertypes,lettertype,tekengrootte,stijlen,tekensets,paneel,besturingspaneel,bureaubladen,bestandsbeheerder,werkbalken,menu,venstertitel,titel,DPI,anti-aliasing,lettertypen van bureaublad,lettertypen van werkbalk,teken,algemene lettertypes X-KDE-Keywords[nn]=skrifter,skriftstorleik,stilar,teiknsett,teiknkodingar,panel,kontrollpanel,skrivebord,filhandsamar,verktøylinje,meny,vindaugstittel,tittel,DPI,PPT,kantutjamning,skrivebordsskrifter,verktøylinjeskrifter,generelle skriftar X-KDE-Keywords[pl]=czcionki,rozmiar czcionki,style,zestaw znaków,panel,panel sterowania,pulpity,Menadżer plików,Paski narzędzi,Menu,Tytuł okna,Tytuł,DPI,wygładzanie,czcionki pulpitu,czcionki pasków narzędzi,znak,czcionki ogólne X-KDE-Keywords[pt]=tipos de letra,tamanho de letra,estilos,codificações,codificações de caracteres,painel,painel de controlo,ecrãs,gestor de ficheiros,barras de ferramentas,menu,título da janela,título,PPP,suavização,tipos de letra do ecrã,tipos de letra da barra de ferramentas,carácter,tipos de letra gerais X-KDE-Keywords[pt_BR]=fontes,tamanho da fonte,estilos,codificações,codificações de caracteres,painel,painel de controle,áreas de trabalho,gerenciador de arquivos,barras de ferramentas,Menu,Título da janela,Título,PPP,anti-aliasing,fontes da área de trabalho,fontes da barra de ferramentas,caractere,fontes gerais X-KDE-Keywords[ru]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,шрифты,размер шрифтов,стили,кодировки,панель,панель управления,рабочие столы,диспетчер файлов,панель инструментов,меню,заголовок окна,заголовок,сглаживание,шрифты рабочего стола,шрифты панели инструментов,символы,общие шрифты X-KDE-Keywords[sk]=písmo,veľkosť písma,štýly,znakové sady,sady znakov,panel,ovládací panel,plochy,Správca súborov,Panely nástrojov,Ponuka,Titulok okna,Titulok,DPI,anti-aliasing,písma plochy,písma nástrojových panelov,znak,všeobecné písma X-KDE-Keywords[sl]=pisave,velikost pisav,slogi,nabori znakov,znakovni nabori,pult,nadzorna plošča,namizja,upravljalnik datotek,datotečni upravljalnik,orodjarne,orodne vrstice,meni,naslov okna,naslovna vrstica,naslov,ločljivost,točk na palec,glajenje robov,namizne pisave,pisave namizja,pisave orodjarne, pisave orodne vrstice,znak,splošne pisave X-KDE-Keywords[sr]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,фонт,величина фонта,стил,кодирање,панел,контролни панел,површ,менаџер фајлова,траке алатки,мени,наслов прозора,тпи,омекшавање,фонт површи,фонт траке алатки,знакови,општи фонт X-KDE-Keywords[sr@ijekavian]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,фонт,величина фонта,стил,кодирање,панел,контролни панел,површ,менаџер фајлова,траке алатки,мени,наслов прозора,тпи,омекшавање,фонт површи,фонт траке алатки,знакови,општи фонт X-KDE-Keywords[sr@ijekavianlatin]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,font,veličina fonta,stil,kodiranje,panel,kontrolni panel,površ,menadžer fajlova,trake alatki,meni,naslov prozora,tpi,omekšavanje,font površi,font trake alatki,znakovi,opšti font X-KDE-Keywords[sr@latin]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,font,veličina fonta,stil,kodiranje,panel,kontrolni panel,površ,menadžer fajlova,trake alatki,meni,naslov prozora,tpi,omekšavanje,font površi,font trake alatki,znakovi,opšti font X-KDE-Keywords[sv]=teckensnitt,teckenstorlek,stil,teckenuppsättningar,panel,kontrollpanel,skrivbord,Filhanterare,Verktygsrader,Meny,Fönsternamn,Namn,Punkter/tum,kantutjämning,skrivbordsteckensnitt,verktygsradsteckensnitt,tecken,allmänna teckensnitt X-KDE-Keywords[tr]=yazı tipi,yazı tipi boyutu,karakterler,karakter setleri,panel,denetim paneli,masaüstleri,Dosya Yöneticisi,Araç Çubukları,Menü,Pencere Başlığı,Başlık,DPI,yumuşatma,anti-aliasing,masaüstü yazı tipleri,araç çubuğu yazı tipleri,karakter,genel yazı tipleri,biçemler X-KDE-Keywords[uk]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,шрифт,шрифти,розмір,розмір шрифту,стиль,стилі,гарнітура,гарнітури,кодування,набір,символ,символи,набір символів,панель,панель керування,стільниця,стільниці,файл,керування,керування файлами,менеджер,панель інструментів,меню,заголовок,заголовок вікна,роздільність,згладжування,шрифти стільниці,шрифти панелі,символ,загальні шрифти X-KDE-Keywords[x-test]=xxfontsxx,xxfont sizexx,xxstylesxx,xxcharsetsxx,xxcharacter setsxx,xxpanelxx,xxcontrol panelxx,xxdesktopsxx,xxFileManagerxx,xxToolbarsxx,xxMenuxx,xxWindow Titlexx,xxTitlexx,xxDPIxx,xxanti-aliasingxx,xxdesktop fontsxx,xxtoolbar fontsxx,xxcharacterxx,xxgeneral fontsxx X-KDE-Keywords[zh_CN]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,字体字体大小,样式,字符集,面板,控制面板,桌面,文件管理器,工具栏,菜单,窗口标题,标题,反锯齿,桌面字体,工具栏字体,字符,常规字体 X-KDE-Keywords[zh_TW]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/kcms/fonts/kxftconfig.cpp b/kcms/fonts/kxftconfig.cpp index d441fb27f..cd4423557 100644 --- a/kcms/fonts/kxftconfig.cpp +++ b/kcms/fonts/kxftconfig.cpp @@ -1,827 +1,827 @@ /* Copyright (c) 2002 Craig Drummond This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kxftconfig.h" #ifdef HAVE_FONTCONFIG #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; static int point2Pixel(double point) { return (int)(((point * QX11Info::appDpiY()) / 72.0) + 0.5); } static int pixel2Point(double pixel) { return (int)(((pixel * 72.0) / (double)QX11Info::appDpiY()) + 0.5); } static bool equal(double d1, double d2) { return (fabs(d1 - d2) < 0.0001); } static QString dirSyntax(const QString &d) { if (!d.isNull()) { QString ds(d); ds.replace("//", "/"); int slashPos = ds.lastIndexOf('/'); if (slashPos != (((int)ds.length()) - 1)) { ds.append('/'); } return ds; } return d; } inline bool fExists(const QString &p) { return QFileInfo(p).isFile(); } inline bool dWritable(const QString &p) { QFileInfo info(p); return info.isDir() && info.isWritable(); } static QString getDir(const QString &f) { QString d(f); int slashPos = d.lastIndexOf('/'); if (-1 != slashPos) { d.remove(slashPos + 1, d.length()); } return dirSyntax(d); } static QDateTime getTimeStamp(const QString &item) { return QFileInfo(item).lastModified(); } // // Obtain location of config file to use. QString getConfigFile() { FcStrList *list = FcConfigGetConfigFiles(FcConfigGetCurrent()); QStringList files; FcChar8 *file; QString home(dirSyntax(QDir::homePath())); while ((file = FcStrListNext(list))) { QString f((const char *)file); if (fExists(f) && 0 == f.indexOf(home)) { files.append(f); } } FcStrListDone(list); // // Go through list of files, looking for the preferred one... if (!files.isEmpty()) { QStringList::const_iterator it(files.begin()), end(files.end()); for (; it != end; ++it) if (-1 != (*it).indexOf(QRegExp("/\\.?fonts\\.conf$"))) { return *it; } return files.front(); // Just return the 1st one... } else { // Hmmm... no known files? if (FcGetVersion() >= 21000) { QString targetPath(KGlobal::dirs()->localxdgconfdir() + "fontconfig"); QDir target(targetPath); if (!target.exists()) { target.mkpath(targetPath); } return targetPath + "/fonts.conf"; } else { return home + "/.fonts.conf"; } } } static QString getEntry(QDomElement element, const char *type, unsigned int numAttributes, ...) { if (numAttributes == element.attributes().length()) { va_list args; unsigned int arg; bool ok = true; va_start(args, numAttributes); for (arg = 0; arg < numAttributes && ok; ++arg) { const char *attr = va_arg(args, const char *); const char *val = va_arg(args, const char *); if (!attr || !val || val != element.attribute(attr)) { ok = false; } } va_end(args); if (ok) { QDomNode n = element.firstChild(); if (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull() && type == e.tagName()) { return e.text(); } } } } return QString(); } static KXftConfig::SubPixel::Type strToType(const char *str) { if (0 == strcmp(str, "rgb")) { return KXftConfig::SubPixel::Rgb; } else if (0 == strcmp(str, "bgr")) { return KXftConfig::SubPixel::Bgr; } else if (0 == strcmp(str, "vrgb")) { return KXftConfig::SubPixel::Vrgb; } else if (0 == strcmp(str, "vbgr")) { return KXftConfig::SubPixel::Vbgr; } else if (0 == strcmp(str, "none")) { return KXftConfig::SubPixel::None; } else { return KXftConfig::SubPixel::NotSet; } } static KXftConfig::Hint::Style strToStyle(const char *str) { if (0 == strcmp(str, "hintslight")) { return KXftConfig::Hint::Slight; } else if (0 == strcmp(str, "hintmedium")) { return KXftConfig::Hint::Medium; } else if (0 == strcmp(str, "hintfull")) { return KXftConfig::Hint::Full; } else { return KXftConfig::Hint::None; } } KXftConfig::KXftConfig() : m_doc("fontconfig") , m_file(getConfigFile()) { qDebug() << "Using fontconfig file:" << m_file; reset(); } KXftConfig::~KXftConfig() { } bool KXftConfig::reset() { bool ok = false; m_madeChanges = false; m_hint.reset(); m_hinting.reset(); m_excludeRange.reset(); m_excludePixelRange.reset(); m_subPixel.reset(); m_antiAliasing.reset(); QFile f(m_file); if (f.open(QIODevice::ReadOnly)) { m_time = getTimeStamp(m_file); ok = true; m_doc.clear(); if (m_doc.setContent(&f)) { readContents(); } f.close(); } else { ok = !fExists(m_file) && dWritable(getDir(m_file)); } if (m_doc.documentElement().isNull()) { m_doc.appendChild(m_doc.createElement("fontconfig")); } if (ok) { // // Check exclude range values - i.e. size and pixel size... // If "size" range is set, ensure "pixelsize" matches... if (!equal(0, m_excludeRange.from) || !equal(0, m_excludeRange.to)) { double pFrom = (double)point2Pixel(m_excludeRange.from), pTo = (double)point2Pixel(m_excludeRange.to); if (!equal(pFrom, m_excludePixelRange.from) || !equal(pTo, m_excludePixelRange.to)) { m_excludePixelRange.from = pFrom; m_excludePixelRange.to = pTo; m_madeChanges = true; } } else if (!equal(0, m_excludePixelRange.from) || !equal(0, m_excludePixelRange.to)) { // "pixelsize" set, but not "size" !!! m_excludeRange.from = (int)pixel2Point(m_excludePixelRange.from); m_excludeRange.to = (int)pixel2Point(m_excludePixelRange.to); m_madeChanges = true; } } return ok; } bool KXftConfig::apply() { bool ok = true; if (m_madeChanges) { // // Check if file has been written since we last read it. If it has, then re-read and add any // of our changes... if (fExists(m_file) && getTimeStamp(m_file) != m_time) { KXftConfig newConfig; newConfig.setExcludeRange(m_excludeRange.from, m_excludeRange.to); newConfig.setSubPixelType(m_subPixel.type); newConfig.setHintStyle(m_hint.style); newConfig.setAntiAliasing(m_antiAliasing.state); ok = newConfig.changed() ? newConfig.apply() : true; if (ok) { reset(); } else { m_time = getTimeStamp(m_file); } } else { // Ensure these are always equal... m_excludePixelRange.from = (int)point2Pixel(m_excludeRange.from); m_excludePixelRange.to = (int)point2Pixel(m_excludeRange.to); FcAtomic *atomic = FcAtomicCreate((const unsigned char *)(QFile::encodeName(m_file).data())); ok = false; if (atomic) { if (FcAtomicLock(atomic)) { FILE *f = fopen((char *)FcAtomicNewFile(atomic), "w"); if (f) { applySubPixelType(); applyHintStyle(); applyAntiAliasing(); applyExcludeRange(false); applyExcludeRange(true); // // Check document syntax... static const char qtXmlHeader[] = ""; static const char xmlHeader[] = ""; static const char qtDocTypeLine[] = ""; static const char docTypeLine[] = ""; QString str(m_doc.toString()); int idx; if (0 != str.indexOf("= 0 || to >= 0) && foundFalse) { m_excludeRange.from = from < to ? from : to; m_excludeRange.to = from < to ? to : from; m_excludeRange.node = n; } else if ((pixelFrom >= 0 || pixelTo >= 0) && foundFalse) { m_excludePixelRange.from = pixelFrom < pixelTo ? pixelFrom : pixelTo; m_excludePixelRange.to = pixelFrom < pixelTo ? pixelTo : pixelFrom; m_excludePixelRange.node = n; } } break; default: break; } } } n = n.nextSibling(); } } void KXftConfig::applySubPixelType() { if (SubPixel::NotSet == m_subPixel.type) { if (!m_subPixel.node.isNull()) { m_doc.documentElement().removeChild(m_subPixel.node); m_subPixel.node.clear(); } } else { QDomElement matchNode = m_doc.createElement("match"); QDomElement typeNode = m_doc.createElement("const"); QDomElement editNode = m_doc.createElement("edit"); QDomText typeText = m_doc.createTextNode(toStr(m_subPixel.type)); matchNode.setAttribute("target", "font"); editNode.setAttribute("mode", "assign"); editNode.setAttribute("name", "rgba"); editNode.appendChild(typeNode); typeNode.appendChild(typeText); matchNode.appendChild(editNode); if (m_subPixel.node.isNull()) { m_doc.documentElement().appendChild(matchNode); } else { m_doc.documentElement().replaceChild(matchNode, m_subPixel.node); } m_subPixel.node = matchNode; } } void KXftConfig::applyHintStyle() { applyHinting(); if (Hint::NotSet == m_hint.style) { if (!m_hint.node.isNull()) { m_doc.documentElement().removeChild(m_hint.node); m_hint.node.clear(); } if (!m_hinting.node.isNull()) { m_doc.documentElement().removeChild(m_hinting.node); m_hinting.node.clear(); } } else { QDomElement matchNode = m_doc.createElement("match"), typeNode = m_doc.createElement("const"), editNode = m_doc.createElement("edit"); QDomText typeText = m_doc.createTextNode(toStr(m_hint.style)); matchNode.setAttribute("target", "font"); editNode.setAttribute("mode", "assign"); editNode.setAttribute("name", "hintstyle"); editNode.appendChild(typeNode); typeNode.appendChild(typeText); matchNode.appendChild(editNode); if (m_hint.node.isNull()) { m_doc.documentElement().appendChild(matchNode); } else { m_doc.documentElement().replaceChild(matchNode, m_hint.node); } m_hint.node = matchNode; } } void KXftConfig::applyHinting() { QDomElement matchNode = m_doc.createElement("match"), typeNode = m_doc.createElement("bool"), editNode = m_doc.createElement("edit"); QDomText typeText = m_doc.createTextNode(m_hinting.set ? "true" : "false"); matchNode.setAttribute("target", "font"); editNode.setAttribute("mode", "assign"); editNode.setAttribute("name", "hinting"); editNode.appendChild(typeNode); typeNode.appendChild(typeText); matchNode.appendChild(editNode); if (m_hinting.node.isNull()) { m_doc.documentElement().appendChild(matchNode); } else { m_doc.documentElement().replaceChild(matchNode, m_hinting.node); } m_hinting.node = matchNode; } void KXftConfig::applyExcludeRange(bool pixel) { Exclude &range = pixel ? m_excludePixelRange : m_excludeRange; if (equal(range.from, 0) && equal(range.to, 0)) { if (!range.node.isNull()) { m_doc.documentElement().removeChild(range.node); range.node.clear(); } } else { QString fromString, toString; fromString.setNum(range.from); toString.setNum(range.to); QDomElement matchNode = m_doc.createElement("match"), fromTestNode = m_doc.createElement("test"), fromNode = m_doc.createElement("double"), toTestNode = m_doc.createElement("test"), toNode = m_doc.createElement("double"), editNode = m_doc.createElement("edit"), boolNode = m_doc.createElement("bool"); QDomText fromText = m_doc.createTextNode(fromString), toText = m_doc.createTextNode(toString), boolText = m_doc.createTextNode("false"); matchNode.setAttribute("target", "font"); // CPD: Is target "font" or "pattern" ???? fromTestNode.setAttribute("qual", "any"); fromTestNode.setAttribute("name", pixel ? "pixelsize" : "size"); fromTestNode.setAttribute("compare", "more_eq"); fromTestNode.appendChild(fromNode); fromNode.appendChild(fromText); toTestNode.setAttribute("qual", "any"); toTestNode.setAttribute("name", pixel ? "pixelsize" : "size"); toTestNode.setAttribute("compare", "less_eq"); toTestNode.appendChild(toNode); toNode.appendChild(toText); editNode.setAttribute("mode", "assign"); editNode.setAttribute("name", "antialias"); editNode.appendChild(boolNode); boolNode.appendChild(boolText); matchNode.appendChild(fromTestNode); matchNode.appendChild(toTestNode); matchNode.appendChild(editNode); if (!m_antiAliasing.node.isNull()) { m_doc.documentElement().removeChild(range.node); } m_doc.documentElement().appendChild(matchNode); range.node = matchNode; } } KXftConfig::AntiAliasing::State KXftConfig::getAntiAliasing() const { return m_antiAliasing.state; } void KXftConfig::setAntiAliasing(AntiAliasing::State state) { if (state != m_antiAliasing.state) { m_antiAliasing.state = state; m_madeChanges = true; } } void KXftConfig::applyAntiAliasing() { if (AntiAliasing::NotSet == m_antiAliasing.state) { if (!m_antiAliasing.node.isNull()) { m_doc.documentElement().removeChild(m_antiAliasing.node); m_antiAliasing.node.clear(); } } else { QDomElement matchNode = m_doc.createElement("match"); QDomElement typeNode = m_doc.createElement("bool"); QDomElement editNode = m_doc.createElement("edit"); QDomText typeText = m_doc.createTextNode(m_antiAliasing.state == AntiAliasing::Enabled ? "true" : "false"); matchNode.setAttribute("target", "font"); editNode.setAttribute("mode", "assign"); editNode.setAttribute("name", "antialias"); editNode.appendChild(typeNode); typeNode.appendChild(typeText); matchNode.appendChild(editNode); if (!m_antiAliasing.node.isNull()) { m_doc.documentElement().removeChild(m_antiAliasing.node); } m_doc.documentElement().appendChild(matchNode); m_antiAliasing.node = matchNode; } } // KXftConfig only parses one config file, user's .fonts.conf usually. // If that one doesn't exist, then KXftConfig doesn't know if antialiasing // is enabled or not. So try to find out the default value from the default font. // Maybe there's a better way *shrug*. bool KXftConfig::aliasingEnabled() { FcPattern *pattern = FcPatternCreate(); FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result; FcPattern *f = FcFontMatch(nullptr, pattern, &result); FcBool antialiased = FcTrue; FcPatternGetBool(f, FC_ANTIALIAS, 0, &antialiased); FcPatternDestroy(f); FcPatternDestroy(pattern); return antialiased == FcTrue; } #endif diff --git a/kcms/fonts/package/contents/ui/FontWidget.qml b/kcms/fonts/package/contents/ui/FontWidget.qml index c1aaf181c..b62dd3bf4 100644 --- a/kcms/fonts/package/contents/ui/FontWidget.qml +++ b/kcms/fonts/package/contents/ui/FontWidget.qml @@ -1,69 +1,74 @@ /* Copyright (c) 2015 Antonis Tsiapaliokas Copyright (c) 2017 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 as QtControls import QtQuick.Dialogs 1.2 as QtDialogs import org.kde.kirigami 2.3 as Kirigami import org.kde.kcm 1.0 FocusScope { id: root property string label property string category property font font Kirigami.FormData.label: root.label activeFocusOnTab: true Layout.minimumWidth: layout.Layout.minimumWidth Layout.preferredWidth: layout.Layout.preferredWidth Layout.minimumHeight: layout.Layout.minimumHeight Layout.preferredHeight: layout.Layout.preferredHeight implicitWidth: layout.implicitWidth implicitHeight: layout.implicitHeight RowLayout { id: layout QtControls.TextField { readOnly: true Kirigami.Theme.inherit: true - text: root.font.family + " " + root.font.pointSize + text: root.font.family + " " + root.font.pointSize + "pt" font: root.font Layout.fillHeight: true } QtControls.Button { - text: i18n("Choose...") + icon.name: "document-edit" Layout.fillHeight: true Kirigami.MnemonicData.enabled: false focus: true onClicked: { fontDialog.adjustAllFonts = false; fontDialog.currentCategory = root.category fontDialog.font = root.font; fontDialog.currentFont = root.font; fontDialog.open() } + QtControls.ToolTip { + visible: parent.hovered + text: i18n("Select %1 Font...", label.replace(':', '')) + font.capitalization: Font.Capitalize + } } } } diff --git a/kcms/fonts/package/contents/ui/main.qml b/kcms/fonts/package/contents/ui/main.qml index 9097be829..408baf5ef 100644 --- a/kcms/fonts/package/contents/ui/main.qml +++ b/kcms/fonts/package/contents/ui/main.qml @@ -1,247 +1,252 @@ /* Copyright (c) 2015 Antonis Tsiapaliokas Copyright (c) 2017 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 as QtControls import QtQuick.Dialogs 1.2 as QtDialogs import org.kde.kirigami 2.3 as Kirigami import org.kde.kcm 1.1 as KCM KCM.SimpleKCM { id: root - KCM.ConfigModule.quickHelp: i18n("Fonts") + KCM.ConfigModule.quickHelp: i18n("This module lets you configure the system fonts.") Kirigami.FormLayout { id: formLayout readonly property int maxImplicitWidth: Math.max(adjustAllFontsButton.implicitWidth, Math.max(antiAliasingComboBox.implicitWidth, Math.max(excludeField.implicitWidth, Math.max(subPixelCombo.implicitWidth, hintingCombo.implicitWidth)))) QtControls.Button { id: adjustAllFontsButton Layout.preferredWidth: formLayout.maxImplicitWidth + icon.name: "font-select-symbolic" text: i18n("&Adjust All Fonts...") onClicked: kcm.adjustAllFonts(); } FontWidget { id: generalFontWidget label: i18n("General:") category: "generalFont" font: kcm.generalFont } FontWidget { label: i18n("Fixed width:") category: "fixedWidthFont" font: kcm.fixedWidthFont } FontWidget { label: i18n("Small:") category: "smallFont" font: kcm.smallFont } FontWidget { label: i18n("Toolbar:") category: "toolbarFont" font: kcm.toolbarFont } FontWidget { label: i18n("Menu:") category: "menuFont" font: kcm.menuFont } FontWidget { label: i18n("Window title:") category: "windowTitleFont" font: kcm.windowTitleFont } Kirigami.Separator { Kirigami.FormData.isSection: true } QtControls.ComboBox { id: antiAliasingComboBox Layout.preferredWidth: formLayout.maxImplicitWidth Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Anti-aliasing:") - model: [i18n("Enabled"), i18n("Vendor Default"), i18n("Disabled")] + model: [i18n("Enabled"), i18n("Vendor default"), i18n("Disabled")] currentIndex: kcm.fontAASettings.antiAliasing onCurrentIndexChanged: kcm.fontAASettings.antiAliasing = antiAliasingComboBox.currentIndex } QtControls.CheckBox { id: excludeCheckBox checked: kcm.fontAASettings.exclude onCheckedChanged: kcm.fontAASettings.exclude = checked; text: i18n("Exclude range from anti-aliasing") Layout.fillWidth: true enabled: antiAliasingComboBox.currentIndex == 0 } RowLayout { id: excludeField - Layout.preferredWidth: formLayout.maxImplicitWidth enabled: antiAliasingComboBox.currentIndex == 0 + + Item { + width: units.largeSpacing + } + QtControls.SpinBox { id: excludeFromSpinBox stepSize: 1 onValueChanged: kcm.fontAASettings.excludeFrom = value textFromValue: function(value, locale) { return i18n("%1 pt", value)} enabled: excludeCheckBox.checked } QtControls.Label { Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter text: i18n("to") enabled: excludeCheckBox.checked } QtControls.SpinBox { id: excludeToSpinBox stepSize: 1 onValueChanged: kcm.fontAASettings.excludeTo = value textFromValue: function(value, locale) { return i18n("%1 pt", value)} enabled: excludeCheckBox.checked } Connections { target: kcm.fontAASettings onExcludeFromChanged: excludeFromSpinBox.value = kcm.fontAASettings.excludeFrom; onExcludeToChanged: excludeToSpinBox.value = kcm.fontAASettings.excludeTo; } } QtControls.ComboBox { id: subPixelCombo Layout.preferredWidth: formLayout.maxImplicitWidth Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Sub-pixel rendering:") currentIndex: kcm.fontAASettings.subPixelCurrentIndex onCurrentIndexChanged: kcm.fontAASettings.subPixelCurrentIndex = currentIndex; model: kcm.fontAASettings.subPixelOptionsModel textRole: "display" enabled: antiAliasingComboBox.currentIndex == 0 popup.height: popup.implicitHeight delegate: QtControls.ItemDelegate { id: subPixelDelegate onWidthChanged: { subPixelCombo.popup.width = Math.max(subPixelCombo.popup.width, width) } contentItem: ColumnLayout { id: subPixelLayout Kirigami.Heading { id: subPixelComboText text: model.display level: 5 } Image { id: subPixelComboImage source: "image://preview/" + model.index + "_" + kcm.fontAASettings.hintingCurrentIndex + ".png" // Setting sourceSize here is necessary as a workaround for QTBUG-38127 // // With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set. // // TODO: Check if QTBUG-38127 is fixed and remove the next two lines. sourceSize.width: 1 sourceSize.height: 1 } } } } QtControls.ComboBox { id: hintingCombo Layout.preferredWidth: formLayout.maxImplicitWidth Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Hinting:") currentIndex: kcm.fontAASettings.hintingCurrentIndex onCurrentTextChanged: kcm.fontAASettings.hintingCurrentIndex = currentIndex; model: kcm.fontAASettings.hintingOptionsModel textRole: "display" enabled: antiAliasingComboBox.currentIndex == 0 popup.height: popup.implicitHeight delegate: QtControls.ItemDelegate { id: hintingDelegate onWidthChanged: { hintingCombo.popup.width = Math.max(hintingCombo.popup.width, width) } contentItem: ColumnLayout { id: hintingLayout Kirigami.Heading { id: hintingComboText text: model.display level: 5 } Image { id: hintingComboImage source: "image://preview/" + kcm.fontAASettings.subPixelCurrentIndex + "_" + model.index + ".png" // Setting sourceSize here is necessary as a workaround for QTBUG-38127 // // With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set. // // TODO: Check if QTBUG-38127 is fixed and remove the next two lines. sourceSize.width: 1 sourceSize.height: 1 } } } } RowLayout { QtControls.CheckBox { id: dpiCheckBox checked: kcm.fontAASettings.dpi !== 0 - text: i18n("Force Fonts DPI:") + text: i18n("Force font DPI:") } QtControls.SpinBox { id: dpiSpinBox stepSize: 24 editable: true enabled: dpiCheckBox.checked value: enabled ? kcm.fontAASettings.dpi : 96 Binding { target: kcm property: "fontAASettings.dpi" value: dpiSpinBox.enabled ? dpiSpinBox.value : 0 } to: 1000 from: 1 } } QtDialogs.FontDialog { id: fontDialog - title: i18n("Choose a font") + title: i18n("Select Font") modality: Qt.WindowModal property string currentCategory property bool adjustAllFonts: false onAccepted: { if (adjustAllFonts) { kcm.adjustAllFonts(font); } else { kcm[currentCategory] = font; } } } } } diff --git a/kcms/fonts/package/metadata.desktop b/kcms/fonts/package/metadata.desktop index 1f4256b9b..d3bc38efc 100644 --- a/kcms/fonts/package/metadata.desktop +++ b/kcms/fonts/package/metadata.desktop @@ -1,155 +1,155 @@ [Desktop Entry] Name=Fonts Name[af]=Skriftipes Name[ar]=الخطوط Name[be]=Шрыфты Name[be@latin]=Šryfty Name[bg]=Шрифтове Name[bn]=ফন্ট Name[bn_IN]=ফন্ট Name[br]=Fontoù Name[bs]=Fontovi Name[ca]=Tipus de lletra Name[ca@valencia]=Tipus de lletra Name[cs]=Písma Name[csb]=Fòntë Name[cy]=Ffontiau Name[da]=Skrifttyper Name[de]=Schriftarten Name[el]=Γραμματοσειρές Name[en_GB]=Fonts Name[eo]=Tiparoj Name[es]=Tipos de letra Name[et]=Fondid Name[eu]=Letra-tipoak Name[fa]=قلمها Name[fi]=Fontit Name[fr]=Polices de caractères Name[fy]=Lettertypen Name[ga]=Clónna Name[gl]=Tipos de letra Name[gu]=ફોન્ટ્સ Name[he]=גופנים Name[hi]=फ़ॉन्ट्स Name[hne]=फोंट Name[hr]=Fontovi Name[hsb]=Pisma Name[hu]=Betűtípusok Name[ia]=Fontes Name[id]=Font Name[is]=Letur Name[it]=Caratteri Name[ja]=フォント Name[ka]=ფონტები Name[kk]=Қаріптер Name[km]=ពុម្ព​អក្សរ Name[kn]=ಅಕ್ಷರಶೈಲಿಗಳು Name[ko]=글꼴 Name[ku]=Curenivîs Name[lt]=Šriftai Name[lv]=Fonti Name[mai]=फान्ट Name[mk]=Фонтови Name[ml]=അക്ഷരസഞ്ചയങ്ങള്‍ Name[mr]=फॉन्ट Name[ms]=Fon Name[nb]=Skrifttyper Name[nds]=Schriftoorden Name[ne]=फन्ट Name[nl]=Lettertypen Name[nn]=Skrifter Name[oc]=Poliças Name[or]=ଅକ୍ଷର ରୂପ Name[pa]=ਫੋਂਟ Name[pl]=Czcionki Name[pt]=Tipos de Letra Name[pt_BR]=Fontes Name[ro]=Fonturi Name[ru]=Шрифты Name[se]=Fonttat Name[si]=අකුරු Name[sk]=Písma Name[sl]=Pisave Name[sr]=Фонтови Name[sr@ijekavian]=Фонтови Name[sr@ijekavianlatin]=Fontovi Name[sr@latin]=Fontovi Name[sv]=Teckensnitt Name[ta]=எழுத்துருக்கள் Name[te]=ఫాంట్‍స్ Name[tg]=Ҳарфҳо Name[th]=แบบอักษรต่างๆ Name[tr]=Yazı Tipleri Name[ug]=خەت نۇسخىلىرى Name[uk]=Шрифти Name[uz]=Shriftlar Name[uz@cyrillic]=Шрифтлар Name[vi]=Phông chữ Name[wa]=Fontes Name[xh]=Uhlobo lwamagama Name[x-test]=xxFontsxx Name[zh_CN]=字体 Name[zh_TW]=字型 -Comment=Fonts +Comment=Configure the system fonts Comment[ar]=الخطوط Comment[bs]=Fontovi Comment[ca]=Tipus de lletra Comment[ca@valencia]=Tipus de lletra Comment[cs]=Písma Comment[da]=Skrifttyper Comment[de]=Schriftarten Comment[el]=Γραμματοσειρές Comment[en_GB]=Fonts Comment[eo]=Tiparoj Comment[es]=Tipos de letra Comment[et]=Fondid Comment[eu]=Letra-tipoak Comment[fi]=Fontit Comment[fr]=Polices de caractères Comment[gl]=Tipos de letra Comment[he]=גופנים Comment[hu]=Betűtípusok Comment[id]=Font Comment[is]=Letur Comment[it]=Caratteri Comment[ja]=フォント Comment[ko]=글꼴 Comment[lt]=Šriftai Comment[mr]=फॉन्ट Comment[nb]=Skrifttype Comment[nds]=Schriftoorden Comment[nl]=Lettertypen Comment[nn]=Skrifter Comment[pa]=ਫੋਂਟ Comment[pl]=Czcionki Comment[pt]=Tipos de Letra Comment[pt_BR]=Fontes Comment[ru]=Шрифты Comment[sk]=Písma Comment[sl]=Pisave Comment[sr]=Фонтови Comment[sr@ijekavian]=Фонтови Comment[sr@ijekavianlatin]=Fontovi Comment[sr@latin]=Fontovi Comment[sv]=Teckensnitt Comment[tr]=Yazı Tipleri Comment[uk]=Шрифти Comment[x-test]=xxFontsxx Comment[zh_CN]=字体 Comment[zh_TW]=字型 Icon=preferences-desktop-font Keywords= Type=Service X-KDE-ParentApp= X-KDE-PluginInfo-Author=Antonis Tsiapaliokas X-KDE-PluginInfo-Email=antonis.tsiapaliokas@kde.org X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-Name=kcm_fonts X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website=https://www.kde.org/plasma-desktop X-KDE-ServiceTypes=Plasma/Generic X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml