diff --git a/kcms/fonts/previewimageprovider.cpp b/kcms/fonts/previewimageprovider.cpp index 338e78180..79e5425ed 100644 --- a/kcms/fonts/previewimageprovider.cpp +++ b/kcms/fonts/previewimageprovider.cpp @@ -1,125 +1,131 @@ /* Copyright (c) 2018 Julian Wolff 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 #include #include +#include + #include "kxftconfig.h" #include "previewimageprovider.h" #include "previewrenderengine.h" QImage combineImages(const QList& images, const QColor& bgnd, int spacing=0) { int width = 0; int height = 0; QImage::Format format = QImage::Format_Invalid; int devicePixelRatio = 1; for(const auto& image : images) { if(width < image.width()) { width = image.width(); } height += image.height() + spacing; format = image.format(); devicePixelRatio = image.devicePixelRatio(); } height -= spacing; // To correctly align the image pixels on a high dpi display, // the image dimensions need to be a multiple of devicePixelRatio width = (width + devicePixelRatio - 1) / devicePixelRatio * devicePixelRatio; height = (height + devicePixelRatio - 1) / devicePixelRatio * devicePixelRatio; QImage combinedImage(width, height, format); combinedImage.setDevicePixelRatio(devicePixelRatio); combinedImage.fill(bgnd); int offset = 0; QPainter p(&combinedImage); for(const auto& image : images) { p.drawImage(0, offset, image); offset += (image.height() + spacing) / devicePixelRatio; } return combinedImage; } PreviewImageProvider::PreviewImageProvider(const QFont& font) : QQuickImageProvider(QQuickImageProvider::Image) , m_font(font) { } QImage PreviewImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { + if (!KWindowSystem::isPlatformX11()) { + return QImage(); + } + int subPixelIndex = 0; int hintingIndex = 0; const auto idpart = id.splitRef(QLatin1Char('.'))[0]; const auto sections = idpart.split(QLatin1Char('_')); if (sections.size() >= 2) { subPixelIndex = sections[0].toInt(); hintingIndex = sections[1].toInt(); } KXftConfig xft; KXftConfig::AntiAliasing::State oldAntialiasing = xft.getAntiAliasing(); double oldStart,oldEnd; xft.getExcludeRange(oldStart, oldEnd); KXftConfig::SubPixel::Type oldSubPixelType; xft.getSubPixelType(oldSubPixelType); KXftConfig::Hint::Style oldHintStyle; xft.getHintStyle(oldHintStyle); xft.setAntiAliasing(KXftConfig::AntiAliasing::Enabled); xft.setExcludeRange(0, 0); KXftConfig::SubPixel::Type subPixelType = (KXftConfig::SubPixel::Type)subPixelIndex; xft.setSubPixelType(subPixelType); KXftConfig::Hint::Style hintStyle = (KXftConfig::Hint::Style)hintingIndex; xft.setHintStyle(hintStyle); xft.apply(); QColor text(QApplication::palette().color(QPalette::Text)); QColor bgnd(QApplication::palette().color(QPalette::Window)); PreviewRenderEngine eng(true); QList lines; lines << eng.drawAutoSize(m_font, text, bgnd, eng.getDefaultPreviewString()); QImage img = combineImages(lines, bgnd, lines[0].height()*.25); xft.setAntiAliasing(oldAntialiasing); xft.setExcludeRange(oldStart, oldEnd); xft.setSubPixelType(oldSubPixelType); xft.setHintStyle(oldHintStyle); *size = img.size(); return img; } diff --git a/kcms/kfontinst/kcmfontinst/fontinst.desktop b/kcms/kfontinst/kcmfontinst/fontinst.desktop index 48ff797df..146a627c4 100644 --- a/kcms/kfontinst/kcmfontinst/fontinst.desktop +++ b/kcms/kfontinst/kcmfontinst/fontinst.desktop @@ -1,160 +1,161 @@ [Desktop Entry] Exec=kcmshell5 fontinst Icon=preferences-desktop-font-installer Type=Service X-KDE-ServiceTypes=KCModule X-DocPath=kcontrol/fontinst/index.html X-KDE-Library=kcm_fontinst X-KDE-ParentApp=kcontrol +X-KDE-OnlyShowOnQtPlatforms=xcb; Categories=Qt;KDE;X-KDE-settings-system; X-KDE-System-Settings-Parent-Category=font Name=Font Management Name[ar]=إدارة الخطوط Name[bg]=Управление на шрифтове Name[bn]=ফন্ট ব্যবস্থাপনা Name[bs]=Font za upravljanje Name[ca]=Gestió dels tipus de lletra Name[ca@valencia]=Gestió dels tipus de lletra Name[cs]=Správa písem Name[da]=Håndtering af skrifttyper Name[de]=Schriftarten-Verwaltung Name[el]=Διαχείριση γραμματοσειρών Name[en_GB]=Font Management Name[es]=Gestión de tipos de letra Name[et]=Fondihaldur Name[eu]=Letra-tipoen kudeaketa Name[fi]=Fonttienhallinta Name[fr]=Gestion des polices de caractères Name[ga]=Bainisteoireacht Clónna Name[gl]=Xestión dos tipos de letra Name[he]=ניהול גופנים Name[hr]=Upravljanje pismima Name[hu]=Betűtípus-kezelés Name[ia]=Gestion de font Name[id]=Pengelolaan Fonta Name[is]=Leturstjórn Name[it]=Gestione dei caratteri Name[ja]=フォント管理 Name[kk]=Қаріптерді басқару Name[km]=ការ​គ្រប់គ្រង​ពុម្ពអក្សរ Name[ko]=글꼴 관리 Name[lt]=Šriftų tvarkymas Name[lv]=Fontu pārvaldnieks Name[mr]=फॉन्ट व्यवस्थापन Name[nb]=Skriftadministrering Name[nds]=Schriftpleeg Name[nl]=Lettertypenbeheer Name[nn]=Skrift­handsaming Name[pa]=ਫੋਂਟ ਪਰਬੰਧ Name[pl]=Zarządzanie czcionkami Name[pt]=Gestão dos Tipos de Letra Name[pt_BR]=Gerenciamento de fontes Name[ro]=Administrare fonturi Name[ru]=Управление шрифтами Name[sk]=Správa písiem Name[sl]=Upravljanje pisav Name[sr]=Управљање фонтовима Name[sr@ijekavian]=Управљање фонтовима Name[sr@ijekavianlatin]=Upravljanje fontovima Name[sr@latin]=Upravljanje fontovima Name[sv]=Teckensnittshantering Name[tr]=Yazı Tipi Yönetimi Name[uk]=Керування шрифтами Name[vi]=Trình quản lý phông chữ Name[x-test]=xxFont Managementxx Name[zh_CN]=字体管理 Name[zh_TW]=字型管理 Comment=Font Installation, Preview and Removal Comment[ar]=ثبّت الخطوط، وعاينها وأزلها Comment[bs]=Instalacija fonta, pregled i uklanjanje Comment[ca]=Instal·lació, vista prèvia i eliminació dels tipus de lletra Comment[ca@valencia]=Instal·lació, vista prèvia i eliminació dels tipus de lletra Comment[cs]=Instalace a náhled písem Comment[da]=Installation, forhåndsvisning og fjernelse af skrifttyper Comment[de]=Installation, Vorschau und Entfernen von Schriftarten Comment[el]=Εγκατάσταση, προεπισκόπηση και αφαίρεση γραμματοσειρών Comment[en_GB]=Font Installation, Preview and Removal Comment[es]=Instalación, vista previa y eliminación de tipos de letra Comment[et]=Fontide paigaldamine, eelvaatlus ja eemaldamine Comment[eu]=Letra-tipoak instalatzea, aurreikustea eta kentzea Comment[fi]=Fonttien asennus, esikatselu ja poistaminen Comment[fr]=Installation, aperçu et suppression de polices Comment[gl]=Instalación, vista previa e desinstalación de tipos de letra Comment[he]=Font Installation, Preview and Removal Comment[hu]=Betűkészlet-telepítés, előnézet és eltávolítás Comment[id]=Pemasangan Fonta, Pratinjau dan Pencopotan Comment[it]=Installazione dei caratteri, anteprima e rimozione Comment[ko]=글꼴 설치, 미리 보기, 삭제 Comment[lt]=Šriftų diegimas, peržiūra ir šalinimas Comment[nb]=Skriftinstallering, forhåndsvisning og fjerning Comment[nds]=Schriftoorden ankieken, installeren un wegmaken Comment[nl]=Installatie, voorbeeldweergave en verwijdering van lettertypen Comment[nn]=Installering, førehandsvising og fjerning av skrifter Comment[pa]=ਫ਼ੋਂਟ ਇੰਸਟਾਲੇਸ਼ਨ, ਝਲਕ ਅਤੇ ਹਟਾਉਣਾ Comment[pl]=Wgrywanie, podgląd i usuwanie czcionek Comment[pt]=Instalação, Antevisão e Remoção de Tipos de Letra Comment[pt_BR]=Instalação, visualização e remoção de fontes Comment[ru]=Установка, просмотр и удаление шрифтов Comment[sk]=Inštalácia, náhľad a odstránenie písiem Comment[sl]=Namestitev, predogled in odstranitev pisav Comment[sr]=Инсталирање, преглед и уклањање фонтова Comment[sr@ijekavian]=Инсталирање, преглед и уклањање фонтова Comment[sr@ijekavianlatin]=Instaliranje, pregled i uklanjanje fontova Comment[sr@latin]=Instaliranje, pregled i uklanjanje fontova Comment[sv]=Installation, förhandsgranskning och borttagning av teckensnitt Comment[tr]=Yazı Tipi Kurulumu, Önizlemesi ve Kaldırılması Comment[uk]=Встановлення, перегляд і вилучення шрифтів Comment[x-test]=xxFont Installation, Preview and Removalxx Comment[zh_CN]=字体安装,预览和删除 Comment[zh_TW]=字型安裝、預覽與移除 X-KDE-Keywords=font,fonts,installer,truetype,type1,bitmap X-KDE-Keywords[ar]=خط,خطوط,مثبّت,مثبت,ترو.تايب,تايب1,صورة نقطية,truetype X-KDE-Keywords[bs]=slovo,slova,instalacijski program,truetype,tip1,bitna mapa X-KDE-Keywords[ca]=tipus de lletra,tipus de lletres,instal·lador,truetype,type1,mapa de bits X-KDE-Keywords[ca@valencia]=tipus de lletra,tipus de lletres,instal·lador,truetype,type1,mapa de bits X-KDE-Keywords[cs]=písmo,písma,instalátor,truetype,type1,bitmap X-KDE-Keywords[da]=font,fonts,skrifttype,skrifttyper,installer,truetype,type1,bitmap X-KDE-Keywords[de]=Schrift,Fonts,Schriftarten,Installation,TrueType,Type1,Bitmapschriften X-KDE-Keywords[el]=γραμματοσειρά,γραμματοσειρές,πρόγραμμα εγκατάστασης,truetype,type1,bitmap X-KDE-Keywords[en_GB]=font,fonts,installer,truetype,type1,bitmap X-KDE-Keywords[es]=tipo de letra,tipos de letra,instalador,truetype,type1,mapa de bits X-KDE-Keywords[et]=font,fondid,paigaldaja,truetype,type1,bitmap,bittraster X-KDE-Keywords[eu]=letra-tipo,letra-tipoak,instalatzaile,truetype,type1,bitmapa X-KDE-Keywords[fi]=kirjasin,kirjasimet,fontti,fontit,asentaja,asennin,truetype,type1,bitmap,bittikartta X-KDE-Keywords[fr]=police, polices, installateur, TrueType, type1, bitmap X-KDE-Keywords[ga]=cló,clófhoireann,clónna,clófhoirne,suiteálaí,truetype,type1,mapa giotán,giotánmhapach X-KDE-Keywords[gl]=letra, glifo, tipo de letra, tipo, instalador X-KDE-Keywords[hu]=betűkészlet,betűkészletek,telepítő,truetype,type 1,bitmap X-KDE-Keywords[ia]=font,fonts,installator,truetype,type1,bitmap X-KDE-Keywords[id]=fonta,fonta,penginstal,truetype,type1,bitmap X-KDE-Keywords[it]=carattere,caratteri,installatore,truetype,type1,bitmap X-KDE-Keywords[kk]=font,fonts,installer,truetype,type1,bitmap X-KDE-Keywords[km]=font,fonts,installer,truetype,type1,bitmap X-KDE-Keywords[ko]=font,fonts,installer,truetype,type1,bitmap,글꼴,폰트,설치 X-KDE-Keywords[mr]=फॉन्ट, फॉन्टस, इंस्टालर, ट्रू टाईप, टाईप १, बीटमँप X-KDE-Keywords[nb]=skrift,skrifter,installer,truetrype,type1,bitmap X-KDE-Keywords[nds]=Schrift,Schriften,Schriftoort,Schriftoorden,TrueType,Type1,Bitmap X-KDE-Keywords[nl]=lettertype,lettertypen,installatieprogramma,truetype,type1,bitmap X-KDE-Keywords[nn]=skrift,skrifter,font,installer,truetype,type1,bitmap,punktskrift X-KDE-Keywords[pl]=czcionki,czcionka,instalator,truetype,typ1,mapa bitowa X-KDE-Keywords[pt]=tipo de letra,tipos de letra,instalador,truetype,type1,imagem X-KDE-Keywords[pt_BR]=fonte,fontes,instalador,truetype,type1,bitmap,imagem X-KDE-Keywords[ru]=font,fonts,installer,truetype,type1,bitmap,шрифт,шрифты,установка шрифтов,инсталлятор,битовая карта,растровое изображение,удаление шрифтов X-KDE-Keywords[sk]=písmo,písma,inštalátor,truetype,type1,bitmap X-KDE-Keywords[sl]=pisava,pisave,namestilnik,truetype,type1,bitmap,namestilnik pisav X-KDE-Keywords[sr]=font,fonts,installer,truetype,type1,bitmap,фонт,фонтови,инсталатер,трутајп,тип‑1,битмапски X-KDE-Keywords[sr@ijekavian]=font,fonts,installer,truetype,type1,bitmap,фонт,фонтови,инсталатер,трутајп,тип‑1,битмапски X-KDE-Keywords[sr@ijekavianlatin]=font,fonts,installer,truetype,type1,bitmap,font,fontovi,instalater,Truetype,Type1,bitmapski X-KDE-Keywords[sr@latin]=font,fonts,installer,truetype,type1,bitmap,font,fontovi,instalater,Truetype,Type1,bitmapski X-KDE-Keywords[sv]=teckensnitt,installation,truetype,type1,bitavbildning X-KDE-Keywords[tr]=yazı tipi,yazı tipleri,yükleyici,kurucu,trueytpe,type1,resim X-KDE-Keywords[uk]=шрифт,шрифти,встановлювач,truetype,type1,растрові X-KDE-Keywords[x-test]=xxfontxx,xxfontsxx,xxinstallerxx,xxtruetypexx,xxtype1xx,xxbitmapxx X-KDE-Keywords[zh_CN]=font,fonts,installer,truetype,type1,bitmap,字体,安装器,点阵 X-KDE-Keywords[zh_TW]=font,fonts,installer,truetype,type1,bitmap