mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix build with Qt 5.5.x
This just imports changes from Qt 5.5 and puts them behind appropriate QT_VERSION #ifdefs.
This commit is contained in:
parent
cea314f0d9
commit
aa19aa903e
@ -54,6 +54,15 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||||
|
static const int maxWeight = 99;
|
||||||
|
|
||||||
|
static inline int mapToQtWeightForRange(int fcweight, int fcLower, int fcUpper, int qtLower, int qtUpper)
|
||||||
|
{
|
||||||
|
return qtLower + ((fcweight - fcLower) * (qtUpper - qtLower)) / (fcUpper - fcLower);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline bool requiresOpenType(int writingSystem)
|
static inline bool requiresOpenType(int writingSystem)
|
||||||
{
|
{
|
||||||
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
|
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
|
||||||
@ -68,6 +77,29 @@ static inline int weightFromFcWeight(int fcweight)
|
|||||||
// mapping. This ensures that where there is a corresponding enum on both sides (for example
|
// mapping. This ensures that where there is a corresponding enum on both sides (for example
|
||||||
// FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map
|
// FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map
|
||||||
// to intermediate Qt weights.
|
// to intermediate Qt weights.
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||||
|
if (fcweight <= FC_WEIGHT_THIN)
|
||||||
|
return QFont::Thin;
|
||||||
|
if (fcweight <= FC_WEIGHT_ULTRALIGHT)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_THIN, FC_WEIGHT_ULTRALIGHT, QFont::Thin, QFont::ExtraLight);
|
||||||
|
if (fcweight <= FC_WEIGHT_LIGHT)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRALIGHT, FC_WEIGHT_LIGHT, QFont::ExtraLight, QFont::Light);
|
||||||
|
if (fcweight <= FC_WEIGHT_NORMAL)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_LIGHT, FC_WEIGHT_NORMAL, QFont::Light, QFont::Normal);
|
||||||
|
if (fcweight <= FC_WEIGHT_MEDIUM)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_NORMAL, FC_WEIGHT_MEDIUM, QFont::Normal, QFont::Medium);
|
||||||
|
if (fcweight <= FC_WEIGHT_DEMIBOLD)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_MEDIUM, FC_WEIGHT_DEMIBOLD, QFont::Medium, QFont::DemiBold);
|
||||||
|
if (fcweight <= FC_WEIGHT_BOLD)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_DEMIBOLD, FC_WEIGHT_BOLD, QFont::DemiBold, QFont::Bold);
|
||||||
|
if (fcweight <= FC_WEIGHT_ULTRABOLD)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_BOLD, FC_WEIGHT_ULTRABOLD, QFont::Bold, QFont::ExtraBold);
|
||||||
|
if (fcweight <= FC_WEIGHT_BLACK)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRABOLD, FC_WEIGHT_BLACK, QFont::ExtraBold, QFont::Black);
|
||||||
|
if (fcweight <= FC_WEIGHT_ULTRABLACK)
|
||||||
|
return mapToQtWeightForRange(fcweight, FC_WEIGHT_BLACK, FC_WEIGHT_ULTRABLACK, QFont::Black, maxWeight);
|
||||||
|
return maxWeight;
|
||||||
|
#else
|
||||||
const int maxWeight = 99;
|
const int maxWeight = 99;
|
||||||
int qtweight;
|
int qtweight;
|
||||||
if (fcweight < 0)
|
if (fcweight < 0)
|
||||||
@ -88,6 +120,7 @@ static inline int weightFromFcWeight(int fcweight)
|
|||||||
qtweight = maxWeight;
|
qtweight = maxWeight;
|
||||||
|
|
||||||
return qtweight;
|
return qtweight;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int stretchFromFcWidth(int fcwidth)
|
static inline int stretchFromFcWidth(int fcwidth)
|
||||||
@ -209,7 +242,35 @@ static const char *specialLanguages[] = {
|
|||||||
"hmd", // Miao
|
"hmd", // Miao
|
||||||
"sa", // Sharada
|
"sa", // Sharada
|
||||||
"srb", // SoraSompeng
|
"srb", // SoraSompeng
|
||||||
"doi" // Takri
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||||
|
"doi", // Takri
|
||||||
|
"lez", // CaucasianAlbanian
|
||||||
|
"bsq", // BassaVah
|
||||||
|
"fr", // Duployan
|
||||||
|
"sq", // Elbasan
|
||||||
|
"sa", // Grantha
|
||||||
|
"hnj", // PahawhHmong
|
||||||
|
"sd", // Khojki
|
||||||
|
"lab", // LinearA
|
||||||
|
"hi", // Mahajani
|
||||||
|
"xmn", // Manichaean
|
||||||
|
"men", // MendeKikakui
|
||||||
|
"mr", // Modi
|
||||||
|
"mru", // Mro
|
||||||
|
"xna", // OldNorthArabian
|
||||||
|
"arc", // Nabataean
|
||||||
|
"arc", // Palmyrene
|
||||||
|
"ctd", // PauCinHau
|
||||||
|
"kv", // OldPermic
|
||||||
|
"pal", // PsalterPahlavi
|
||||||
|
"sa", // Siddham
|
||||||
|
"sd", // Khudawadi
|
||||||
|
"mai", // Tirhuta
|
||||||
|
"hoc" // WarangCiti
|
||||||
|
#else
|
||||||
|
"doi" // Takri
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
Q_STATIC_ASSERT(sizeof(specialLanguages) / sizeof(const char *) == QChar::ScriptCount);
|
Q_STATIC_ASSERT(sizeof(specialLanguages) / sizeof(const char *) == QChar::ScriptCount);
|
||||||
|
|
||||||
@ -270,7 +331,11 @@ static const char *openType[] = {
|
|||||||
"deva", // Devanagari
|
"deva", // Devanagari
|
||||||
"beng", // Bengali
|
"beng", // Bengali
|
||||||
"guru", // Gurmukhi
|
"guru", // Gurmukhi
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||||
|
"gujr", // Gujarati
|
||||||
|
#else
|
||||||
"gurj", // Gujarati
|
"gurj", // Gujarati
|
||||||
|
#endif
|
||||||
"orya", // Oriya
|
"orya", // Oriya
|
||||||
"taml", // Tamil
|
"taml", // Tamil
|
||||||
"telu", // Telugu
|
"telu", // Telugu
|
||||||
|
@ -16,6 +16,16 @@ class QFontEngineFT;
|
|||||||
class QFontconfigDatabase : public QBasicFontDatabase
|
class QFontconfigDatabase : public QBasicFontDatabase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
||||||
|
void populateFontDatabase() Q_DECL_OVERRIDE;
|
||||||
|
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE;
|
||||||
|
QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
|
||||||
|
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
|
||||||
|
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE;
|
||||||
|
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE;
|
||||||
|
QString resolveFontFamilyAlias(const QString &family) const Q_DECL_OVERRIDE;
|
||||||
|
QFont defaultFont() const Q_DECL_OVERRIDE;
|
||||||
|
#else
|
||||||
void populateFontDatabase();
|
void populateFontDatabase();
|
||||||
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
|
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
|
||||||
QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
|
QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
|
||||||
@ -24,6 +34,7 @@ public:
|
|||||||
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
|
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
|
||||||
QString resolveFontFamilyAlias(const QString &family) const;
|
QString resolveFontFamilyAlias(const QString &family) const;
|
||||||
QFont defaultFont() const;
|
QFont defaultFont() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const;
|
void setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user