1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
/**
* This file is part of the KDE project
*
* Copyright (C) 2003 Stephan Kulow (coolo@kde.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "ecma/kjs_proxy.h"
#define QT_NO_XRANDR 1
#define QT_NO_XFTFREETYPE 1
#include <private/qfontengine_p.h>
#include <tqfontdatabase.h>
#include <tqfont.h>
#include <tqpainter.h>
#include "khtml_settings.h"
#include <tqwidget.h>
#include <assert.h>
class QFakeFontEngine : public QFontEngineXLFD
{
bool ahem;
int pixS;
public:
QFakeFontEngine( XFontStruct *fs, const char *name, int size );
~QFakeFontEngine();
int leading() const
{
if (ahem)
return 0;
else
return QFontEngineXLFD::leading();
}
void draw( TQPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags )
{
//Sometimes X misrounds stuff for larger ahem, so we have to do it ourselves.
if (!ahem || (si->analysis.bidiLevel & 1) ) //We're fine if not ahem or bidi.
return QFontEngineXLFD::draw(p, x, y, engine, si, textFlags);
glyph_t* gl = engine->glyphs(si);
for (int pos = 0; pos < si->num_glyphs; ++pos)
{
switch (gl[pos])
{
case ' ':
break;
case 'p':
//Below the baseline, including it
p->fillRect(x, y, pixS, descent() + 1, p->pen().color());
break;
case 0xC9:
//Above the baseline
p->fillRect(x, y - ascent(), pixS, ascent(), p->pen().color());
break;
default:
//Whole block
p->fillRect(x, y - ascent(), pixS, pixS, p->pen().color());
}
x += pixS;
}
}
#if 0
virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
glyph_metrics_t boundingBox( glyph_t glyph );
QFontEngine::Error stringToCMap( const TQChar *, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool ) const;
int ascent() const;
int descent() const;
int leading() const;
int maxCharWidth() const;
int minLeftBearing() const { return 0; }
int minRightBearing() const { return 0; }
int cmap() const;
#endif
bool canRender( const TQChar *string, int len );
};
QFakeFontEngine::QFakeFontEngine( XFontStruct *fs, const char *name, int size )
: QFontEngineXLFD( fs, name, 0)
{
pixS = size;
ahem = TQString::fromLatin1(name).contains("ahem");
}
QFakeFontEngine::~QFakeFontEngine()
{
}
#if 0
QFontEngine::Error QFakeFontEngine::stringToCMap( const TQChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored) const
{
QFontEngine::Error ret = QFontEngineXLFD::stringToCMap( str, len, glyphs, advances, nglyphs, mirrored );
if ( ret != NoError )
return ret;
*nglyphs = len;
if ( advances ) {
for ( int i = 0; i < len; i++ )
*(advances++) = _size;
}
return NoError;
}
glyph_metrics_t QFakeFontEngine::boundingBox( const glyph_t *, const advance_t *, const qoffset_t *, int numGlyphs )
{
glyph_metrics_t overall;
overall.x = overall.y = 0;
overall.width = _size*numGlyphs;
overall.height = _size;
overall.xoff = overall.width;
overall.yoff = 0;
return overall;
}
glyph_metrics_t QFakeFontEngine::boundingBox( glyph_t )
{
return glyph_metrics_t( 0, _size, _size, _size, _size, 0 );
}
int QFakeFontEngine::ascent() const
{
return _size;
}
int QFakeFontEngine::descent() const
{
return 0;
}
int QFakeFontEngine::leading() const
{
// the original uses double and creates quite random results depending
// on the compiler flags
int l = ( _size * 15 + 50) / 100;
// only valid on i386 without -O2 assert(l == int(qRound(_size * 0.15)));
return (l > 0) ? l : 1;
}
int QFakeFontEngine::maxCharWidth() const
{
return _size;
}
int QFakeFontEngine::cmap() const
{
return -1;
}
#endif
bool QFakeFontEngine::canRender( const TQChar *, int )
{
return true;
}
static TQString courier_pickxlfd( int pixelsize, bool italic, bool bold )
{
if ( pixelsize >= 24 )
pixelsize = 24;
else if ( pixelsize >= 18 )
pixelsize = 18;
else if ( pixelsize >= 12 )
pixelsize = 12;
else
pixelsize = 10;
return TQString( "-adobe-courier-%1-%2-normal--%3-*-75-75-m-*-iso10646-1" ).arg( bold ? "bold" : "medium" ).arg( italic ? "o" : "r" ).arg( pixelsize );
}
static TQString ahem_pickxlfd( int pixelsize )
{
return TQString( "-misc-ahem-medium-r-normal--%1-*-100-100-c-*-iso10646-1" ).arg( pixelsize );
}
static TQString helv_pickxlfd( int pixelsize, bool italic, bool bold )
{
if ( pixelsize >= 24 )
pixelsize = 24;
else if ( pixelsize >= 18 )
pixelsize = 18;
else if ( pixelsize >= 12 )
pixelsize = 12;
else
pixelsize = 10;
return TQString( "-adobe-helvetica-%1-%2-normal--%3-*-75-75-p-*-iso10646-1" ).arg( bold ? "bold" : "medium" ).arg( italic ? "o" : "r" ).arg( pixelsize );
}
KDE_EXPORT QFontEngine *
TQFontDatabase::findFont( TQFont::Script script, const QFontPrivate *fp,
const QFontDef &request, int )
{
TQString xlfd;
TQString family = request.family.lower();
if ( family == "adobe courier" || family == "courier" || family == "fixed" ) {
xlfd = courier_pickxlfd( request.pixelSize, request.italic, request.weight > 50 );
}
else if ( family == "times new roman" || family == "times" )
xlfd = "-adobe-times-medium-r-normal--8-80-75-75-p-44-iso10646-1";
else if ( family == "ahem" )
xlfd = ahem_pickxlfd( request.pixelSize );
else
xlfd = helv_pickxlfd( request.pixelSize, request.italic, request.weight > 50 );
QFontEngine *fe = 0;
XFontStruct *xfs;
xfs = XLoadQueryFont(TQPaintDevice::x11AppDisplay(), xlfd.latin1() );
if (!xfs) // as long as you don't do screenshots, it's maybe fine
qFatal("we need some fonts. So make sure you have %s installed.", xlfd.latin1());
unsigned long value;
if ( !XGetFontProperty( xfs, XA_FONT, &value ) )
return 0;
char *n = XGetAtomName( TQPaintDevice::x11AppDisplay(), value );
xlfd = n;
if ( n )
XFree( n );
fe = new QFakeFontEngine( xfs, xlfd.latin1(),request.pixelSize );
// qDebug("fe %s ascent %d descent %d minLeftBearing %d leading %d maxCharWidth %d minRightBearing %d", xlfd.latin1(), fe->ascent(), fe->descent(), fe->minLeftBearing(), fe->leading(), fe->maxCharWidth(), fe->minRightBearing());
// fe->setScale( scale );
QFontCache::Key key( request, script, fp->screen
#if QT_VERSION >= 0x030308
, fp->paintdevice
#endif
);
QFontCache::instance->insertEngine( key, fe );
return fe;
}
KDE_EXPORT bool TQFontDatabase::isBitmapScalable( const TQString &,
const TQString &) const
{
return true;
}
KDE_EXPORT bool TQFontDatabase::isSmoothlyScalable( const TQString &,
const TQString &) const
{
return true;
}
const TQString &KHTMLSettings::availableFamilies()
{
if ( !avFamilies ) {
avFamilies = new QString;
*avFamilies = ",Adobe Courier,Arial,Comic Sans MS,Courier,Helvetica,Times,Times New Roman,Utopia,Fixed,Ahem,";
}
return *avFamilies;
}
bool KHTMLSettings::unfinishedImageFrame() const
{
return false;
}
KDE_EXPORT int TQPaintDevice::x11AppDpiY( int )
{
return 100;
}
KDE_EXPORT int TQPaintDevice::x11AppDpiX( int )
{
return 100;
}
KDE_EXPORT void TQFont::insertSubstitution(const TQString &,
const TQString &)
{
}
KDE_EXPORT void TQFont::insertSubstitutions(const TQString &,
const TQStringList &)
{
}
#include <kprotocolinfo.h>
bool KProtocolInfo::isKnownProtocol( const TQString& _protocol )
{
return ( _protocol == "file" );
}
#include <kprotocolinfofactory.h>
TQString KProtocolInfo::exec( const TQString& _protocol )
{
if ( _protocol != "file" )
return TQString::null;
KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol);
if ( !prot )
return TQString::null;
return prot->m_exec;
}
#include <dcopclient.h>
bool DCOPClient::attach()
{
return false;
}
bool DCOPClient::isAttached() const
{
return false;
}
void DCOPClient::processSocketData( int )
{
}
#include <tqapplication.h>
#include <tqpalette.h>
KDE_EXPORT void TQApplication::setPalette( const TQPalette &, bool ,
const char* )
{
static bool done = false;
if (done) return;
TQString xlfd = ahem_pickxlfd(40);
XFontStruct *xfs;
xfs = XLoadQueryFont(TQPaintDevice::x11AppDisplay(), xlfd.latin1() );
if (!xfs) // as long as you don't do screenshots, it's maybe fine
qFatal("We will need some fonts. So make sure you have %s installed.", xlfd.latin1());
XFreeFont(TQPaintDevice::x11AppDisplay(), xfs);
done = true;
}
#include <kapplication.h>
void KApplication::dcopFailure( const TQString & )
{
qDebug( "KApplication::dcopFailure" );
}
#include <kparts/historyprovider.h>
bool KParts::HistoryProvider::contains( const TQString& t ) const
{
return ( t == "http://www.kde.org/" || t == "http://www.google.com/");
}
bool KJSCPUGuard::confirmTerminate()
{
return false;
}
#include <ksslsettings.h>
bool KSSLSettings::warnOnEnter() const { return false; }
bool KSSLSettings::warnOnUnencrypted() const { return false; }
bool KSSLSettings::warnOnLeave() const { return false; }
#include <kparts/plugin.h>
KParts::Plugin* KParts::Plugin::loadPlugin( TQObject * parent, const char* libname ) { return 0; }
|