summaryrefslogtreecommitdiff
path: root/patches/vclplug/vcl-source-glyphs.diff
blob: b401f7d159a315888d94d2237c06068fe8ad50e0 (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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
Index: vcl/source/glyphs/gcach_ftyp.cxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_ftyp.cxx,v
retrieving revision 1.98.20.2
diff -u -p -u -r1.98.20.2 gcach_ftyp.cxx
--- vcl/source/glyphs/gcach_ftyp.cxx	28 Jan 2004 15:22:42 -0000	1.98.20.2
+++ vcl/source/glyphs/gcach_ftyp.cxx	5 Jul 2004 14:01:28 -0000
@@ -58,13 +59,10 @@
  *
  ************************************************************************/
 
-#if defined(WIN32)
-#ifndef _SV_SVSYS_HXX
-
+#ifdef WNT
 #include <svsys.h>
 #undef CreateFont
 #endif
-#endif
 
 #include <gcach_ftyp.hxx>
 
@@ -72,17 +70,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
@@ -251,15 +258,22 @@ void FtFontFile::Unmap()
 // =======================================================================
 
 FtFontInfo::FtFontInfo( const ImplFontData& rFontData,
-    const ::rtl::OString& rNativeFileName, int nFaceNum, int nFontId, int nSynthetic )
-:   mpFontFile( FtFontFile::FindFontFile( rNativeFileName ) ),
+                        const ::rtl::OString& rNativeFileName,
+                        int nFaceNum, int nFontId, int nSynthetic,
+                        const unicodeKernMap* pKern
+                        )
+:   
     maFontData( rFontData ),
+    mpFontFile( FtFontFile::FindFontFile( rNativeFileName ) ),
     mnFaceNum( nFaceNum ),
-    mnFontId( nFontId ),
     mnSynthetic( nSynthetic ),
+    mnFontId( nFontId ),
     maFaceFT( NULL ),
     mnRefCount( 0 )
 {
+    if( pKern )
+        maUnicodeKernPairs = *pKern;
+
     maFontData.mpSysData = (void*)nFontId;
     maFontData.mpNext    = NULL;
 
@@ -336,6 +350,43 @@ void FtFontInfo::ReleaseFaceFT( FT_FaceR
     }
 }
 
+void FtFontInfo::CacheGlyphIndex( sal_Unicode cChar, int nGI ) const
+{
+    maGlyphMap[ cChar ] = nGI;
+
+    if( maUnicodeKernPairs.size() != maGlyphKernPairs.size() )
+    {
+        // move kerning to glyph kerning map
+        unicodeKernMap::const_iterator left_it =
+            maUnicodeKernPairs.find( cChar );
+        std::map< sal_Unicode, int >::const_iterator right_it;
+        for( left_it = maUnicodeKernPairs.begin(); left_it != maUnicodeKernPairs.end(); ++left_it )
+        {
+            if( left_it->first == cChar )
+            {
+                for( right_it = left_it->second.begin(); right_it != left_it->second.end(); ++right_it )
+                {
+                    int nRightGlyph = GetGlyphIndex( right_it->first );
+                    if( nRightGlyph != -1 )
+                        maGlyphKernPairs[ nGI ][ nRightGlyph ] = right_it->second;
+                }
+            }
+            else
+            {
+                int nLeftGlyph = GetGlyphIndex( left_it->first );
+                if( nLeftGlyph != -1 )
+                {
+                    for( right_it = left_it->second.begin(); right_it != left_it->second.end(); ++right_it )
+                    {
+                        if( right_it->first == cChar )
+                            maGlyphKernPairs[ nLeftGlyph ][ nGI ] = right_it->second;
+                    }
+                }
+            }
+        }
+    }
+}
+
 // -----------------------------------------------------------------------
 
 static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);}
@@ -382,11 +433,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().
@@ -449,7 +499,10 @@ void* FreetypeManager::GetFontHandle( in
 // -----------------------------------------------------------------------
 
 void FreetypeManager::AddFontFile( const rtl::OString& rNormalizedName,
-    int nFaceNum, int nFontId, const ImplFontData* pData )
+                                   int nFaceNum, int nFontId,
+                                   const ImplFontData* pData,
+                                   const unicodeKernMap* pKern
+                                   )
 {
     if( !rNormalizedName.getLength() )
         return;
@@ -457,7 +510,7 @@ void FreetypeManager::AddFontFile( const
     if( maFontList.find( nFontId ) != maFontList.end() )
         return;
 
-    FtFontInfo* pFI = new FtFontInfo( *pData, rNormalizedName, nFaceNum, nFontId, 0 );
+    FtFontInfo* pFI = new FtFontInfo( *pData, rNormalizedName, nFaceNum, nFontId, 0, pKern );
     maFontList[ nFontId ] = pFI;
     if( mnMaxFontId < nFontId )
         mnMaxFontId = nFontId;
@@ -482,8 +535,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();
 
@@ -556,8 +609,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;
@@ -581,7 +647,7 @@ FreetypeServerFont* FreetypeManager::Cre
     if( it != maFontList.end() )
     {
         FtFontInfo* pFI = it->second;
-        FreetypeServerFont* pFont = new FreetypeServerFont( rFSD, pFI );
+        FreetypeServerFont* pFont = new FreetypeServerFont( rFSD, pFI, pFI->GetGlyphKernMap(), pFI->GetUnicodeKernMap() );
         return pFont;
     }
 
@@ -592,8 +658,8 @@ FreetypeServerFont* FreetypeManager::Cre
 // FreetypeServerFont
 // =======================================================================
 
-FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontInfo* pFI )
-:   ServerFont( rFSD ),
+FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontInfo* pFI, const glyphKernMap* pKern, const unicodeKernMap* pUniKern )
+:   ServerFont( rFSD, pKern, pUniKern ),
     mpFontInfo( pFI ),
     maFaceFT( NULL ),
     maSizeFT( NULL ),
@@ -856,23 +944,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;
     }
 
@@ -1049,9 +1137,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 );
@@ -1314,34 +1402,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 ) )
@@ -1409,8 +1469,6 @@ ULONG FreetypeServerFont::GetFontCodeRan
                 *(pCodes++) = cCode;
         }
     }
-#endif
-
     return nRangeCount;
 }
 // -----------------------------------------------------------------------
@@ -1420,7 +1478,10 @@ ULONG FreetypeServerFont::GetFontCodeRan
 int FreetypeServerFont::GetGlyphKernValue( int nGlyphLeft, int nGlyphRight ) const
 {
     if( maSizeFT )
+
         pFTActivateSize( maSizeFT );
+    if( !FT_HAS_KERNING( maFaceFT ) || !FT_IS_SFNT( maFaceFT ) )
+        return ServerFont::GetGlyphKernValue( nGlyphLeft, nGlyphRight );
 
     FT_Vector aKernVal;
     FT_Error rcFT = FT_Get_Kerning( maFaceFT, nGlyphLeft, nGlyphRight,
@@ -1438,7 +1499,7 @@ ULONG FreetypeServerFont::GetKernPairs( 
 
     *ppKernPairs = NULL;
     if( !FT_HAS_KERNING( maFaceFT ) || !FT_IS_SFNT( maFaceFT ) )
-        return 0;
+        return ServerFont::GetKernPairs( ppKernPairs );
 
     // first figure out which glyph pairs are involved in kerning
     ULONG nKernLength = 0;
Index: vcl/source/glyphs/gcach_ftyp.hxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_ftyp.hxx,v
retrieving revision 1.24
retrieving revision 1.27
diff -u -p -u -r1.24 -r1.27
--- vcl/source/glyphs/gcach_ftyp.hxx	4 Jul 2003 12:51:33 -0000	1.24
+++ vcl/source/glyphs/gcach_ftyp.hxx	18 May 2004 10:55:11 -0000	1.27
@@ -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 +85,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 );
 
@@ -104,7 +101,9 @@ class FtFontInfo
 {
 public:
     FtFontInfo( const ImplFontData&, const ::rtl::OString&,
-        int nFaceNum, int nFontId, int nSynthetic );
+                int nFaceNum, int nFontId, int nSynthetic,
+                const unicodeKernMap* pUnicodeKern = NULL
+                );
 
     const unsigned char*  GetTable( const char*, ULONG* pLength=0 ) const;
 
@@ -121,6 +120,11 @@ public:
 
     int                   GetGlyphIndex( sal_Unicode cChar ) const;
     void                  CacheGlyphIndex( sal_Unicode cChar, int nGI ) const;
+    const glyphKernMap*	  GetGlyphKernMap() const
+    { return (maUnicodeKernPairs.size() || maGlyphKernPairs.size()) ? &maGlyphKernPairs : NULL; }
+    const unicodeKernMap* GetUnicodeKernMap() const
+    { return maUnicodeKernPairs.size() ? &maUnicodeKernPairs : NULL; }
+
 
 private:
     ImplFontData    maFontData;
@@ -135,6 +139,9 @@ private:
     // cache unicode->glyphid mapping because looking it up is expensive
     typedef ::std::hash_map<sal_Unicode,int> FIGlyphMap;
     mutable FIGlyphMap maGlyphMap;
+
+    mutable glyphKernMap maGlyphKernPairs;
+    unicodeKernMap maUnicodeKernPairs;
 };
 
 // these two inlines are very important for performance
@@ -147,11 +154,6 @@ inline int FtFontInfo::GetGlyphIndex( sa
     return -1;
 }
 
-inline void FtFontInfo::CacheGlyphIndex( sal_Unicode cChar, int nGI ) const
-{
-    maGlyphMap[ cChar ] = nGI;
-}
-
 // -----------------------------------------------------------------------
 
 class FreetypeManager
@@ -162,7 +164,9 @@ public:
 
     long                AddFontDir( const String& rUrlName );
     void                AddFontFile( const rtl::OString& rNormalizedName,
-                            int nFaceNum, int nFontId, const ImplFontData* );
+                                     int nFaceNum, int nFontId, const ImplFontData*,
+                                     const unicodeKernMap* pKern = NULL
+                                     );
     long                FetchFontList( ImplDevFontList* ) const;
     void                ClearFontList();
 
@@ -182,7 +186,7 @@ private:
 class FreetypeServerFont : public ServerFont
 {
 public:
-                                FreetypeServerFont( const ImplFontSelectData&, FtFontInfo* );
+                                FreetypeServerFont( const ImplFontSelectData&, FtFontInfo*, const glyphKernMap*, const unicodeKernMap* );
     virtual                     ~FreetypeServerFont();
 
     virtual const ::rtl::OString* GetFontFileName() const { return mpFontInfo->GetFontFileName(); }
@@ -206,9 +210,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
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_layout.cxx,v
retrieving revision 1.23.20.1
retrieving revision 1.29
diff -u -p -u -r1.23.20.1 -r1.29
--- vcl/source/glyphs/gcach_layout.cxx	9 Jan 2004 18:13:49 -0000	1.23.20.1
+++ vcl/source/glyphs/gcach_layout.cxx	25 Jun 2004 17:09:25 -0000	1.29
@@ -59,30 +59,29 @@
  ************************************************************************/
 
 #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
 #include <cstdio>
 #endif
@@ -446,6 +446,13 @@
     meScriptCode( USCRIPT_INVALID_CODE )
 {}
 
+void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
+{
+    rSalGraphics.DrawServerFontLayout( *this );
+}
+
+//--------------------------------------------------------------------------
+
 // -----------------------------------------------------------------------
 
 IcuLayoutEngine::~IcuLayoutEngine()
Index: vcl/source/glyphs/gcach_rbmp.cxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_rbmp.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -u -r1.3 -r1.4
--- vcl/source/glyphs/gcach_rbmp.cxx	13 Dec 2001 14:54:19 -0000	1.3
+++ vcl/source/glyphs/gcach_rbmp.cxx	6 Jan 2004 13:58:48 -0000	1.4
@@ -64,7 +64,7 @@
 //------------------------------------------------------------------------
 
 RawBitmap::RawBitmap()
-: mnAllocated(0), mpBits(0)
+: mpBits(0), mnAllocated(0)
 {}
 
 //------------------------------------------------------------------------
Index: vcl/source/glyphs/gcach_vdev.cxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_vdev.cxx,v
retrieving revision 1.11
retrieving revision 1.15
diff -u -p -u -r1.11 -r1.15
--- vcl/source/glyphs/gcach_vdev.cxx	5 Aug 2002 07:19:22 -0000	1.11
+++ vcl/source/glyphs/gcach_vdev.cxx	17 Jun 2004 12:21:43 -0000	1.15
@@ -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 +197,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 +221,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 +231,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 +292,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 +307,7 @@ bool VirtDevServerFont::GetGlyphOutline(
 
 	const bool bOptimize = true;
 	return vdev.GetGlyphOutline( nGlyphIndex, rPolyPoly, bOptimize );
-#endif
+	*/
 }
 
 // =======================================================================
Index: vcl/source/glyphs/gcach_vdev.hxx
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/gcach_vdev.hxx,v
retrieving revision 1.5
retrieving revision 1.7
diff -u -p -u -r1.5 -r1.7
--- vcl/source/glyphs/gcach_vdev.hxx	15 Feb 2002 15:58:57 -0000	1.5
+++ vcl/source/glyphs/gcach_vdev.hxx	4 Feb 2004 15:59:34 -0000	1.7
@@ -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
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/glyphcache.cxx,v
retrieving revision 1.22.40.2
retrieving revision 1.26
diff -u -p -u -r1.22.40.2 -r1.26
--- vcl/source/glyphs/glyphcache.cxx	26 Jan 2004 17:23:59 -0000	1.22.40.2
+++ vcl/source/glyphs/glyphcache.cxx	18 May 2004 10:55:25 -0000	1.26
@@ -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;
 
@@ -219,10 +219,12 @@ void GlyphCache::AddFontPath( const Stri
 // -----------------------------------------------------------------------
 
 void GlyphCache::AddFontFile( const rtl::OString& rNormalizedName, int nFaceNum,
-    int nFontId, const ImplFontData* pFontData )
+                              int nFontId, const ImplFontData* pFontData,
+                              const unicodeKernMap* pKern
+                              )
 {
     if( mpFtManager )
-        mpFtManager->AddFontFile( rNormalizedName, nFaceNum, nFontId, pFontData );
+        mpFtManager->AddFontFile( rNormalizedName, nFaceNum, nFontId, pFontData, pKern );
 }
 
 // -----------------------------------------------------------------------
@@ -337,7 +339,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)
@@ -401,15 +403,17 @@ inline void GlyphCache::RemovingGlyph( S
 // ServerFont
 // =======================================================================
 
-ServerFont::ServerFont( const ImplFontSelectData& rFSD )
+ServerFont::ServerFont( const ImplFontSelectData& rFSD, const glyphKernMap* pKern, const unicodeKernMap* pUniKern )
 :   maFontSelData(rFSD),
     mnExtInfo(0),
     mnRefCount(1),
     mnBytesUsed( sizeof(ServerFont) ),
-    mpNextGCFont( NULL ),
     mpPrevGCFont( NULL ),
+    mpNextGCFont( NULL ),
     nCos( 0x10000),
-    nSin( 0)
+    nSin( 0),
+    mpKernPairs( pKern ),
+    mpUnicodeKernPairs( pUniKern )
 {
     if( rFSD.mnOrientation != 0 )
     {
@@ -440,6 +444,65 @@ long ServerFont::Release() const
 
 // -----------------------------------------------------------------------
 
+int ServerFont::GetGlyphKernValue( int left, int right ) const
+{
+    int kern = 0;
+    if( mpKernPairs )
+    {
+        std::map< int, std::map< int, int > >::const_iterator left_it =
+            mpKernPairs->find( left );
+        if( left_it != mpKernPairs->end() )
+        {
+            std::map< int, int >::const_iterator right_it = left_it->second.find( right );
+            if( right_it != left_it->second.end() )
+                kern = right_it->second;
+        }
+    }
+    return kern*(maFontSelData.mnWidth ? maFontSelData.mnWidth : maFontSelData.mnHeight)/1000;
+}
+
+// -----------------------------------------------------------------------
+
+ULONG ServerFont::GetKernPairs( struct ImplKernPairData** ppKernPairs ) const
+{
+    int nKernEntry = 0;
+    unicodeKernMap::const_iterator left_it;
+    std::map< sal_Unicode, int >::const_iterator right_it;
+    if( mpUnicodeKernPairs )
+    {
+        // count the kern entries
+        for( left_it = mpUnicodeKernPairs->begin(); left_it != mpUnicodeKernPairs->end(); ++left_it )
+        {
+            nKernEntry += left_it->second.size();
+        }
+    }
+
+    // allocate kern pair table
+    if( nKernEntry )
+    {
+        *ppKernPairs = new ImplKernPairData[ nKernEntry ];
+
+        // fill in kern pairs
+        nKernEntry = 0;
+        for( left_it = mpUnicodeKernPairs->begin(); left_it != mpUnicodeKernPairs->end(); ++left_it )
+        {
+            for( right_it = left_it->second.begin(); right_it != left_it->second.end(); ++right_it )
+            {
+                (*ppKernPairs)[ nKernEntry ].mnChar1 = (USHORT)left_it->first;
+                (*ppKernPairs)[ nKernEntry ].mnChar2 = (USHORT)right_it->first;
+                (*ppKernPairs)[ nKernEntry ].mnKern = right_it->second*(maFontSelData.mnWidth ? maFontSelData.mnWidth : maFontSelData.mnHeight)/1000;
+                nKernEntry++;
+            }
+        }
+    }
+    else
+        *ppKernPairs = NULL;
+
+    return (ULONG)nKernEntry;
+}
+
+// -----------------------------------------------------------------------
+
 GlyphData& ServerFont::GetGlyphData( int nGlyphIndex )
 {
     // usually the GlyphData is cached
@@ -465,7 +528,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
===================================================================
RCS file: /cvs/gsl/vcl/source/glyphs/makefile.mk,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -u -r1.5 -r1.6
--- vcl/source/glyphs/makefile.mk	15 Feb 2002 15:52:27 -0000	1.5
+++ vcl/source/glyphs/makefile.mk	6 Jan 2004 14:00:38 -0000	1.6
@@ -76,11 +76,9 @@ TARGET=glyphs
 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 ------------------------------------------------------