2 * KFontInst - KDE Font Installer
4 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
27 #include <config-workspace.h>
28 #include <fontconfig/fontconfig.h>
29 #include "kfontinst_export.h"
30 #include "KfiConstants.h"
32 #if (FC_VERSION<20200)
34 #define KFI_FC_NO_WIDTHS
35 #define KFI_FC_LIMITED_WEIGHTS
39 #ifdef KFI_FC_LIMITED_WEIGHTS
41 #undef FC_WEIGHT_LIGHT
42 #define FC_WEIGHT_THIN 0
43 #define FC_WEIGHT_EXTRALIGHT 40
44 #define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
45 #define FC_WEIGHT_LIGHT 50
46 #define FC_WEIGHT_BOOK 75
47 #define FC_WEIGHT_REGULAR 80
48 #define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
49 #define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD
50 #define FC_WEIGHT_EXTRABOLD 205
51 #define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
52 #define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
63 // Ideally only want this class to contain KFI_FC_NO_WIDTHS
64 #ifdef KFI_FC_NO_WIDTHS
65 #define KFI_FC_WIDTH_ULTRACONDENSED 50
66 #define KFI_FC_WIDTH_EXTRACONDENSED 63
67 #define KFI_FC_WIDTH_CONDENSED 75
68 #define KFI_FC_WIDTH_SEMICONDENSED 87
69 #define KFI_FC_WIDTH_NORMAL 100
70 #define KFI_FC_WIDTH_SEMIEXPANDED 113
71 #define KFI_FC_WIDTH_EXPANDED 125
72 #define KFI_FC_WIDTH_EXTRAEXPANDED 150
73 #define KFI_FC_WIDTH_ULTRAEXPANDED 200
75 #define KFI_FC_WIDTH_ULTRACONDENSED FC_WIDTH_ULTRACONDENSED
76 #define KFI_FC_WIDTH_EXTRACONDENSED FC_WIDTH_EXTRACONDENSED
77 #define KFI_FC_WIDTH_CONDENSED FC_WIDTH_CONDENSED
78 #define KFI_FC_WIDTH_SEMICONDENSED FC_WIDTH_SEMICONDENSED
79 #define KFI_FC_WIDTH_NORMAL FC_WIDTH_NORMAL
80 #define KFI_FC_WIDTH_SEMIEXPANDED FC_WIDTH_SEMIEXPANDED
81 #define KFI_FC_WIDTH_EXPANDED FC_WIDTH_EXPANDED
82 #define KFI_FC_WIDTH_EXTRAEXPANDED FC_WIDTH_EXTRAEXPANDED
83 #define KFI_FC_WIDTH_ULTRAEXPANDED FC_WIDTH_ULTRAEXPANDED
86 extern KDE_EXPORT
int weight(int w
); // round w to nearest fc weight
87 extern KDE_EXPORT
int width(int w
); // round w to nearest fc width
88 extern KDE_EXPORT
int slant(int s
); // round s to nearest fc slant
89 extern KDE_EXPORT
int spacing(int s
); // round s to nearest fc spacing
90 extern KDE_EXPORT
int strToWeight(const QString
&str
, QString
&newStr
);
91 extern KDE_EXPORT
int strToWidth(const QString
&str
, QString
&newStr
);
92 extern KDE_EXPORT
int strToSlant(const QString
&str
);
93 extern KDE_EXPORT quint32
createStyleVal(const QString
&name
);
94 inline KDE_EXPORT quint32
createStyleVal(int weight
, int width
, int slant
)
95 { return ((weight
&0xFF)<<16)+((width
&0xFF)<<8)+(slant
&0xFF); }
96 extern KDE_EXPORT QString
styleValToStr(quint32 style
);
97 extern KDE_EXPORT
void decomposeStyleVal(quint32 styleInfo
, int &weight
, int &width
, int &slant
);
98 extern KDE_EXPORT quint32
styleValFromStr(const QString
&style
);
100 extern KDE_EXPORT QString
getFcString(FcPattern
*pat
, const char *val
, int index
=0);
101 #ifdef KFI_USE_TRANSLATED_FAMILY_NAME
102 extern KDE_EXPORT QString
getFcLangString(FcPattern
*pat
, const char *val
, const char *valLang
);
104 extern KDE_EXPORT
int getFcInt(FcPattern
*pat
, const char *val
, int index
=0, int def
=-1);
105 extern KDE_EXPORT
void getDetails(FcPattern
*pat
, QString
&name
, quint32
&styleVal
, int &index
);
106 extern KDE_EXPORT QString
createName(FcPattern
*pat
);
107 extern KDE_EXPORT QString
createName(FcPattern
*pat
, int weight
, int width
, int slant
);
108 extern KDE_EXPORT QString
createName(const QString
&family
, quint32 styleInfo
);
109 extern KDE_EXPORT QString
createName(const QString
&family
, int weight
, int width
, int slant
);
110 extern KDE_EXPORT QString
weightStr(int w
, bool emptyNormal
=true);
111 extern KDE_EXPORT QString
widthStr(int w
, bool emptyNormal
=true);
112 extern KDE_EXPORT QString
slantStr(int s
, bool emptyNormal
=true);
113 extern KDE_EXPORT QString
spacingStr(int s
);
114 extern KDE_EXPORT
bool bitmapsEnabled();