summaryrefslogtreecommitdiff
path: root/patches/vclplug/vcl-source-glyphs.diff
blob: 5121c80f165203330ac62e5290832c4007b22d2a (plain)
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
Index: vcl/source/glyphs/gcach_ftyp.cxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_ftyp.cxx,v
retrieving revision 1.98.20.2
Index: vcl/source/glyphs/gcach_ftyp.cxx
===================================================================
--- vcl/source/glyphs/gcach_ftyp.cxx.orig	2004-09-12 14:46:23.000000000 +0200
+++ vcl/source/glyphs/gcach_ftyp.cxx	2004-09-14 13:53:47.306959408 +0200
@@ -58,13 +58,10 @@
  *
  ************************************************************************/
 
-#if defined(WIN32)
-#ifndef _SV_SVSYS_HXX
-
+#ifdef WNT
 #include <svsys.h>
 #undef CreateFont
 #endif
-#endif
 
 #include <gcach_ftyp.hxx>
 
@@ -72,17 +69,25 @@
 #include <outfont.hxx>
 #include <bitmap.hxx>
 #include <bmpacc.hxx>
-#include <poly.hxx>
+
+#ifndef _TL_POLY_HXX
+#include <tools/poly.hxx>
+#endif
 
 #include <osl/file.hxx>
 #include <osl/thread.hxx>
 
-#include "freetype/freetype.h"
-#include "freetype/ftglyph.h"
-#include "freetype/ftoutln.h"
-#include "freetype/tttables.h"
-#include "freetype/tttags.h"
-#include "freetype/ttnameid.h"
+#ifndef INCLUDED_RTL_INSTANCE_HXX
+#include <rtl/instance.hxx>
+#endif
+
+#include "ft2build.h"
+#include  FT_FREETYPE_H
+#include  FT_GLYPH_H
+#include  FT_OUTLINE_H
+#include  FT_TRUETYPE_TABLES_H
+#include  FT_TRUETYPE_TAGS_H
+#include  FT_TRUETYPE_IDS_H
 
 #ifndef FREETYPE_PATCH
     // VERSION_MINOR in freetype.h is too coarse
@@ -258,8 +263,8 @@ FtFontInfo::FtFontInfo( const ImplFontDa
 :   mpFontFile( FtFontFile::FindFontFile( rNativeFileName ) ),
     maFontData( rFontData ),
     mnFaceNum( nFaceNum ),
-    mnFontId( nFontId ),
     mnSynthetic( nSynthetic ),
+    mnFontId( nFontId ),
     maFaceFT( NULL ),
     mnRefCount( 0 )
 {
@@ -425,11 +467,10 @@ const unsigned char* FtFontInfo::GetTabl
 // =======================================================================
 
 FreetypeManager::FreetypeManager()
-:   mnNextFontId( 0x1000 ),
-    mnMaxFontId( 0 )
+:   mnMaxFontId( 0 ), mnNextFontId( 0x1000 )
 {
     FT_Error rcFT = FT_Init_FreeType( &aLibFT );
-   
+  
 #ifdef RTLD_DEFAULT // true if a good dlfcn.h header was included
     // Get version of freetype library to enable workarounds.
     // Freetype <= 2.0.9 does not have FT_Library_Version().
@@ -527,8 +568,8 @@ long FreetypeManager::AddFontDir( const 
         rcOSL = aDirItem.getFileStatus( aFileStatus );
 
         ::rtl::OUString aUSytemPath;
-        OSL_VERIFY(  osl_File_E_None
-            == ::osl::FileBase::getSystemPathFromFileURL( aFileStatus.getFileURL(), aUSytemPath ));
+        OSL_VERIFY(  osl::FileBase::E_None
+            == osl::FileBase::getSystemPathFromFileURL( aFileStatus.getFileURL(), aUSytemPath ));
         ::rtl::OString aCFileName = rtl::OUStringToOString( aUSytemPath, theEncoding );
         const char* pszFontFileName = aCFileName.getStr();
 
@@ -601,8 +642,21 @@ long FreetypeManager::FetchFontList( Imp
     for( FontList::const_iterator it(maFontList.begin()); it != maFontList.end(); ++it, ++nCount )
     {
         const FtFontInfo& rFFI = *it->second;
-        ImplFontData* pFontData = new ImplFontData( rFFI.GetFontData() );
-        pToAdd->Add( pFontData );
+        rtl::OUString aFamilyName = rFFI.GetFontData().maName;
+        sal_Int32 nIndex = 0;
+        rtl::OUString aAliasNames = rFFI.GetFontData().maMapNames;
+        
+        do
+        {
+            ImplFontData* pFontData = new ImplFontData( rFFI.GetFontData() );
+            pFontData->maName = aFamilyName;
+            pFontData->maMapNames.Erase();
+            pToAdd->Add( pFontData );
+            if( nIndex >= 0 )
+                aFamilyName = aAliasNames.getToken( 0, ';', nIndex );
+            else
+                aFamilyName = rtl::OUString();
+        } while( aFamilyName.getLength() );
     }
 
     return nCount;
@@ -903,23 +957,23 @@ int FreetypeServerFont::ApplyGlyphTransf
     case GF_ROTL:    // left
         nAngle += 900;
         bStretched = (mfStretch != 1.0);
-        aVector.x = +rMetrics.descender * mfStretch;
+        aVector.x = (long)((double)+rMetrics.descender * mfStretch);
         aVector.y = -rMetrics.ascender;
-        aMatrix.xx = -nSin / mfStretch;
-        aMatrix.yy = -nSin * mfStretch;
-        aMatrix.xy = -nCos * mfStretch;
-        aMatrix.yx = +nCos / mfStretch;
+        aMatrix.xx = (long)((double)-nSin / mfStretch);
+        aMatrix.yy = (long)((double)-nSin * mfStretch);
+        aMatrix.xy = (long)((double)-nCos * mfStretch);
+        aMatrix.yx = (long)((double)+nCos / mfStretch);
         break;
     case GF_ROTR:    // right
         nAngle -= 900;
         bStretched = (mfStretch != 1.0);
         aVector.x = -maFaceFT->glyph->metrics.horiAdvance;
-        aVector.x += (rMetrics.descender * nSin/65536.0);
-        aVector.y = -(rMetrics.descender * mfStretch * nCos/65536.0);
-        aMatrix.xx = +nSin / mfStretch;
-        aMatrix.yy = +nSin * mfStretch;
-        aMatrix.xy = +nCos * mfStretch;
-        aMatrix.yx = -nCos / mfStretch;
+        aVector.x += (long)((double)rMetrics.descender * nSin/65536.0);
+        aVector.y = -(long)((double)rMetrics.descender * mfStretch * nCos/65536.0);
+        aMatrix.xx = (long)((double)+nSin / mfStretch);
+        aMatrix.yy = (long)((double)+nSin * mfStretch);
+        aMatrix.xy = (long)((double)+nCos * mfStretch);
+        aMatrix.yx = (long)((double)-nCos / mfStretch);
         break;
     }
 
@@ -1096,9 +1150,9 @@ void FreetypeServerFont::InitGlyphData( 
     if( nGlyphFlags & GF_ROTMASK ) {  // for bVertical rotated glyphs
         const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
 #if (FTVERSION < 2000)
-        nCharWidth = (rMetrics.height - rMetrics.descender) * mfStretch;
+        nCharWidth = (long)((double)(rMetrics.height - rMetrics.descender) * mfStretch);
 #else
-        nCharWidth = (rMetrics.height + rMetrics.descender) * mfStretch;
+        nCharWidth = (long)((double)(rMetrics.height + rMetrics.descender) * mfStretch);
 #endif
     }
     rGD.SetCharWidth( (nCharWidth + 32) >> 6 );
@@ -1361,34 +1415,6 @@ ULONG FreetypeServerFont::GetFontCodeRan
 {
     int nRangeCount = 0;
 
-#if 0 && (FTVERSION >= 2102)
-    // TODO: enable new version when it is fast enough for big fonts
-    // TODO: implement Get_Next_Missing_Char() and use this
-    FT_UInt nGlyphIndex = 0;
-    sal_uInt32 aChar = FT_Get_First_Char( maFaceFT, &nGlyphIndex );
-    if( nGlyphIndex )
-        nRangeCount = 1;
-    if( pCodes )
-        *(pCodes++) = aChar;            // start of first range
-    for(;;)
-    {
-        sal_uInt32 bChar = FT_Get_Next_Char( maFaceFT, aChar, &nGlyphIndex );
-        if( !nGlyphIndex )
-            break;
-        if( bChar != aChar+1 )
-        {
-            ++nRangeCount;
-            if( pCodes )
-            {
-                *(pCodes++) = aChar+1;  // end of old range
-                *(pCodes++) = bChar;    // start of new range
-            }
-        }
-        aChar = bChar;
-    }
-    if( pCodes && nRangeCount )
-        *(pCodes++) = aChar+1;          // end of last range
-#else
     const unsigned char* pCmap = NULL;
     ULONG nLength = 0;
     if( FT_IS_SFNT( maFaceFT ) )
@@ -1456,8 +1482,6 @@ ULONG FreetypeServerFont::GetFontCodeRan
                 *(pCodes++) = cCode;
         }
     }
-#endif
-
     return nRangeCount;
 }
 // -----------------------------------------------------------------------
Index: vcl/source/glyphs/gcach_ftyp.hxx
===================================================================
--- vcl/source/glyphs/gcach_ftyp.hxx.orig	2004-09-12 14:46:23.000000000 +0200
+++ vcl/source/glyphs/gcach_ftyp.hxx	2004-09-14 13:53:47.307959256 +0200
@@ -65,11 +65,15 @@
 #include <glyphcache.hxx>
 #include <rtl/textcvt.h>
 
-typedef int FT_Int;
-struct FT_GlyphRec_;
+#include "ft2build.h"
+#include  FT_FREETYPE_H
+#include  FT_GLYPH_H
+#include  FT_OUTLINE_H
+#include  FT_TRUETYPE_TABLES_H
+#include  FT_TRUETYPE_TAGS_H
+#include  FT_TRUETYPE_IDS_H
 class FreetypeServerFont;
-struct FT_FaceRec_;
-struct FT_SizeRec_;
+struct FT_GlyphRec_;
 
 // -----------------------------------------------------------------------
 
@@ -87,7 +91,6 @@ public:
     const unsigned char*    GetBuffer() const { return mpFileMap; }
     int                     GetFileSize() const { return mnFileSize; }
     const ::rtl::OString*   GetFileName() const { return &maNativeFileName; }
-
 private:
                             FtFontFile( const ::rtl::OString& rNativeFileName );
 
@@ -211,9 +222,10 @@ public:
     const unsigned char*        GetTable( const char* pName, ULONG* pLength )
                                 { return mpFontInfo->GetTable( pName, pLength ); }
     int                         GetEmUnits() const;
+    const FT_Size_Metrics&      GetMetricsFT() const { return maSizeFT->metrics; }
 
 protected:
-friend GlyphCache;
+    friend class GlyphCache;
 
     int                         ApplyGlyphTransform( int nGlyphFlags, FT_GlyphRec_* ) const;
     virtual void                InitGlyphData( int nGlyphIndex, GlyphData& ) const;
Index: vcl/source/glyphs/gcach_layout.cxx
===================================================================
--- vcl/source/glyphs/gcach_layout.cxx.orig	2004-09-12 14:26:10.000000000 +0200
+++ vcl/source/glyphs/gcach_layout.cxx	2004-09-14 13:53:47.310958800 +0200
@@ -59,28 +59,27 @@
  ************************************************************************/
 
 #define ENABLE_ICU_LAYOUT
-#if OSL_DEBUG_LEVEL > 1
-//#define VERBOSE_DEBUG
-#endif
-
-#if !defined(_SV_SALUNX_HXX) && !defined(WIN32)
-#include <salunx.h>
-#endif
 
 #ifndef _SV_GCACHFTYP_HXX
-#include <freetype/freetype.h>
 #include <gcach_ftyp.hxx>
 #endif
 
 #ifndef _SV_SALLAYOUT_HXX
 #include <sallayout.hxx>
 #endif
+#ifndef _SV_SALGDI_HXX
+#include <salgdi.hxx>
+#endif
 
 #ifdef WIN32
 #include <malloc.h>
 #define alloca _alloca
-#elif !defined(FREEBSD) && !defined(NETBSD) && !defined(MACOSX)
-#include <alloca.h>
+#elif defined(SOLARIS) || defined(IRIX)
+  #include <alloca.h>
+#else
+#ifndef MACOSX
+  #include <malloc.h>
+#endif
 #endif
 
 #if OSL_DEBUG_LEVEL > 1
@@ -450,6 +449,13 @@ IcuLayoutEngine::IcuLayoutEngine( Freety
     meScriptCode( USCRIPT_INVALID_CODE )
 {}
 
+void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
+{
+    rSalGraphics.DrawServerFontLayout( *this );
+}
+
+//--------------------------------------------------------------------------
+
 // -----------------------------------------------------------------------
 
 IcuLayoutEngine::~IcuLayoutEngine()
Index: vcl/source/glyphs/gcach_rbmp.cxx
===================================================================
--- vcl/source/glyphs/gcach_rbmp.cxx.orig	2004-09-12 14:26:10.000000000 +0200
+++ vcl/source/glyphs/gcach_rbmp.cxx	2004-09-14 13:53:47.311958648 +0200
@@ -64,7 +64,7 @@
 //------------------------------------------------------------------------
 
 RawBitmap::RawBitmap()
-: mnAllocated(0), mpBits(0)
+: mpBits(0), mnAllocated(0)
 {}
 
 //------------------------------------------------------------------------
Index: vcl/source/glyphs/gcach_vdev.cxx
===================================================================
--- vcl/source/glyphs/gcach_vdev.cxx.orig	2004-09-12 14:26:10.000000000 +0200
+++ vcl/source/glyphs/gcach_vdev.cxx	2004-09-14 13:53:47.312958496 +0200
@@ -75,10 +75,6 @@
 
 long VirtDevServerFont::FetchFontList( ImplDevFontList* pToAdd )
 {
-#if 0
-	// TODO: add fonts on server but not on client to the list
-	long nCount = 0;
-#else
 	// TODO: get fonts on server but not on client,
 	// problem is that currently there is no serverside virtual device...
 	VirtualDevice vdev( 1 );
@@ -112,8 +108,6 @@ long VirtDevServerFont::FetchFontList( I
 
 		pToAdd->Add( new ImplFontData( rData ) );	// TODO: avoid copy if possible
 	}
-#endif
-
 	return nCount;
 }
 
@@ -202,13 +196,16 @@ void VirtDevServerFont::InitGlyphData( i
 	vdev.SetFont( aFont );
 
 	// get glyph metrics
-	long nCharWidth = 10;
+	sal_Int32 nCharWidth = 10;
 // TODO:	vdev.GetCharWidth( nGlyphIndex, nGlyphIndex, &nCharWidth );
 	rGD.SetCharWidth( nCharWidth );
 
-	const Rectangle aRect = vdev.GetTextRect( aRect, nGlyphIndex );
+	const Rectangle aRect = vdev.GetTextRect(
+        aRect, String(static_cast< sal_Unicode >(nGlyphIndex)) );
 	rGD.SetOffset( aRect.Top(), aRect.Left() );
-	rGD.SetDelta( vdev.GetTextWidth( nGlyphIndex ), 0 );
+	rGD.SetDelta(
+        vdev.GetTextWidth( String(static_cast< sal_Unicode >(nGlyphIndex)) ),
+        0 );
 	rGD.SetSize( aRect.GetSize() );
 }
 
@@ -223,7 +220,7 @@ bool VirtDevServerFont::GetAntialiasAdvi
 
 bool VirtDevServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& ) const
 {
-#if 0
+	/*
 	// draw bitmap
 	vdev.SetOutputSizePixel( aSize, TRUE );
 	vdev.DrawText( Point(0,0)-rGD.GetMetric().GetOffset(), nGlyphIndex );
@@ -233,9 +230,8 @@ bool VirtDevServerFont::GetGlyphBitmap1(
 	const Bitmap& rBitmap = vdev.GetBitmap( Point(0,0), aSize );
 	rGD.SetBitmap( new Bitmap( rBitmap ) );
 	return true;
-#else
+	*/
 	return false;
-#endif
 }
 
 // -----------------------------------------------------------------------
@@ -295,9 +291,8 @@ ULONG VirtDevServerFont::GetKernPairs( I
 
 bool VirtDevServerFont::GetGlyphOutline( int nGlyphIndex, PolyPolygon& rPolyPoly ) const
 {
-#if 1
 	return false;
-#else
+	/*
     Font aFont;
 	aFont.SetName		( GetFontSelData().maName );
 	aFont.SetStyleName	( GetFontSelData().maStyleName );
@@ -311,7 +306,7 @@ bool VirtDevServerFont::GetGlyphOutline(
 
 	const bool bOptimize = true;
 	return vdev.GetGlyphOutline( nGlyphIndex, rPolyPoly, bOptimize );
-#endif
+	*/
 }
 
 // =======================================================================
Index: vcl/source/glyphs/gcach_vdev.hxx
===================================================================
--- vcl/source/glyphs/gcach_vdev.hxx.orig	2004-09-12 14:26:10.000000000 +0200
+++ vcl/source/glyphs/gcach_vdev.hxx	2004-09-14 13:53:47.312958496 +0200
@@ -72,7 +72,7 @@ public:
 	virtual bool				GetGlyphOutline( int nGlyphIndex, PolyPolygon& ) const;
 
 protected:
-friend GlyphCache;
+    friend class GlyphCache;
 	static long					FetchFontList( ImplDevFontList* );
 	static void					ClearFontList();
 
Index: vcl/source/glyphs/glyphcache.cxx
===================================================================
--- vcl/source/glyphs/glyphcache.cxx.orig	2004-09-12 14:46:23.000000000 +0200
+++ vcl/source/glyphs/glyphcache.cxx	2004-09-14 13:53:47.313958344 +0200
@@ -88,8 +88,8 @@ GlyphCache::GlyphCache( ULONG nMaxSize )
     mnBytesUsed(sizeof(GlyphCache)),
     mnLruIndex(0),
     mnGlyphCount(0),
-    mpFtManager(NULL),
-    mpCurrentGCFont(NULL)
+    mpCurrentGCFont(NULL),
+    mpFtManager(NULL)
 {
     mpFtManager = new FreetypeManager;
 }
@@ -167,7 +167,7 @@ void GlyphCache::RemoveFont( const ImplF
     FontList::iterator it_next = maFontList.begin(), it;
     while( it_next != maFontList.end() )
     {
-	it = it_next++;
+        it = it_next++;
         if( pFontData != it->first.mpFontData )
             continue;
 
@@ -338,7 +338,7 @@ void GlyphCache::GarbageCollect()
             FontList::iterator it_next = maFontList.begin(), it;
             while( it_next != maFontList.end() )
             {
-		it = it_next++;
+                it = it_next++;
                 ServerFont* pSF = it->second;
                 if( (pSF != NULL)
                 &&  (pSF->GetRefCount() <= 0)
@@ -407,8 +407,8 @@ ServerFont::ServerFont( const ImplFontSe
     mnExtInfo(0),
     mnRefCount(1),
     mnBytesUsed( sizeof(ServerFont) ),
-    mpNextGCFont( NULL ),
     mpPrevGCFont( NULL ),
+    mpNextGCFont( NULL ),
     nCos( 0x10000),
     nSin( 0),
     mpKernPairs( pKern ),
@@ -527,7 +586,7 @@ void ServerFont::GarbageCollect( long nM
     GlyphList::iterator it_next = maGlyphList.begin(), it;
     while( it_next != maGlyphList.end() )
     {
-	it = it_next++;
+        it = it_next++;
         GlyphData& rGD = it->second;
         if( (nMinLruIndex - rGD.GetLruValue()) > 0 )
         {
Index: vcl/source/glyphs/makefile.mk
===================================================================
--- vcl/source/glyphs/makefile.mk.orig	2004-09-12 14:26:10.000000000 +0200
+++ vcl/source/glyphs/makefile.mk	2004-09-14 13:53:47.314958192 +0200
@@ -77,11 +77,9 @@ CFLAGS += $(FREETYPE_CFLAGS)
 SLOFILES=\
 		$(SLO)$/glyphcache.obj		\
 		$(SLO)$/gcach_rbmp.obj		\
+		$(SLO)$/gcach_layout.obj	\
 		$(SLO)$/gcach_vdev.obj		\
 		$(SLO)$/gcach_ftyp.obj
-.IF "$(ENABLE_CTL)" != ""
-SLOFILES+=$(SLO)$/gcach_layout.obj
-.ENDIF
 .ENDIF
 
 # --- Targets ------------------------------------------------------