View | Details | Raw Unified | Return to issue 60594
Collapse All | Expand All

(-)inc/salgdi.h (-2 / +46 lines)
Lines 39-47 Link Here
39
39
40
#include "boost/scoped_ptr.hpp"
40
#include "boost/scoped_ptr.hpp"
41
#include <hash_set>
41
#include <hash_set>
42
#include <hash_map>
43
typedef std::hash_map<int,int> IntMap;
44
45
46
#define USE_UNISCRIBE
47
#ifdef USE_UNISCRIBE
48
#include <Usp10.h>
49
#endif // USE_UNISCRIBE
42
50
43
class ImplFontSelectData;
51
class ImplFontSelectData;
44
class ImplWinFontEntry;
45
class ImplFontAttrCache;
52
class ImplFontAttrCache;
46
53
47
// -----------
54
// -----------
Lines 52-61 Link Here
52
#define PALRGB_TO_RGB(nPalRGB)		((nPalRGB)&0x00ffffff)
59
#define PALRGB_TO_RGB(nPalRGB)		((nPalRGB)&0x00ffffff)
53
60
54
// win32 platform specific options. Move them to the PMK file?
61
// win32 platform specific options. Move them to the PMK file?
55
#define USE_UNISCRIBE
62
56
#define GCP_KERN_HACK
63
#define GCP_KERN_HACK
57
#define GNG_VERT_HACK
64
#define GNG_VERT_HACK
58
65
66
// win32 specific physical font instance
67
class ImplWinFontEntry : public ImplFontEntry
68
{
69
public:
70
                            ImplWinFontEntry( ImplFontSelectData& );
71
                            ~ImplWinFontEntry();
72
73
private:
74
    // TODO: also add HFONT??? Watch out for issues with too many active fonts...
75
76
#ifdef GCP_KERN_HACK
77
public:
78
    bool                    HasKernData() const;
79
    void                    SetKernData( int, const KERNINGPAIR* );
80
    int                     GetKerning( sal_Unicode, sal_Unicode ) const;
81
private:
82
    KERNINGPAIR*            mpKerningPairs;
83
    int                     mnKerningPairs;
84
#endif // GCP_KERN_HACK
85
86
#ifdef USE_UNISCRIBE
87
public:
88
    SCRIPT_CACHE&           GetScriptCache() const
89
                            { return maScriptCache; }
90
	int						GetKashidaWidth( HDC ) const;
91
private:
92
    mutable SCRIPT_CACHE    maScriptCache;
93
#endif // USE_UNISCRIBE
94
95
public:
96
    int                     GetCachedGlyphWidth( int nCharCode ) const;
97
    void                    CacheGlyphWidth( int nCharCode, int nCharWidth );
98
private:
99
    IntMap                  maWidthMap;
100
};
101
102
59
// win32 specific physically available font face
103
// win32 specific physically available font face
60
class ImplWinFontData : public ImplFontData
104
class ImplWinFontData : public ImplFontData
61
{
105
{
(-)source/gdi/salgdi3.cxx (-50 / +3 lines)
Lines 115-154 Link Here
115
// =======================================================================
115
// =======================================================================
116
116
117
// -----------------------------------------------------------------------
117
// -----------------------------------------------------------------------
118
// dynamic loading of usp library
119
// copied from winlayout.cxx
120
121
static oslModule aUspModule = NULL;
122
static bool bUspEnabled = true;
123
124
static HRESULT ((WINAPI *pScriptGetFontProperties)( HDC, SCRIPT_CACHE*, SCRIPT_FONTPROPERTIES* ));
125
static HRESULT ((WINAPI *pScriptFreeCache)( SCRIPT_CACHE* ));
126
127
static bool InitUSP()
128
{
129
    rtl::OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( "usp10" ) );
130
    aUspModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT );
131
    if( !aUspModule )
132
        return (bUspEnabled = false);
133
134
135
    rtl::OUString queryFuncName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScriptGetFontProperties" ) );
136
    pScriptGetFontProperties = (HRESULT (WINAPI*)( HDC,SCRIPT_CACHE*,SCRIPT_FONTPROPERTIES*))
137
        osl_getSymbol( aUspModule, queryFuncName.pData );
138
    bUspEnabled &= (NULL != pScriptGetFontProperties);
139
140
    queryFuncName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScriptFreeCache" ) );
141
    pScriptFreeCache = (HRESULT (WINAPI*)(SCRIPT_CACHE*))
142
        osl_getSymbol( aUspModule, queryFuncName.pData );
143
    bUspEnabled &= (NULL != pScriptFreeCache);
144
145
    if( !bUspEnabled )
146
    {
147
        osl_unloadModule( aUspModule );
148
        aUspModule = NULL;
149
    }
150
    return bUspEnabled;
151
}
152
118
153
// TODO: also support temporary TTC font files
119
// TODO: also support temporary TTC font files
154
typedef std::map< String, ImplDevFontAttributes > FontAttrMap;
120
typedef std::map< String, ImplDevFontAttributes > FontAttrMap;
Lines 1375-1381 Link Here
1375
    }
1341
    }
1376
1342
1377
    DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL");
1343
    DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL");
1378
    mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<ImplWinFontEntry*>( pFont->mpFontEntry );
1344
    mpWinFontEntry[ nFallbackLevel ] = static_cast<ImplWinFontEntry*>( pFont->mpFontEntry );
1379
    mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData );
1345
    mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData );
1380
1346
1381
    HFONT hOldFont = 0;
1347
    HFONT hOldFont = 0;
Lines 1509-1530 Link Here
1509
                pMetric->mnDescent += pMetric->mnExtLeading;
1475
                pMetric->mnDescent += pMetric->mnExtLeading;
1510
    }
1476
    }
1511
1477
1512
    if( mpWinFontData[0] && mpWinFontData[0]->SupportsArabic() )
1478
    if( mpWinFontData[0] && mpWinFontData[0]->SupportsArabic() && mpWinFontEntry[0] )
1513
    {
1479
    {
1514
        if (aUspModule || (bUspEnabled && InitUSP()) )
1480
        pMetric->mnMinKashida = static_cast<int>( mfFontScale * mpWinFontEntry[0]->GetKashidaWidth( mhDC ));
1515
        {
1516
           //ScriptGetFontProperties
1517
           SCRIPT_FONTPROPERTIES aFontProperties;
1518
           SCRIPT_CACHE aScriptCache = NULL; // should use ScriptCache from ImplWinFontEntry
1519
                                             // but how do I get there
1520
           aFontProperties.cBytes = sizeof (aFontProperties);
1521
           HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &aScriptCache, &aFontProperties );
1522
           if( !nRC )
1523
           {
1524
               pMetric->mnMinKashida = static_cast<int>( mfFontScale * aFontProperties.iKashidaWidth);
1525
           }
1526
           (*pScriptFreeCache)( &aScriptCache );
1527
        }
1528
    }
1481
    }
1529
}
1482
}
1530
1483
(-)source/gdi/winlayout.cxx (-55 / +27 lines)
Lines 60-69 Link Here
60
#include <winver.h>
60
#include <winver.h>
61
#endif // USE_UNISCRIBE
61
#endif // USE_UNISCRIBE
62
62
63
#include <hash_map>
63
//#include <hash_map>
64
typedef std::hash_map<int,int> IntMap;
64
//typedef std::hash_map<int,int> IntMap;
65
#include <set>
65
//#include <set>
66
typedef std::set<int> IntSet;
66
//typedef std::set<int> IntSet;
67
67
68
#define DROPPED_OUTGLYPH 0xFFFF
68
#define DROPPED_OUTGLYPH 0xFFFF
69
69
Lines 71-110 Link Here
71
71
72
// =======================================================================
72
// =======================================================================
73
73
74
// win32 specific physical font instance
75
class ImplWinFontEntry : public ImplFontEntry
76
{
77
public:
78
                            ImplWinFontEntry( ImplFontSelectData& );
79
                            ~ImplWinFontEntry();
80
81
private:
82
    // TODO: also add HFONT??? Watch out for issues with too many active fonts...
83
84
#ifdef GCP_KERN_HACK
85
public:
86
    bool                    HasKernData() const;
87
    void                    SetKernData( int, const KERNINGPAIR* );
88
    int                     GetKerning( sal_Unicode, sal_Unicode ) const;
89
private:
90
    KERNINGPAIR*            mpKerningPairs;
91
    int                     mnKerningPairs;
92
#endif // GCP_KERN_HACK
93
74
94
#ifdef USE_UNISCRIBE
95
public:
96
    SCRIPT_CACHE&           GetScriptCache() const
97
                            { return maScriptCache; }
98
private:
99
    mutable SCRIPT_CACHE    maScriptCache;
100
#endif // USE_UNISCRIBE
101
102
public:
103
    int                     GetCachedGlyphWidth( int nCharCode ) const;
104
    void                    CacheGlyphWidth( int nCharCode, int nCharWidth );
105
private:
106
    IntMap                  maWidthMap;
107
};
108
75
109
// -----------------------------------------------------------------------
76
// -----------------------------------------------------------------------
110
77
Lines 1673-1687 Link Here
1673
        }
1640
        }
1674
    }
1641
    }
1675
1642
1676
    //ScriptGetFontProperties
1643
    mnMinKashidaWidth = mrWinFontEntry.GetKashidaWidth ( mhDC );
1677
    SCRIPT_FONTPROPERTIES aFontProperties;
1678
    aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize
1679
    mnMinKashidaWidth = 0;
1680
    HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties );
1681
    if( !nRC )
1682
    {
1683
       mnMinKashidaWidth = aFontProperties.iKashidaWidth;
1684
    }
1685
1644
1686
    // scale layout metrics if needed
1645
    // scale layout metrics if needed
1687
    if( mfFontScale != 1.0 )
1646
    if( mfFontScale != 1.0 )
Lines 2523-2541 Link Here
2523
                nItemWidth += mpCharWidths[ i ];
2482
                nItemWidth += mpCharWidths[ i ];
2524
            nItemWidth = (int)((fStretch - 1.0) * nItemWidth + 0.5);
2483
            nItemWidth = (int)((fStretch - 1.0) * nItemWidth + 0.5);
2525
2484
2526
            SCRIPT_FONTPROPERTIES aFontProperties;
2485
            HRESULT nRC = (*pScriptJustify) (
2527
            aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize
2528
            int nMinKashida = 1;
2529
            HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties );
2530
            if( !nRC )
2531
                nMinKashida = aFontProperties.iKashidaWidth;
2532
2533
            nRC = (*pScriptJustify) (
2534
                mpVisualAttrs + rVisualItem.mnMinGlyphPos,
2486
                mpVisualAttrs + rVisualItem.mnMinGlyphPos,
2535
                mpGlyphAdvances + rVisualItem.mnMinGlyphPos,
2487
                mpGlyphAdvances + rVisualItem.mnMinGlyphPos,
2536
                rVisualItem.mnEndGlyphPos - rVisualItem.mnMinGlyphPos,
2488
                rVisualItem.mnEndGlyphPos - rVisualItem.mnMinGlyphPos,
2537
                nItemWidth,
2489
                nItemWidth,
2538
                nMinKashida,
2490
                mnMinKashidaWidth,
2539
                mpJustifications + rVisualItem.mnMinGlyphPos );
2491
                mpJustifications + rVisualItem.mnMinGlyphPos );
2540
2492
2541
            rVisualItem.mnXOffset = nXOffset;
2493
            rVisualItem.mnXOffset = nXOffset;
Lines 2655-2660 Link Here
2655
    return nKernAmount;
2607
    return nKernAmount;
2656
}
2608
}
2657
2609
2610
// -----------------------------------------------------------------------
2611
2612
int ImplWinFontEntry::GetKashidaWidth( HDC hDC ) const
2613
{
2614
#ifdef USE_UNISCRIBE
2615
	if (aUspModule || (bUspEnabled && InitUSP())) 
2616
	{
2617
		SCRIPT_FONTPROPERTIES aFontProperties;
2618
		aFontProperties.cBytes = sizeof (aFontProperties); 
2619
		SCRIPT_CACHE& rScriptCache = GetScriptCache();
2620
		HRESULT nRC = (*pScriptGetFontProperties)( hDC, &rScriptCache, &aFontProperties );
2621
		if( !nRC )
2622
			return aFontProperties.iKashidaWidth;
2623
    }
2624
#endif // USE_UNISCRIBE
2625
	return 0;
2626
}
2627
2628
2629
2658
// =======================================================================
2630
// =======================================================================
2659
2631
2660
ImplFontData* ImplWinFontData::Clone() const
2632
ImplFontData* ImplWinFontData::Clone() const

Return to issue 60594