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 52 of file KoFontRegistry.cpp.

52 {
53
54 FcChar8 *fileValue{};
55 if (FcPatternGetString(p, FC_FILE, 0, &fileValue) != FcResultMatch) {
56 debugFlake << "Failed to get font file for" << p;
57 return {};
58 }
59 const QString fontFileName = QString::fromUtf8(reinterpret_cast<char *>(fileValue));
60
61 int indexValue{};
62 if (FcPatternGetInteger(p, FC_INDEX, 0, &indexValue) != FcResultMatch) {
63 debugFlake << "Failed to get font index for" << p << "(file:" << fontFileName << ")";
64 return {};
65 }
66
67 return {{fontFileName, indexValue}};
68}
#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 306 of file KoFontRegistry.cpp.

306 {
307 QString modifications;
308 if (info.size > -1) {
309 modifications += QString::number(info.size) + ":" + QString::number(xRes) + "x" + QString::number(yRes);
310 }
311 if (info.fontSizeAdjust != 1.0) {
312 modifications += QString::number(info.fontSizeAdjust);
313 }
314 if (info.weight != 400) {
315 modifications += "weight:"+QString::number(info.weight);
316 }
317 if (info.width != 100) {
318 modifications += "width:"+QString::number(info.width);
319 }
320 if (info.slantMode != 0) {
321 modifications += "slantMode:"+QString::number(info.slantMode);
322 if (info.slantValue != 0) {
323 modifications += "val:"+QString::number(info.slantValue);
324 }
325 }
326 if (!info.axisSettings.isEmpty()) {
327 Q_FOREACH (const QString &key, info.axisSettings.keys()) {
328 modifications += "|" + key + QString::number(info.axisSettings.value(key));
329 }
330 }
331 return modifications;
332}
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.