Krita Source Code Documentation
Loading...
Searching...
No Matches
KoFontRegistry.cpp File Reference
#include "KoFontRegistry.h"
#include "FlakeDebug.h"
#include "KoCssTextUtils.h"
#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QGlobalStatic>
#include <QThread>
#include <QThreadStorage>
#include <QtGlobal>
#include <utility>
#include <optional>
#include <KoResourcePaths.h>
#include <kis_debug.h>
#include "KoFontLibraryResourceUtils.h"
#include "KoFFWWSConverter.h"
#include "KoFontChangeTracker.h"
#include "KoWritingSystemUtils.h"
#include <KisResourceLocator.h>

Go to the source code of this file.

Classes

class  KoFontRegistry
 The KoFontRegistry class A wrapper around a freetype library. More...
 
struct  KoFontRegistry::ThreadData
 

Functions

static unsigned int firstCharUcs4 (const QStringView qsv)
 
std::optional< KoFFWWSConverter::FontFileEntrygetFontFileEntry (const FcPattern *p)
 
QString modificationsString (KoCSSFontInfo info, quint32 xRes, quint32 yRes)
 

Function Documentation

◆ firstCharUcs4()

static unsigned int firstCharUcs4 ( const QStringView qsv)
static

Definition at line 34 of file KoFontRegistry.cpp.

35{
36 if (Q_UNLIKELY(qsv.isEmpty())) {
37 return 0;
38 }
39 const QChar high = qsv.first();
40 if (Q_LIKELY(!high.isSurrogate())) {
41 return high.unicode();
42 }
43 if (Q_LIKELY(high.isHighSurrogate() && qsv.length() >= 2)) {
44 const QChar low = qsv[1];
45 if (Q_LIKELY(low.isLowSurrogate())) {
46 return QChar::surrogateToUcs4(high, low);
47 }
48 }
49 return QChar::ReplacementCharacter;
50}

◆ getFontFileEntry()

std::optional< KoFFWWSConverter::FontFileEntry > getFontFileEntry ( const FcPattern * p)

Definition at line 277 of file KoFontRegistry.cpp.

277 {
278
279 FcChar8 *fileValue{};
280 if (FcPatternGetString(p, FC_FILE, 0, &fileValue) != FcResultMatch) {
281 debugFlake << "Failed to get font file for" << p;
282 return {};
283 }
284 const QString fontFileName = QString::fromUtf8(reinterpret_cast<char *>(fileValue));
285
286 int indexValue{};
287 if (FcPatternGetInteger(p, FC_INDEX, 0, &indexValue) != FcResultMatch) {
288 debugFlake << "Failed to get font index for" << p << "(file:" << fontFileName << ")";
289 return {};
290 }
291
292 return {{fontFileName, indexValue}};
293}
#define debugFlake
Definition FlakeDebug.h:15
const Params2D p

References debugFlake, and p.

◆ modificationsString()

QString modificationsString ( KoCSSFontInfo info,
quint32 xRes,
quint32 yRes )

Definition at line 249 of file KoFontRegistry.cpp.

249 {
250 QString modifications;
251 if (info.size > -1) {
252 modifications += QString::number(info.size) + ":" + QString::number(xRes) + "x" + QString::number(yRes);
253 }
254 if (info.fontSizeAdjust != 1.0) {
255 modifications += QString::number(info.fontSizeAdjust);
256 }
257 if (info.weight != 400) {
258 modifications += "weight:"+QString::number(info.weight);
259 }
260 if (info.width != 100) {
261 modifications += "width:"+QString::number(info.width);
262 }
263 if (info.slantMode != 0) {
264 modifications += "slantMode:"+QString::number(info.slantMode);
265 if (info.slantValue != 0) {
266 modifications += "val:"+QString::number(info.slantValue);
267 }
268 }
269 if (!info.axisSettings.isEmpty()) {
270 Q_FOREACH (const QString &key, info.axisSettings.keys()) {
271 modifications += "|" + key + QString::number(info.axisSettings.value(key));
272 }
273 }
274 return modifications;
275}
double fontSizeAdjust
QMap< QString, double > axisSettings
QFont::Style slantMode

References KoCSSFontInfo::axisSettings, KoCSSFontInfo::fontSizeAdjust, KoCSSFontInfo::size, KoCSSFontInfo::slantMode, KoCSSFontInfo::slantValue, KoCSSFontInfo::weight, and KoCSSFontInfo::width.