~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kcontrol/kfontinst/lib/Fc.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * KFontInst - KDE Font Installer
 
3
 *
 
4
 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
 
5
 *
 
6
 * ----
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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.
 
22
 */
 
23
 
 
24
#ifndef __FC_H__
 
25
#define __FC_H__
 
26
 
 
27
#include <KDE/KUrl>
 
28
#include <config-workspace.h>
 
29
#include <fontconfig/fontconfig.h>
 
30
#include "kfontinst_export.h"
 
31
#include "KfiConstants.h"
 
32
#include "Misc.h"
 
33
 
 
34
#if (FC_VERSION<20200)
 
35
 
 
36
#define KFI_FC_NO_WIDTHS
 
37
#define KFI_FC_LIMITED_WEIGHTS
 
38
 
 
39
#endif
 
40
 
 
41
#ifdef KFI_FC_LIMITED_WEIGHTS
 
42
 
 
43
#undef FC_WEIGHT_LIGHT
 
44
#define FC_WEIGHT_THIN              0
 
45
#define FC_WEIGHT_EXTRALIGHT        40
 
46
#define FC_WEIGHT_ULTRALIGHT        FC_WEIGHT_EXTRALIGHT
 
47
#define FC_WEIGHT_LIGHT             50
 
48
#define FC_WEIGHT_BOOK              75
 
49
#define FC_WEIGHT_REGULAR           80
 
50
#define FC_WEIGHT_NORMAL            FC_WEIGHT_REGULAR
 
51
#define FC_WEIGHT_SEMIBOLD          FC_WEIGHT_DEMIBOLD
 
52
#define FC_WEIGHT_EXTRABOLD         205
 
53
#define FC_WEIGHT_ULTRABOLD         FC_WEIGHT_EXTRABOLD
 
54
#define FC_WEIGHT_HEAVY             FC_WEIGHT_BLACK
 
55
 
 
56
#endif
 
57
 
 
58
class QString;
 
59
 
 
60
namespace KFI
 
61
{
 
62
namespace FC
 
63
{
 
64
//
 
65
// Ideally only want this class to contain KFI_FC_NO_WIDTHS
 
66
#ifdef KFI_FC_NO_WIDTHS
 
67
#define KFI_FC_WIDTH_ULTRACONDENSED     50
 
68
#define KFI_FC_WIDTH_EXTRACONDENSED     63
 
69
#define KFI_FC_WIDTH_CONDENSED          75
 
70
#define KFI_FC_WIDTH_SEMICONDENSED      87
 
71
#define KFI_FC_WIDTH_NORMAL             100
 
72
#define KFI_FC_WIDTH_SEMIEXPANDED       113
 
73
#define KFI_FC_WIDTH_EXPANDED           125
 
74
#define KFI_FC_WIDTH_EXTRAEXPANDED      150
 
75
#define KFI_FC_WIDTH_ULTRAEXPANDED      200
 
76
#else
 
77
#define KFI_FC_WIDTH_ULTRACONDENSED     FC_WIDTH_ULTRACONDENSED
 
78
#define KFI_FC_WIDTH_EXTRACONDENSED     FC_WIDTH_EXTRACONDENSED
 
79
#define KFI_FC_WIDTH_CONDENSED          FC_WIDTH_CONDENSED
 
80
#define KFI_FC_WIDTH_SEMICONDENSED      FC_WIDTH_SEMICONDENSED
 
81
#define KFI_FC_WIDTH_NORMAL             FC_WIDTH_NORMAL
 
82
#define KFI_FC_WIDTH_SEMIEXPANDED       FC_WIDTH_SEMIEXPANDED
 
83
#define KFI_FC_WIDTH_EXPANDED           FC_WIDTH_EXPANDED
 
84
#define KFI_FC_WIDTH_EXTRAEXPANDED      FC_WIDTH_EXTRAEXPANDED
 
85
#define KFI_FC_WIDTH_ULTRAEXPANDED      FC_WIDTH_ULTRAEXPANDED
 
86
#endif
 
87
 
 
88
    extern KDE_EXPORT KUrl        encode(const QString &name, quint32 style, const QString &file=QString(), int index=0);
 
89
    extern KDE_EXPORT Misc::TFont decode(const KUrl &url);
 
90
    extern KDE_EXPORT QString     getFile(const KUrl &url);
 
91
    extern KDE_EXPORT int         getIndex(const KUrl &url);
 
92
    extern KDE_EXPORT int     weight(int w); // round w to nearest fc weight
 
93
    extern KDE_EXPORT int     width(int w); // round w to nearest fc width
 
94
    extern KDE_EXPORT int     slant(int s); // round s to nearest fc slant
 
95
    extern KDE_EXPORT int     spacing(int s); // round s to nearest fc spacing
 
96
    extern KDE_EXPORT int     strToWeight(const QString &str, QString &newStr);
 
97
    extern KDE_EXPORT int     strToWidth(const QString &str, QString &newStr);
 
98
    extern KDE_EXPORT int     strToSlant(const QString &str);
 
99
    extern KDE_EXPORT quint32 createStyleVal(const QString &name);
 
100
    inline KDE_EXPORT quint32 createStyleVal(int weight, int width, int slant)
 
101
                            { return ((weight&0xFF)<<16)+((width&0xFF)<<8)+(slant&0xFF); }
 
102
    extern KDE_EXPORT QString styleValToStr(quint32 style);
 
103
    extern KDE_EXPORT void    decomposeStyleVal(quint32 styleInfo, int &weight, int &width, int &slant);
 
104
    extern KDE_EXPORT quint32 styleValFromStr(const QString &style);
 
105
 
 
106
    extern KDE_EXPORT QString getFcString(FcPattern *pat, const char *val, int index=0);
 
107
#ifdef KFI_USE_TRANSLATED_FAMILY_NAME
 
108
    extern KDE_EXPORT QString getFcLangString(FcPattern *pat, const char *val, const char *valLang);
 
109
#endif
 
110
    extern KDE_EXPORT int     getFcInt(FcPattern *pat, const char *val, int index=0, int def=-1);
 
111
    extern KDE_EXPORT QString getName(const QString &file);
 
112
    extern KDE_EXPORT void    getDetails(FcPattern *pat, QString &family, quint32 &styleVal, int &index, QString &foundry);
 
113
    extern KDE_EXPORT QString createName(FcPattern *pat);
 
114
    extern KDE_EXPORT QString createName(const QString &family, quint32 styleInfo);
 
115
    extern KDE_EXPORT QString createName(const QString &family, int weight, int width, int slant);
 
116
    inline KDE_EXPORT QString createName(const Misc::TFont &font) { return createName(font.family, font.styleInfo); }
 
117
    extern KDE_EXPORT QString createStyleName(quint32 styleInfo);
 
118
    extern KDE_EXPORT QString createStyleName(int weight, int width, int slant);
 
119
    extern KDE_EXPORT QString weightStr(int w, bool emptyNormal=true);
 
120
    extern KDE_EXPORT QString widthStr(int w, bool emptyNormal=true);
 
121
    extern KDE_EXPORT QString slantStr(int s, bool emptyNormal=true);
 
122
    extern KDE_EXPORT QString spacingStr(int s);
 
123
    extern KDE_EXPORT bool    bitmapsEnabled();
 
124
}
 
125
}
 
126
 
 
127
#endif