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

(-)openoffice.org.orig/vcl/inc/outdev.h (-1 / +2 lines)
Lines 239-245 Link Here
239
                             const Font& rFont, const Size& rSize, ImplFontSubstEntry* pDevSpecific );
239
                             const Font& rFont, const Size& rSize, ImplFontSubstEntry* pDevSpecific );
240
    ImplFontEntry*      GetFallback( ImplDevFontList* pFontList,
240
    ImplFontEntry*      GetFallback( ImplDevFontList* pFontList,
241
                                     const Font& rFont, const Size& rSize,
241
                                     const Font& rFont, const Size& rSize,
242
                                     int nFallbackLevel );
242
                                     int nFallbackLevel, sal_Unicode *pMissingUnicodes,
243
                                     int nMissingUnicodes );
243
    void                Release( ImplFontEntry* );
244
    void                Release( ImplFontEntry* );
244
    void                Invalidate();
245
    void                Invalidate();
245
};
246
};
(-)openoffice.org.orig/vcl/inc/outfont.hxx (+15 lines)
Lines 252-257 Link Here
252
    ImplDevFontListData*    FindFontFamily( const String& rFontName ) const;
252
    ImplDevFontListData*    FindFontFamily( const String& rFontName ) const;
253
    ImplDevFontListData*    ImplFindByFont( ImplFontSelectData&, bool bPrinter, ImplFontSubstEntry* pDevSpecificSubst ) const;
253
    ImplDevFontListData*    ImplFindByFont( ImplFontSelectData&, bool bPrinter, ImplFontSubstEntry* pDevSpecificSubst ) const;
254
    ImplDevFontListData*    ImplFindBySearchName( const String& ) const;
254
    ImplDevFontListData*    ImplFindBySearchName( const String& ) const;
255
    ImplDevFontListData*    ImplGetFontconfigSubstitute( ImplFontSelectData &rFontSelData, ImplFontSubstEntry* pDevSpecific );
255
256
256
    bool                    HasFallbacks() const;
257
    bool                    HasFallbacks() const;
257
    void                    SetFallbacks( ImplDevFontListData**, int nCount );
258
    void                    SetFallbacks( ImplDevFontListData**, int nCount );
Lines 354-359 Link Here
354
                        ImplFontEntry( const ImplFontSelectData& );
355
                        ImplFontEntry( const ImplFontSelectData& );
355
    virtual             ~ImplFontEntry() {}
356
    virtual             ~ImplFontEntry() {}
356
357
358
    // cache of Unicode characters and replacement font names
359
    typedef ::std::hash_map<sal_Unicode,String> UnicodeFallbackList;
360
    UnicodeFallbackList maUnicodeFallbackList;
361
357
public: // TODO: make data members private
362
public: // TODO: make data members private
358
    ImplFontSelectData  maFontSelData;      // FontSelectionData
363
    ImplFontSelectData  maFontSelData;      // FontSelectionData
359
    ImplFontMetricData  maMetric;           // Font Metric
364
    ImplFontMetricData  maMetric;           // Font Metric
Lines 364-369 Link Here
364
    short               mnOwnOrientation;   // text angle if lower layers don't rotate text themselves
369
    short               mnOwnOrientation;   // text angle if lower layers don't rotate text themselves
365
    short               mnOrientation;      // text angle in 3600 system
370
    short               mnOrientation;      // text angle in 3600 system
366
    bool                mbInit;             // true if maMetric member is valid
371
    bool                mbInit;             // true if maMetric member is valid
372
373
    void                AddFallbackForUnicode( sal_Unicode ch, String fallback )
374
                            { maUnicodeFallbackList[ch] = fallback; }
375
    String              GetFallbackForUnicode( sal_Unicode ch )
376
                            {
377
                                UnicodeFallbackList::const_iterator it = maUnicodeFallbackList.find( ch );
378
                                if ( it != maUnicodeFallbackList.end() )
379
                                    return (*it).second;
380
                                return String();
381
                            }
367
};
382
};
368
383
369
384
(-)openoffice.org.orig/vcl/source/gdi/outdev3.cxx (-90 / +243 lines)
Lines 185-190 Link Here
185
#include <memory>
185
#include <memory>
186
#include <algorithm>
186
#include <algorithm>
187
187
188
#include <psprint/fontmanager.hxx>
189
#include <tools/isolang.hxx>
190
188
// =======================================================================
191
// =======================================================================
189
192
190
DBG_NAMEEX( OutputDevice );
193
DBG_NAMEEX( OutputDevice );
Lines 2670-2675 Link Here
2670
    }
2673
    }
2671
}
2674
}
2672
2675
2676
2677
// -----------------------------------------------------------------------
2678
2679
String GetFcSubstitute(const ImplFontSelectData &rFontSelData, sal_Unicode *pMissingGlyphs=0, int nMissingGlyphs=0)
2680
{
2681
    std::vector<String> aNames;
2682
    if( rFontSelData.GetFamilyName().Len() )
2683
    {
2684
        sal_uInt16 nIndex = 0;
2685
	String aTempName;
2686
        do
2687
        {
2688
                aTempName = GetNextFontToken(rFontSelData.GetFamilyName(), nIndex);
2689
		aNames.push_back(aTempName);
2690
        }
2691
        while (nIndex != STRING_NOTFOUND);
2692
    }
2693
2694
    std::vector<sal_Unicode> aGlyphs;
2695
    for (int i=0; i < nMissingGlyphs; ++i)
2696
	aGlyphs.push_back(pMissingGlyphs[i]);
2697
2698
    ByteString aLangAttrib = ConvertLanguageToIsoByteString( rFontSelData.meLanguage );
2699
2700
    psp::italic::type eItalic = psp::italic::Unknown;
2701
    if( rFontSelData.GetSlant() != ITALIC_DONTKNOW )
2702
    {
2703
        switch( rFontSelData.GetSlant() )
2704
        {
2705
            case ITALIC_NORMAL:  eItalic = psp::italic::Italic; break;
2706
            case ITALIC_OBLIQUE: eItalic = psp::italic::Oblique; break;
2707
            default:
2708
                break;
2709
        }
2710
    }
2711
2712
    psp::weight::type eWeight = psp::weight::Unknown;
2713
    if( rFontSelData.GetWeight() != WEIGHT_DONTKNOW )
2714
    {
2715
        switch( rFontSelData.GetWeight() )
2716
        {
2717
            case WEIGHT_THIN:		eWeight = psp::weight::Thin; break;
2718
            case WEIGHT_ULTRALIGHT:	eWeight = psp::weight::UltraLight; break;
2719
            case WEIGHT_LIGHT:		eWeight = psp::weight::Light; break;
2720
            case WEIGHT_SEMILIGHT:	eWeight = psp::weight::SemiLight; break;
2721
            case WEIGHT_NORMAL:		eWeight = psp::weight::Normal; break;
2722
            case WEIGHT_MEDIUM:		eWeight = psp::weight::Medium; break;
2723
            case WEIGHT_SEMIBOLD:	eWeight = psp::weight::SemiBold; break;
2724
            case WEIGHT_BOLD:		eWeight = psp::weight::Bold; break;
2725
            case WEIGHT_ULTRABOLD:	eWeight = psp::weight::UltraBold; break;
2726
            case WEIGHT_BLACK:		eWeight = psp::weight::Black; break;
2727
            default:
2728
                break;
2729
        }
2730
    }
2731
2732
    psp::width::type eWidth = psp::width::Unknown;
2733
    if( rFontSelData.GetWidthType() != WIDTH_DONTKNOW )
2734
    {
2735
        switch( rFontSelData.GetWidthType() )
2736
        {
2737
            case WIDTH_ULTRA_CONDENSED:	eWidth = psp::width::UltraCondensed; break;
2738
            case WIDTH_EXTRA_CONDENSED: eWidth = psp::width::ExtraCondensed; break;
2739
            case WIDTH_CONDENSED:	eWidth = psp::width::Condensed; break;
2740
            case WIDTH_SEMI_CONDENSED:	eWidth = psp::width::SemiCondensed; break;
2741
            case WIDTH_NORMAL:		eWidth = psp::width::Normal; break;
2742
            case WIDTH_SEMI_EXPANDED:	eWidth = psp::width::SemiExpanded; break;
2743
            case WIDTH_EXPANDED:	eWidth = psp::width::Expanded; break;
2744
            case WIDTH_EXTRA_EXPANDED:	eWidth = psp::width::ExtraExpanded; break;
2745
            case WIDTH_ULTRA_EXPANDED:	eWidth = psp::width::UltraExpanded; break;
2746
            default:
2747
                break;
2748
        }
2749
    }
2750
2751
    psp::pitch::type ePitch = psp::pitch::Unknown;
2752
    if( rFontSelData.GetPitch() != PITCH_DONTKNOW )
2753
    {
2754
        switch(  rFontSelData.GetPitch() )
2755
        {
2756
            case PITCH_FIXED:    ePitch=psp::pitch::Fixed; break;
2757
            case PITCH_VARIABLE: ePitch=psp::pitch::Variable; break;
2758
            default:
2759
                break;
2760
        }
2761
    }
2762
2763
    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
2764
    return rMgr.Substitute(aNames, aGlyphs, aLangAttrib, eItalic, eWeight, eWidth, ePitch);
2765
}
2766
2767
// -----------------------------------------------------------------------
2768
2769
ImplDevFontListData *ImplDevFontList::ImplGetFontconfigSubstitute( ImplFontSelectData &rFontSelData, ImplFontSubstEntry* pDevSpecific )
2770
{
2771
    // We dont' actually want to talk to Fontconfig at all for symbol fonts
2772
    if (rFontSelData.IsSymbolFont())
2773
        return 0;
2774
    // StarSymbol is a unicode font, but it still deserves the symbol flag
2775
    if( 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "starsymbol", 10)
2776
        ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
2777
        return 0;
2778
2779
    String aName(GetFcSubstitute(rFontSelData));
2780
    if (!aName.Len())
2781
        return 0;
2782
2783
    String aUserName(aName);
2784
    ImplGetEnglishSearchFontName( aName );
2785
    ImplFontSubstitute( aName, FONT_SUBSTITUTE_ALWAYS, pDevSpecific );
2786
    ImplDevFontListData *pFontFamily = ImplFindBySearchName( aName );
2787
    if (pFontFamily)
2788
        rFontSelData.maTargetName = aUserName;
2789
2790
    return pFontFamily;
2791
}
2792
2793
2673
// -----------------------------------------------------------------------
2794
// -----------------------------------------------------------------------
2674
2795
2675
ImplFontEntry* ImplFontCache::Get( ImplDevFontList* pFontList,
2796
ImplFontEntry* ImplFontCache::Get( ImplDevFontList* pFontList,
Lines 2707-2714 Link Here
2707
2828
2708
    if( !pEntry ) // no direct cache hit
2829
    if( !pEntry ) // no direct cache hit
2709
    {
2830
    {
2710
        // find the best matching logical font family and update font selector accordingly
2831
        pFontFamily = pFontList->ImplGetFontconfigSubstitute( aFontSelData, pDevSpecific );
2711
        pFontFamily = pFontList->ImplFindByFont( aFontSelData, mbPrinter, pDevSpecific );
2832
        if (!pFontFamily)
2833
        {
2834
            // find the best matching logical font family and update font selector accordingly
2835
            pFontFamily = pFontList->ImplFindByFont( aFontSelData, mbPrinter, pDevSpecific );
2836
        }
2712
        DBG_ASSERT( (pFontFamily != NULL), "ImplFontCache::Get() No logical font found!" );
2837
        DBG_ASSERT( (pFontFamily != NULL), "ImplFontCache::Get() No logical font found!" );
2713
        aFontSelData.maSearchName = pFontFamily->GetSearchName();
2838
        aFontSelData.maSearchName = pFontFamily->GetSearchName();
2714
2839
Lines 3028-3136 Link Here
3028
// -----------------------------------------------------------------------
3153
// -----------------------------------------------------------------------
3029
3154
3030
ImplFontEntry* ImplFontCache::GetFallback( ImplDevFontList* pFontList,
3155
ImplFontEntry* ImplFontCache::GetFallback( ImplDevFontList* pFontList,
3031
    const Font& rOrigFont, const Size& rSize, int nFallbackLevel )
3156
    const Font& rOrigFont, const Size& rSize, int nFallbackLevel,
3157
    sal_Unicode *pMissingUnicodes, int nMissingUnicodes )
3032
{
3158
{
3033
    // make sure the fontlist knows it's fallbacks
3159
    ImplFontEntry*      pFallbackFont = NULL;
3034
    if( !pFontList->HasFallbacks() )
3160
    bool                cached = false;
3161
    bool                new_entry = false;
3162
    bool                symbolFont = false;
3163
    ImplFontEntry*      pOrigFontEntry = Get( pFontList, rOrigFont, rSize, NULL );
3164
    ImplFontSelectData  aSelData( rOrigFont, rOrigFont.GetName(), rSize );
3165
    sal_uInt16          nToken = 0;
3166
    String              aOrigFontName( GetNextFontToken(rOrigFont.GetName(), nToken) );
3167
3168
    const FontSubstConfigItem& rFontSubst = *FontSubstConfigItem::get();
3169
    const FontNameAttr* fontAttr = rFontSubst.getSubstInfo( aOrigFontName );
3170
3171
    // We dont' actually want to talk to Fontconfig at all for symbol fonts
3172
    if ( pFontList && fontAttr && (fontAttr->Type & IMPL_FONT_ATTR_SYMBOL) )
3035
    {
3173
    {
3036
        // normalized family names of fonts suited for glyph fallback
3174
        if ( fontAttr->Substitutions.size() )
3037
        // if a font is available related fonts can be ignored
3038
        // TODO: implement dynamic lists
3039
        static const char* aGlyphFallbackList[] = {
3040
            // empty strings separate the names of unrelated fonts
3041
            "eudc", "",
3042
            "arialunicodems", "cyberbit", "code2000", "",
3043
            "andalesansui", "",
3044
            "starsymbol", "opensymbol", "",
3045
            "msmincho", "fzmingti", "fzheiti", "ipamincho", "sazanamimincho", "kochimincho", "",
3046
            "sunbatang", "sundotum", "baekmukdotum", "gulim", "batang", "dotum", "",
3047
            "hgmincholightj", "msunglightsc", "msunglighttc", "hymyeongjolightk", "",
3048
            "tahoma", "timesnewroman", "lucidatypewriter", "lucidasans", "nimbussansl", "",
3049
            "shree", "mangal", "raavi", "shruti", "tunga", "latha", "",
3050
            "shayyalmt", "naskmt", "",
3051
            "david", "nachlieli", "lucidagrande", "",
3052
            "norasi", "angsanaupc", "",
3053
            0
3054
        };
3055
3056
        int nMaxLevel = 0;
3057
        int nBestQuality = 0;
3058
        ImplDevFontListData** pFallbackList = NULL;
3059
        for( const char** ppNames = &aGlyphFallbackList[0];; ++ppNames )
3060
        {
3175
        {
3061
            // advance to next sub-list when end-of-sublist marker
3176
            ::std::vector< String >::const_iterator it = fontAttr->Substitutions.begin();
3062
            if( !**ppNames )    // #i46456# check for empty string, i.e., deref string itself not only ptr to it
3177
            while ( it != fontAttr->Substitutions.end() )
3063
            {
3178
            {
3064
                if( nBestQuality > 0 )
3179
                // Since *it is the "search name" like "standardsymbolsl"
3065
                    if( ++nMaxLevel >= MAX_FALLBACK )
3180
                // we have to find the Family Name (Standard Symbols L) for Fontconfig
3066
                        break;
3181
                ImplDevFontListData* pFontFamily = pFontList->FindFontFamily( *it );
3067
                if( !ppNames[1] )
3182
                if (pFontFamily)
3183
                {
3184
                    aSelData.maSearchName = pFontFamily->GetFamilyName();
3068
                    break;
3185
                    break;
3069
                nBestQuality = 0;
3186
                }
3070
                continue;
3187
                ++it;
3071
            }
3188
            }
3189
        }
3190
        symbolFont = true;
3191
        cached = true;
3192
    }
3072
3193
3073
            // test if the glyph fallback candidate font is available and scalable
3194
    // Try cached fallbacks first
3074
            String aTokenName( *ppNames, RTL_TEXTENCODING_UTF8 );
3195
    if ( !symbolFont && (nMissingUnicodes > 0) )
3075
            ImplDevFontListData* pFallbackFont = pFontList->FindFontFamily( aTokenName );
3196
    {
3076
            if( !pFallbackFont )
3197
        aSelData.maSearchName = pOrigFontEntry->GetFallbackForUnicode( pMissingUnicodes[0] );
3077
                continue;
3198
        if ( aSelData.maSearchName.Len() )
3078
            if( !pFallbackFont->IsScalable() )
3199
            cached = true;
3079
                continue;
3200
    }
3080
3201
3081
            // keep the best font of the glyph fallback sub-list
3202
    if ( !cached )
3082
            if( nBestQuality < pFallbackFont->GetMinQuality() )
3203
    {
3083
            {
3204
        String aName(GetFcSubstitute( aSelData, pMissingUnicodes, nMissingUnicodes ));
3084
                nBestQuality = pFallbackFont->GetMinQuality();
3205
	if (aName.Len())
3085
                // store available glyph fallback fonts
3206
            aSelData.maSearchName = aName;
3086
                if( !pFallbackList )
3207
    }
3087
                    pFallbackList = new ImplDevFontListData*[ MAX_FALLBACK ];
3088
                pFallbackList[ nMaxLevel ] = pFallbackFont;
3089
            }
3090
        }
3091
3208
3092
        // sort the fonts for glyph fallback by quality (highest first)
3209
    // Check our font instance cache first, if not found then
3093
        // an insertion sort is good enough for this short list
3210
    // add this ImplFontSelectData to the cache along with its ImplFontEntry
3094
        for( int i = 1, j; i < nMaxLevel; ++i )
3211
    FontInstanceList::const_iterator it = maFontInstanceList.find( aSelData );
3095
        {
3212
    if (it != maFontInstanceList.end())
3096
            ImplDevFontListData* pTestFont = pFallbackList[ i ];
3213
        pFallbackFont = (*it).second;
3097
            int nTestQuality = pTestFont->GetMinQuality();
3214
    else
3098
            for( j = i; --j >= 0; )
3215
    {
3099
                if( nTestQuality > pFallbackList[j]->GetMinQuality() )
3216
        // find the best matching physical font face
3100
                    pFallbackList[ j+1 ] = pFallbackList[ j ];
3217
        ImplDevFontListData* pFontFamily = pFontList->FindFontFamily( aSelData.maSearchName );
3101
                else
3218
        if (pFontFamily)
3102
                    break;
3219
        {
3103
            pFallbackList[ j+1 ] = pTestFont;
3220
            ImplFontData* pFontData = pFontFamily->FindBestFontFace( aSelData );
3104
        }
3105
3221
3106
#if defined(HDU_DEBUG)
3222
            // create a new logical font instance from this physical font face
3107
        for( int i = 0; i < nMaxLevel; ++i )
3223
            aSelData.mpFontData = pFontData;
3224
            pFallbackFont = pFontData->CreateFontInstance( aSelData );
3225
3226
            // if we found a different symbol font we need a symbol conversion table
3227
            if( pFontData->IsSymbolFont() )
3228
                if( aSelData.maTargetName != aSelData.maSearchName )
3229
                    pFallbackFont->mpConversion = ImplGetRecodeData( aSelData.maTargetName, aSelData.maSearchName );
3230
3231
            // add the new entry to the cache
3232
            maFontInstanceList[ aSelData ] = pFallbackFont;
3233
            new_entry = true;
3234
        }
3235
        else
3108
        {
3236
        {
3109
            ImplDevFontListData* pFont = pFallbackList[ i ];
3237
            ByteString l( aSelData.maSearchName, RTL_TEXTENCODING_UTF8 );
3110
            ByteString aFontName( pFont->GetFamilyName(), RTL_TEXTENCODING_UTF8 );
3238
            fprintf (stderr, "--- Couldn't get FontFamily for '%s'\n", l.GetBuffer());
3111
            fprintf( stderr, "GlyphFallbackFont[%d] (quality=%05d): \"%s\"\n",
3112
                i, pFont->GetMinQuality(), aFontName.GetBuffer() );
3113
        }
3239
        }
3114
#endif
3115
3116
        pFontList->SetFallbacks( pFallbackList, nMaxLevel );
3117
    }
3240
    }
3118
3241
3119
    Font aFallbackFont = rOrigFont;
3242
    // Cache the fallback font for each of the missing Unicode chars
3120
3243
    if ( !symbolFont && aSelData.maSearchName.Len() )
3121
    // nFallbackLevel==0 => original font without device specific substitution
3122
    // nFallbackLevel>=1 => use a font from the glyph fallback font list
3123
    if( nFallbackLevel>=1 )
3124
    {
3244
    {
3125
        ImplDevFontListData* pFallbackData = pFontList->GetFallback( nFallbackLevel-1 );
3245
        for ( int i = 0; i < nMissingUnicodes; i++ )
3126
        if( !pFallbackData )
3246
        {
3127
            return NULL;
3247
            if ( ! pOrigFontEntry->GetFallbackForUnicode(pMissingUnicodes[i]).Len() )
3128
3248
                pOrigFontEntry->AddFallbackForUnicode( pMissingUnicodes[i], aSelData.maSearchName );
3129
        aFallbackFont.SetName( pFallbackData->GetSearchName() );
3249
        }
3130
    }
3250
    }
3131
3251
3132
    ImplFontEntry* pFallbackFont = Get( pFontList, aFallbackFont, rSize, NULL );
3133
3134
    if( pFallbackFont && !pFallbackFont->mbInit )
3252
    if( pFallbackFont && !pFallbackFont->mbInit )
3135
    {
3253
    {
3136
        // HACK: maMetrics are irrelevant for fallback fonts, but
3254
        // HACK: maMetrics are irrelevant for fallback fonts, but
Lines 3139-3144 Link Here
3139
        pFallbackFont->maMetric.maStyleName = String();
3257
        pFallbackFont->maMetric.maStyleName = String();
3140
    }
3258
    }
3141
3259
3260
    if ( pFallbackFont && !new_entry )
3261
    {
3262
        // increase the font instance's reference count
3263
        if( !pFallbackFont->mnRefCount++ )
3264
            --mnRef0Count;
3265
    }
3266
3267
#if 0
3268
    sal_uInt16 nTok = 0;
3269
    ByteString n( GetNextFontToken(rOrigFont.GetName(), nTok), RTL_TEXTENCODING_UTF8);
3270
    ByteString m;
3271
    if (pFallbackFont)
3272
    {
3273
        nTok = 0;
3274
        ByteString tS( GetNextFontToken(pFallbackFont->maFontSelData.mpFontData->GetFamilyName(), nTok), RTL_TEXTENCODING_UTF8 );
3275
        m.Assign( tS );
3276
    }
3277
    fprintf (stderr, "Glyph fallback '%s'->'%s' %s\n", n.GetBuffer(), pFallbackFont ? m.GetBuffer() : "none",
3278
                new_entry ? "(new)" : "(cached)");
3279
#endif
3280
3142
    return pFallbackFont;
3281
    return pFallbackFont;
3143
}
3282
}
3144
3283
Lines 6105-6111 Link Here
6105
    // do glyph fallback if needed
6244
    // do glyph fallback if needed
6106
    // #105768# avoid fallback for very small font sizes
6245
    // #105768# avoid fallback for very small font sizes
6107
    if( aLayoutArgs.NeedFallback() )
6246
    if( aLayoutArgs.NeedFallback() )
6108
        if( mpFontEntry && (mpFontEntry->maFontSelData.mnHeight >= 6) )
6247
        if( mpFontEntry && (mpFontEntry->maFontSelData.mnHeight >= 3) )
6109
            pSalLayout = ImplGlyphFallbackLayout( pSalLayout, aLayoutArgs );
6248
            pSalLayout = ImplGlyphFallbackLayout( pSalLayout, aLayoutArgs );
6110
6249
6111
    // position, justify, etc. the layout
6250
    // position, justify, etc. the layout
Lines 6149-6154 Link Here
6149
        rLayoutArgs.ResetPos();
6288
        rLayoutArgs.ResetPos();
6150
    }
6289
    }
6151
#endif
6290
#endif
6291
    int nCharPos = -1;
6292
    bool bRTL = false;
6293
    sal_Unicode *pMissingUnicodes = new sal_Unicode[8];
6294
    int nMissingUnicodes = 0;
6295
6296
    for( int i=0; i<8 && rLayoutArgs.GetNextPos( &nCharPos, &bRTL); ++i )
6297
    {
6298
        pMissingUnicodes[i] = rLayoutArgs.mpStr[ nCharPos ];
6299
        nMissingUnicodes++;
6300
    }
6301
    rLayoutArgs.ResetPos();
6152
6302
6153
    ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData;
6303
    ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData;
6154
    Size aFontSize( aFontSelData.mnWidth, aFontSelData.mnHeight );
6304
    Size aFontSize( aFontSelData.mnWidth, aFontSelData.mnHeight );
Lines 6165-6171 Link Here
6165
    {
6315
    {
6166
        // find a font family suited for glyph fallback
6316
        // find a font family suited for glyph fallback
6167
        ImplFontEntry* pFallbackFont = mpFontCache->GetFallback( mpFontList,
6317
        ImplFontEntry* pFallbackFont = mpFontCache->GetFallback( mpFontList,
6168
            maFont, aFontSize, nFallbackLevel-nDevSpecificFallback );
6318
            maFont, aFontSize, nFallbackLevel-nDevSpecificFallback,
6319
            (nMissingUnicodes ? pMissingUnicodes : NULL), nMissingUnicodes );
6169
        if( !pFallbackFont )
6320
        if( !pFallbackFont )
6170
            break;
6321
            break;
6171
6322
Lines 6217-6222 Link Here
6217
            break;
6368
            break;
6218
    }
6369
    }
6219
6370
6371
    delete[] pMissingUnicodes;
6372
6220
    if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
6373
    if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
6221
        pSalLayout = pMultiSalLayout;
6374
        pSalLayout = pMultiSalLayout;
6222
    
6375
    
(-)openoffice.org.orig/vcl/source/window/window.cxx (+5 lines)
Lines 212-217 Link Here
212
#endif
212
#endif
213
213
214
#include <pdfextoutdevdata.hxx>
214
#include <pdfextoutdevdata.hxx>
215
#include <psprint/fontmanager.hxx>
215
216
216
using namespace rtl;
217
using namespace rtl;
217
using namespace ::com::sun::star::uno;
218
using namespace ::com::sun::star::uno;
Lines 350-355 Link Here
350
{
351
{
351
    ImplInitFontList();
352
    ImplInitFontList();
352
353
354
    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
355
    if (rMgr.hasFontconfig())
356
        return true;
357
353
    String aTestText;
358
    String aTestText;
354
    aTestText.Append( Button::GetStandardText( BUTTON_OK ) );
359
    aTestText.Append( Button::GetStandardText( BUTTON_OK ) );
355
    aTestText.Append( Button::GetStandardText( BUTTON_CANCEL ) );
360
    aTestText.Append( Button::GetStandardText( BUTTON_CANCEL ) );
(-)openoffice.org.orig/vcl/util/makefile.mk (-1 / +1 lines)
Lines 265-271 Link Here
265
.ENDIF
265
.ENDIF
266
266
267
267
268
SHL1STDLIBS += -lX11
268
SHL1STDLIBS += -lX11 -lpsp$(VERSION)$(DLLPOSTFIX)
269
269
270
.ENDIF          # "$(GUI)"=="UNX"
270
.ENDIF          # "$(GUI)"=="UNX"
271
271
(-)openoffice.org.orig/psprint/uinc/psprint/fontmanager.hxx (-2 / +11 lines)
Lines 75-80 Link Here
75
#ifndef _PSPRINT_HELPER_HXX_
75
#ifndef _PSPRINT_HELPER_HXX_
76
#include <psprint/helper.hxx>
76
#include <psprint/helper.hxx>
77
#endif
77
#endif
78
#ifndef _STRING_HXX
79
#include <tools/string.hxx>
80
#endif
78
81
79
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
82
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
80
#include <com/sun/star/lang/Locale.hpp>
83
#include <com/sun/star/lang/Locale.hpp>
Lines 419-424 Link Here
419
    std::hash_multimap< sal_uInt8, sal_Unicode >	m_aAdobecodeToUnicode;
422
    std::hash_multimap< sal_uInt8, sal_Unicode >	m_aAdobecodeToUnicode;
420
423
421
    mutable FontCache*							m_pFontCache;
424
    mutable FontCache*							m_pFontCache;
425
    bool m_bFontconfigSuccess;
422
        
426
        
423
    rtl::OString getAfmFile( PrintFont* pFont ) const;
427
    rtl::OString getAfmFile( PrintFont* pFont ) const;
424
    rtl::OString getFontFile( PrintFont* pFont ) const;
428
    rtl::OString getFontFile( PrintFont* pFont ) const;
Lines 504-513 Link Here
504
    const rtl::OUString& getPSName( fontID nFontID ) const;
508
    const rtl::OUString& getPSName( fontID nFontID ) const;
505
509
506
    // get a specific fonts style family
510
    // get a specific fonts style family
507
    family::type PrintFontManager::getFontFamilyType( fontID nFontID ) const;
511
    family::type getFontFamilyType( fontID nFontID ) const;
508
512
509
    // get a specific fonts family name aliases
513
    // get a specific fonts family name aliases
510
    void PrintFontManager::getFontFamilyAliases( fontID nFontID ) const;
514
    void getFontFamilyAliases( fontID nFontID ) const;
511
        
515
        
512
    // get a specific fonts type
516
    // get a specific fonts type
513
    fonttype::type getFontType( fontID nFontID ) const
517
    fonttype::type getFontType( fontID nFontID ) const
Lines 729-734 Link Here
729
    false else
733
    false else
730
     */
734
     */
731
    bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
735
    bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
736
737
    String Substitute(const std::vector<String> &rNames, const std::vector<sal_Unicode> &rGlyphs, 
738
        const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight, 
739
        width::type eWidth, pitch::type ePitch) const;
740
    bool hasFontconfig() const { return m_bFontconfigSuccess; }
732
};
741
};
733
742
734
} // namespace
743
} // namespace
(-)openoffice.org.orig/psprint/usource/fontmanager/fontcache.cxx (-1 / +1 lines)
Lines 688-696 Link Here
688
        FontDirMap::const_iterator entry = dir->second.m_aEntries.find( rFile );
688
        FontDirMap::const_iterator entry = dir->second.m_aEntries.find( rFile );
689
        if( entry != dir->second.m_aEntries.end() )
689
        if( entry != dir->second.m_aEntries.end() )
690
        {
690
        {
691
            bSuccess = true;
692
            for( FontCacheEntry::const_iterator font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
691
            for( FontCacheEntry::const_iterator font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
693
            {
692
            {
693
                bSuccess = true;
694
                PrintFontManager::PrintFont* pFont = clonePrintFont( *font );
694
                PrintFontManager::PrintFont* pFont = clonePrintFont( *font );
695
                rNewFonts.push_back( pFont );
695
                rNewFonts.push_back( pFont );
696
            }
696
            }
(-)openoffice.org.orig/psprint/usource/fontmanager/fontconfig.cxx (-64 / +204 lines)
Lines 70-79 Link Here
70
typedef void FcObjectSet;
70
typedef void FcObjectSet;
71
typedef void FcPattern;
71
typedef void FcPattern;
72
typedef void FcFontSet;
72
typedef void FcFontSet;
73
typedef void FcCharSet;
73
typedef int FcResult;
74
typedef int FcResult;
74
typedef int FcBool;
75
typedef int FcBool;
75
typedef int FcMatchKind;
76
typedef int FcMatchKind;
76
typedef char FcChar8;
77
typedef char FcChar8;
78
typedef sal_Int32 FcChar32;
77
#endif
79
#endif
78
80
79
#include <cstdio>
81
#include <cstdio>
Lines 106-111 Link Here
106
{
108
{
107
    void*			m_pLib;
109
    void*			m_pLib;
108
    FcConfig*		m_pDefConfig;
110
    FcConfig*		m_pDefConfig;
111
    FcFontSet*      m_pOutlineSet;
109
112
110
	FcBool          (*m_pFcInit)();
113
	FcBool          (*m_pFcInit)();
111
    FcConfig*		(*m_pFcConfigGetCurrent)();
114
    FcConfig*		(*m_pFcConfigGetCurrent)();
Lines 114-130 Link Here
114
    FcPattern*		(*m_pFcPatternCreate)();
117
    FcPattern*		(*m_pFcPatternCreate)();
115
    void			(*m_pFcPatternDestroy)(FcPattern*);
118
    void			(*m_pFcPatternDestroy)(FcPattern*);
116
    FcFontSet*		(*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*);
119
    FcFontSet*		(*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*);
120
    FcFontSet*      (*m_pFcConfigGetFonts)(FcConfig*,FcSetName);
117
    FcFontSet*		(*m_pFcFontSetCreate)();
121
    FcFontSet*		(*m_pFcFontSetCreate)();
122
    FcCharSet*		(*m_pFcCharSetCreate)();
123
    FcBool			(*m_pFcCharSetAddChar)(FcCharSet *, FcChar32);
118
    void			(*m_pFcFontSetDestroy)(FcFontSet*);
124
    void			(*m_pFcFontSetDestroy)(FcFontSet*);
119
    FcBool			(*m_pFcFontSetAdd)(FcFontSet*,FcPattern*);
125
    FcBool			(*m_pFcFontSetAdd)(FcFontSet*,FcPattern*);
126
    void            (*m_pFcPatternReference)(FcPattern*);
120
    FcResult		(*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**);
127
    FcResult		(*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**);
121
    FcResult		(*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*);
128
    FcResult		(*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*);
122
    FcResult		(*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*);
129
    FcResult		(*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*);
123
    FcResult		(*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*);
130
    FcResult		(*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*);
124
    void			(*m_pFcDefaultSubstitute)(FcPattern *);
131
    void			(*m_pFcDefaultSubstitute)(FcPattern *);
125
    FcPattern*		(*m_pFcFontMatch)(FcConfig*,FcPattern*,FcResult*);    
132
    FcPattern*      (*m_pFcFontSetMatch)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*);
126
    FcBool			(*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind);
133
    FcBool			(*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind);
127
    FcBool			(*m_pFcPatternAddInteger)(FcPattern*,const char*,int);
134
    FcBool			(*m_pFcPatternAddInteger)(FcPattern*,const char*,int);
135
    FcBool			(*m_pFcPatternAddBool)(FcPattern*,const char*,FcBool);
136
    FcBool			(*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*);
128
    FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
137
    FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
129
138
130
    void* loadSymbol( const char* );
139
    void* loadSymbol( const char* );
Lines 140-145 Link Here
140
    { return m_pLib != NULL;}
149
    { return m_pLib != NULL;}
141
150
142
    FcConfig* getDefConfig() { return m_pDefConfig; }
151
    FcConfig* getDefConfig() { return m_pDefConfig; }
152
    FcFontSet* getFontSet() { return m_pOutlineSet; }
143
153
144
    FcBool FcInit()
154
    FcBool FcInit()
145
    { return m_pFcInit(); }
155
    { return m_pFcInit(); }
Lines 169-182 Link Here
169
    
179
    
170
    FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet )
180
    FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet )
171
    { return m_pFcFontList( pConfig, pPattern, pSet ); }
181
    { return m_pFcFontList( pConfig, pPattern, pSet ); }
172
    
182
183
    FcFontSet* FcConfigGetFonts( FcConfig* pConfig, FcSetName eSet)
184
    { return m_pFcConfigGetFonts( pConfig, eSet ); }
185
173
    FcFontSet* FcFontSetCreate()
186
    FcFontSet* FcFontSetCreate()
174
    { return m_pFcFontSetCreate(); }
187
    { return m_pFcFontSetCreate(); }
188
189
    FcCharSet* FcCharSetCreate()
190
    { return m_pFcCharSetCreate(); }
191
192
    FcBool FcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4)
193
    { return m_pFcCharSetAddChar(fcs, ucs4); }
194
175
    void FcFontSetDestroy( FcFontSet* pSet )
195
    void FcFontSetDestroy( FcFontSet* pSet )
176
    { m_pFcFontSetDestroy( pSet );}
196
    { m_pFcFontSetDestroy( pSet );}
197
177
    FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern )
198
    FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern )
178
    { return m_pFcFontSetAdd( pSet, pPattern ); }
199
    { return m_pFcFontSetAdd( pSet, pPattern ); }
179
200
201
    void FcPatternReference( FcPattern* pPattern )
202
    { m_pFcPatternReference( pPattern ); }
203
180
    FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s )
204
    FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s )
181
    { return m_pFcPatternGetString( pPattern, object, n, s ); }
205
    { return m_pFcPatternGetString( pPattern, object, n, s ); }
182
206
Lines 190-201 Link Here
190
    { return m_pFcPatternGetBool( pPattern, object, n, s ); }
214
    { return m_pFcPatternGetBool( pPattern, object, n, s ); }
191
    void FcDefaultSubstitute( FcPattern* pPattern )
215
    void FcDefaultSubstitute( FcPattern* pPattern )
192
    { m_pFcDefaultSubstitute( pPattern ); }
216
    { m_pFcDefaultSubstitute( pPattern ); }
193
    FcPattern* FcFontMatch( FcConfig* pConfig, FcPattern* pPattern, FcResult* pResult )
217
    FcPattern* FcFontSetMatch(FcConfig* pConfig, FcFontSet** ppFontSet, int nset, FcPattern *pPattern, FcResult *pResult)
194
    { return m_pFcFontMatch( pConfig, pPattern, pResult ); }
218
    { return m_pFcFontSetMatch( pConfig, ppFontSet, nset, pPattern, pResult ); }
195
    FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind )
219
    FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind )
196
    { return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); }
220
    { return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); }
197
    FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue )
221
    FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue )
198
    { return m_pFcPatternAddInteger( pPattern, pObject, nValue ); }
222
    { return m_pFcPatternAddInteger( pPattern, pObject, nValue ); }
223
    FcBool FcPatternAddBool( FcPattern* pPattern, const char* pObject, FcBool b )
224
    { return m_pFcPatternAddBool( pPattern, pObject, b ); }
225
    FcBool FcPatternAddCharSet( FcPattern* pPattern, const char* pObject, const FcCharSet *c)
226
    { return m_pFcPatternAddCharSet( pPattern, pObject, c ); }
199
    FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString )
227
    FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString )
200
    { return m_pFcPatternAddString( pPattern, pObject, pString ); }
228
    { return m_pFcPatternAddString( pPattern, pObject, pString ); }
201
};
229
};
Lines 212-218 Link Here
212
240
213
FontCfgWrapper::FontCfgWrapper()
241
FontCfgWrapper::FontCfgWrapper()
214
        : m_pLib( NULL ),
242
        : m_pLib( NULL ),
215
          m_pDefConfig( NULL )
243
          m_pDefConfig( NULL ),
244
          m_pOutlineSet( NULL )
216
{
245
{
217
#ifdef ENABLE_FONTCONFIG
246
#ifdef ENABLE_FONTCONFIG
218
    OUString aLib( RTL_CONSTASCII_USTRINGPARAM( "libfontconfig.so.1" ) );
247
    OUString aLib( RTL_CONSTASCII_USTRINGPARAM( "libfontconfig.so.1" ) );
Lines 246-257 Link Here
246
        loadSymbol( "FcPatternDestroy" );
275
        loadSymbol( "FcPatternDestroy" );
247
    m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*))
276
    m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*))
248
        loadSymbol( "FcFontList" );
277
        loadSymbol( "FcFontList" );
278
    m_pFcConfigGetFonts = (FcFontSet*(*)(FcConfig*,FcSetName))
279
        loadSymbol( "FcConfigGetFonts" );
249
    m_pFcFontSetCreate = (FcFontSet*(*)())
280
    m_pFcFontSetCreate = (FcFontSet*(*)())
250
        loadSymbol( "FcFontSetCreate" );
281
        loadSymbol( "FcFontSetCreate" );
282
    m_pFcCharSetCreate = (FcCharSet*(*)())
283
        loadSymbol( "FcCharSetCreate" );
284
    m_pFcCharSetAddChar = (FcBool(*)(FcCharSet*, FcChar32))
285
        loadSymbol( "FcCharSetAddChar" );
251
    m_pFcFontSetDestroy = (void(*)(FcFontSet*))
286
    m_pFcFontSetDestroy = (void(*)(FcFontSet*))
252
        loadSymbol( "FcFontSetDestroy" );
287
        loadSymbol( "FcFontSetDestroy" );
253
    m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*))
288
    m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*))
254
        loadSymbol( "FcFontSetAdd" );
289
        loadSymbol( "FcFontSetAdd" );
290
    m_pFcPatternReference = (void(*)(FcPattern*))
291
        loadSymbol( "FcPatternReference" );
255
    m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**))
292
    m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**))
256
        loadSymbol( "FcPatternGetString" );
293
        loadSymbol( "FcPatternGetString" );
257
    m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*))
294
    m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*))
Lines 262-273 Link Here
262
        loadSymbol( "FcPatternGetBool" );
299
        loadSymbol( "FcPatternGetBool" );
263
    m_pFcDefaultSubstitute = (void(*)(FcPattern *))
300
    m_pFcDefaultSubstitute = (void(*)(FcPattern *))
264
        loadSymbol( "FcDefaultSubstitute" );
301
        loadSymbol( "FcDefaultSubstitute" );
265
    m_pFcFontMatch = (FcPattern*(*)(FcConfig*,FcPattern*,FcResult*))
302
    m_pFcFontSetMatch = (FcPattern*(*)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*))
266
        loadSymbol( "FcFontMatch" );
303
        loadSymbol( "FcFontSetMatch" );
267
    m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind))
304
    m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind))
268
        loadSymbol( "FcConfigSubstitute" );
305
        loadSymbol( "FcConfigSubstitute" );
269
    m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int))
306
    m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int))
270
        loadSymbol( "FcPatternAddInteger" );
307
        loadSymbol( "FcPatternAddInteger" );
308
    m_pFcPatternAddBool = (FcBool(*)(FcPattern*,const char*,FcBool))
309
        loadSymbol( "FcPatternAddBool" );
310
    m_pFcPatternAddCharSet = (FcBool(*)(FcPattern*,const char*,const FcCharSet *))
311
        loadSymbol( "FcPatternAddCharSet" );
271
    m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*))
312
    m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*))
272
        loadSymbol( "FcPatternAddString" );
313
        loadSymbol( "FcPatternAddString" );
273
314
Lines 279-295 Link Here
279
            m_pFcPatternCreate				&&
320
            m_pFcPatternCreate				&&
280
            m_pFcPatternDestroy				&&
321
            m_pFcPatternDestroy				&&
281
            m_pFcFontList					&&
322
            m_pFcFontList					&&
323
            m_pFcConfigGetFonts             &&
282
            m_pFcFontSetCreate				&&
324
            m_pFcFontSetCreate				&&
325
            m_pFcCharSetCreate				&&
326
            m_pFcCharSetAddChar 			&&
283
            m_pFcFontSetDestroy				&&
327
            m_pFcFontSetDestroy				&&
284
            m_pFcFontSetAdd					&&
328
            m_pFcFontSetAdd					&&
329
            m_pFcPatternReference           &&
285
            m_pFcPatternGetString			&&
330
            m_pFcPatternGetString			&&
286
            m_pFcPatternGetInteger			&&
331
            m_pFcPatternGetInteger			&&
287
            m_pFcPatternGetDouble			&&
332
            m_pFcPatternGetDouble			&&
288
            m_pFcPatternGetBool				&&
333
            m_pFcPatternGetBool				&&
289
            m_pFcDefaultSubstitute			&&
334
            m_pFcDefaultSubstitute			&&
290
            m_pFcFontMatch					&&
335
            m_pFcFontSetMatch				&&
291
            m_pFcConfigSubstitute			&&
336
            m_pFcConfigSubstitute			&&
292
            m_pFcPatternAddInteger			&&
337
            m_pFcPatternAddInteger			&&
338
            m_pFcPatternAddCharSet			&&
339
            m_pFcPatternAddBool 			&&
293
            m_pFcPatternAddString
340
            m_pFcPatternAddString
294
            ) )
341
            ) )
295
    {
342
    {
Lines 307-316 Link Here
307
        osl_unloadModule( m_pLib );
354
        osl_unloadModule( m_pLib );
308
        m_pLib = NULL;
355
        m_pLib = NULL;
309
    }
356
    }
357
358
    m_pOutlineSet = FcFontSetCreate();
359
360
    /*
361
      add only acceptable outlined fonts to our config, 
362
      for future fontconfig use
363
    */
364
    FcFontSet *pOrig = FcConfigGetFonts(NULL, FcSetSystem);
365
366
    if (!pOrig)
367
        return;
368
369
    for( int i = 0; i < pOrig->nfont; ++i )
370
    {
371
        FcBool outline = false;
372
        FcPattern *pOutlinePattern = pOrig->fonts[i];
373
        FcResult eOutRes = 
374
			FcPatternGetBool( pOutlinePattern, FC_OUTLINE, 0, &outline );
375
        if (eOutRes == FcResultMatch && !outline)
376
            continue;
377
        FcPatternReference(pOutlinePattern);
378
        FcFontSetAdd(m_pOutlineSet, pOutlinePattern);
379
    }
310
}
380
}
311
381
312
FontCfgWrapper::~FontCfgWrapper()
382
FontCfgWrapper::~FontCfgWrapper()
313
{
383
{
384
	if( m_pOutlineSet )
385
		FcFontSetDestroy( m_pOutlineSet );
314
    if( m_pLib )
386
    if( m_pLib )
315
        osl_unloadModule( m_pLib );
387
        osl_unloadModule( m_pLib );
316
}
388
}
Lines 345-362 Link Here
345
    if( ! rWrapper.isValid() )
417
    if( ! rWrapper.isValid() )
346
        return false;
418
        return false;
347
419
348
    FcConfig* pConfig = rWrapper.getDefConfig();
420
    FcFontSet* pFSet = rWrapper.getFontSet();
349
    FcObjectSet* pOSet = rWrapper.FcObjectSetBuild( FC_FAMILY,
350
                                                    FC_STYLE,
351
                                                    FC_SLANT,
352
                                                    FC_WEIGHT,
353
                                                    FC_SPACING,
354
                                                    FC_FILE,
355
                                                    FC_OUTLINE,
356
                                                    FC_INDEX,
357
                                                    (void *) NULL );
358
    FcPattern* pPattern = rWrapper.FcPatternCreate();
359
    FcFontSet* pFSet = rWrapper.FcFontList( pConfig, pPattern, pOSet );
360
421
361
    if( pFSet )
422
    if( pFSet )
362
    {
423
    {
Lines 399-404 Link Here
399
                     );
460
                     );
400
#endif
461
#endif
401
462
463
            OSL_ASSERT(eOutRes != FcResultMatch || outline);
464
402
            // only outline fonts are usable to psprint anyway
465
            // only outline fonts are usable to psprint anyway
403
            if( eOutRes == FcResultMatch && ! outline )
466
            if( eOutRes == FcResultMatch && ! outline )
404
                continue;
467
                continue;
Lines 537-550 Link Here
537
        }
600
        }
538
    }
601
    }
539
    
602
    
540
    // cleanup
541
    if( pPattern )
542
        rWrapper.FcPatternDestroy( pPattern );
543
    if( pFSet )
544
        rWrapper.FcFontSetDestroy( pFSet );
545
    if( pOSet )
546
        rWrapper.FcObjectSetDestroy( pOSet );
547
    
548
    // how does one get rid of the config ?
603
    // how does one get rid of the config ?
549
#if OSL_DEBUG_LEVEL > 1
604
#if OSL_DEBUG_LEVEL > 1
550
    fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts );
605
    fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts );
Lines 558-596 Link Here
558
    FontCfgWrapper::release();
613
    FontCfgWrapper::release();
559
}
614
}
560
615
561
bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale )
616
static void addtopattern(FontCfgWrapper& rWrapper, FcPattern *pPattern, 
617
	italic::type eItalic, weight::type eWeight, width::type eWidth, pitch::type ePitch)
562
{
618
{
563
#ifdef ENABLE_FONTCONFIG
619
#ifdef ENABLE_FONTCONFIG
564
    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
620
    if( eItalic != italic::Unknown )
565
    if( ! rWrapper.isValid() )
566
        return false;
567
568
    FcConfig* pConfig = rWrapper.getDefConfig();
569
    FcPattern* pPattern = rWrapper.FcPatternCreate();
570
571
    OString aLangAttrib;
572
    // populate pattern with font characteristics
573
    if( rLocale.Language.getLength() )
574
    {
575
        OUStringBuffer aLang(6);
576
        aLang.append( rLocale.Language );
577
        if( rLocale.Country.getLength() )
578
        {
579
            aLang.append( sal_Unicode('-') );
580
            aLang.append( rLocale.Country );
581
        }
582
        aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
583
    }
584
    if( aLangAttrib.getLength() )
585
        rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() );
586
587
    OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
588
    if( aFamily.getLength() )
589
        rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() );
590
    if( rInfo.m_eItalic != italic::Unknown )
591
    {
621
    {
592
        int nSlant = FC_SLANT_ROMAN;
622
        int nSlant = FC_SLANT_ROMAN;
593
        switch( rInfo.m_eItalic )
623
        switch( eItalic )
594
        {
624
        {
595
            case italic::Italic:	 	nSlant = FC_SLANT_ITALIC;break;
625
            case italic::Italic:	 	nSlant = FC_SLANT_ITALIC;break;
596
            case italic::Oblique:	 	nSlant = FC_SLANT_OBLIQUE;break;
626
            case italic::Oblique:	 	nSlant = FC_SLANT_OBLIQUE;break;
Lines 599-608 Link Here
599
        }
629
        }
600
        rWrapper.FcPatternAddInteger( pPattern, FC_SLANT, nSlant );
630
        rWrapper.FcPatternAddInteger( pPattern, FC_SLANT, nSlant );
601
    }
631
    }
602
    if( rInfo.m_eWeight != weight::Unknown )
632
    if( eWeight != weight::Unknown )
603
    {
633
    {
604
        int nWeight = FC_WEIGHT_NORMAL;
634
        int nWeight = FC_WEIGHT_NORMAL;
605
        switch( rInfo.m_eWeight )
635
        switch( eWeight )
606
        {
636
        {
607
            case weight::Thin:			nWeight = FC_WEIGHT_THIN;break;
637
            case weight::Thin:			nWeight = FC_WEIGHT_THIN;break;
608
            case weight::UltraLight:	nWeight = FC_WEIGHT_ULTRALIGHT;break;
638
            case weight::UltraLight:	nWeight = FC_WEIGHT_ULTRALIGHT;break;
Lines 619-628 Link Here
619
        }
649
        }
620
        rWrapper.FcPatternAddInteger( pPattern, FC_WEIGHT, nWeight );
650
        rWrapper.FcPatternAddInteger( pPattern, FC_WEIGHT, nWeight );
621
    }
651
    }
622
    if( rInfo.m_eWidth != width::Unknown )
652
    if( eWidth != width::Unknown )
623
    {
653
    {
624
        int nWidth = FC_WIDTH_NORMAL;
654
        int nWidth = FC_WIDTH_NORMAL;
625
        switch( rInfo.m_eWidth )
655
        switch( eWidth )
626
        {
656
        {
627
            case width::UltraCondensed:	nWidth = FC_WIDTH_ULTRACONDENSED;break;
657
            case width::UltraCondensed:	nWidth = FC_WIDTH_ULTRACONDENSED;break;
628
            case width::ExtraCondensed: nWidth = FC_WIDTH_EXTRACONDENSED;break;
658
            case width::ExtraCondensed: nWidth = FC_WIDTH_EXTRACONDENSED;break;
Lines 638-647 Link Here
638
        }
668
        }
639
        rWrapper.FcPatternAddInteger( pPattern, FC_WIDTH, nWidth );
669
        rWrapper.FcPatternAddInteger( pPattern, FC_WIDTH, nWidth );
640
    }
670
    }
641
    if( rInfo.m_ePitch != pitch::Unknown )
671
    if( ePitch != pitch::Unknown )
642
    {
672
    {
643
        int nSpacing = FC_PROPORTIONAL;
673
        int nSpacing = FC_PROPORTIONAL;
644
        switch( rInfo.m_ePitch )
674
        switch( ePitch )
645
        {
675
        {
646
            case pitch::Fixed:			nSpacing = FC_MONO;break;
676
            case pitch::Fixed:			nSpacing = FC_MONO;break;
647
            case pitch::Variable:		nSpacing = FC_PROPORTIONAL;break;
677
            case pitch::Variable:		nSpacing = FC_PROPORTIONAL;break;
Lines 649-660 Link Here
649
                break;
679
                break;
650
        }
680
        }
651
        rWrapper.FcPatternAddInteger( pPattern, FC_SPACING, nSpacing );
681
        rWrapper.FcPatternAddInteger( pPattern, FC_SPACING, nSpacing );
682
        if (nSpacing == FC_MONO)
683
            rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)"monospace");
652
    }
684
    }
685
#endif
686
}
687
688
String PrintFontManager::Substitute(const std::vector<String> &rNames, const std::vector<sal_Unicode> &rGlyphs,
689
        const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight,
690
        width::type eWidth, pitch::type ePitch) const
691
{
692
    String aName;
693
#ifdef ENABLE_FONTCONFIG
694
    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
695
    if( ! rWrapper.isValid() )
696
        return aName;
697
698
    FcFontSet*  pSet = NULL;
699
    FcPattern*  pPattern = rWrapper.FcPatternCreate();
700
701
    // Prefer scalable fonts
702
    rWrapper.FcPatternAddBool( pPattern, FC_SCALABLE, 1 );
703
704
    std::vector<String>::const_iterator aEnd = rNames.end();
705
    for (std::vector<String>::const_iterator aIter = rNames.begin(); aIter != aEnd; ++aIter)
706
    {
707
	    OString maTargetName = OUStringToOString(*aIter, RTL_TEXTENCODING_UTF8);
708
        rWrapper.FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)maTargetName.getStr());
709
    }
710
711
    if( rLangAttrib.Len() )
712
        rWrapper.FcPatternAddString(pPattern, FC_LANG, (FcChar8*)rLangAttrib.GetBuffer());
713
714
    // Add required Unicode characters, if any
715
    FcCharSet *unicodes = NULL;
716
    if (! rGlyphs.empty() )
717
    {
718
        unicodes = rWrapper.FcCharSetCreate();
719
	    std::vector<sal_Unicode>::const_iterator aGlyphEnd = rGlyphs.end();
720
	    for (std::vector<sal_Unicode>::const_iterator aGlyphIter = rGlyphs.begin(); 
721
            aGlyphIter != aGlyphEnd; ++aGlyphIter)
722
	    {
723
            rWrapper.FcCharSetAddChar( unicodes, (FcChar32)*aGlyphIter );
724
	    }
725
        rWrapper.FcPatternAddCharSet( pPattern, FC_CHARSET, unicodes);
726
    }
727
728
    addtopattern(rWrapper, pPattern, eItalic, eWeight, eWidth, ePitch);
729
730
    rWrapper.FcConfigSubstitute( NULL, pPattern, FcMatchPattern );
731
    rWrapper.FcDefaultSubstitute( pPattern );
732
    FcResult eResult = FcResultNoMatch;
733
    FcFontSet *pFontSet = rWrapper.getFontSet();
734
    FcPattern* pResult = rWrapper.FcFontSetMatch( NULL, &pFontSet, 1, pPattern, &eResult );
735
    rWrapper.FcPatternDestroy( pPattern );
736
737
    if( pResult )
738
    {
739
        pSet = rWrapper.FcFontSetCreate();
740
        // info: destroying the pSet destroys pResult implicitly
741
        // since pResult was "added" to pSet
742
        rWrapper.FcFontSetAdd( pSet, pResult );
743
    }
744
745
    if( pSet )
746
    {
747
        if( pSet->nfont > 0 )
748
        {
749
            //extract the closest match
750
            FcChar8* family = NULL;
751
            FcResult eFileRes = rWrapper.FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family );
752
            if( eFileRes == FcResultMatch )
753
                aName = String( (sal_Char*)family, RTL_TEXTENCODING_UTF8 );
754
        }
755
    }
756
    rWrapper.FcFontSetDestroy( pSet );
757
#endif
758
    return aName;
759
}
760
761
bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale )
762
{
763
#ifdef ENABLE_FONTCONFIG
764
    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
765
    if( ! rWrapper.isValid() )
766
        return false;
767
768
    FcConfig* pConfig = rWrapper.getDefConfig();
769
    FcPattern* pPattern = rWrapper.FcPatternCreate();
770
771
    OString aLangAttrib;
772
    // populate pattern with font characteristics
773
    if( rLocale.Language.getLength() )
774
    {
775
        OUStringBuffer aLang(6);
776
        aLang.append( rLocale.Language );
777
        if( rLocale.Country.getLength() )
778
        {
779
            aLang.append( sal_Unicode('-') );
780
            aLang.append( rLocale.Country );
781
        }
782
        aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
783
    }
784
    if( aLangAttrib.getLength() )
785
        rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() );
786
787
    OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
788
    if( aFamily.getLength() )
789
        rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() );
790
791
    addtopattern(rWrapper, pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
653
792
654
    rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern );
793
    rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern );
655
    rWrapper.FcDefaultSubstitute( pPattern );
794
    rWrapper.FcDefaultSubstitute( pPattern );
656
    FcResult eResult = FcResultNoMatch;
795
    FcResult eResult = FcResultNoMatch;
657
    FcPattern* pResult = rWrapper.FcFontMatch( pConfig, pPattern, &eResult );
796
    FcFontSet *pFontSet = rWrapper.getFontSet();
797
    FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult );
658
    bool bSuccess = false;
798
    bool bSuccess = false;
659
    if( pResult )
799
    if( pResult )
660
    {
800
    {
(-)openoffice.org.orig/psprint/usource/fontmanager/fontmanager.cxx (-4 / +5 lines)
Lines 1177-1183 Link Here
1177
        m_nNextFontID( 1 ),
1177
        m_nNextFontID( 1 ),
1178
        m_pAtoms( new MultiAtomProvider() ),
1178
        m_pAtoms( new MultiAtomProvider() ),
1179
        m_nNextDirAtom( 1 ),
1179
        m_nNextDirAtom( 1 ),
1180
        m_pFontCache( NULL )
1180
        m_pFontCache( NULL ),
1181
	m_bFontconfigSuccess(false)
1181
{
1182
{
1182
    for( unsigned int i = 0; i < sizeof( aAdobeCodes )/sizeof( aAdobeCodes[0] ); i++ )
1183
    for( unsigned int i = 0; i < sizeof( aAdobeCodes )/sizeof( aAdobeCodes[0] ); i++ )
1183
    {
1184
    {
Lines 2129-2135 Link Here
2129
#endif
2130
#endif
2130
2131
2131
    // first try fontconfig
2132
    // first try fontconfig
2132
    bool bFontconfigSuccess = initFontconfig();
2133
    m_bFontconfigSuccess = initFontconfig();
2133
2134
2134
    // part one - look for downloadable fonts
2135
    // part one - look for downloadable fonts
2135
    rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
2136
    rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
Lines 2151-2157 Link Here
2151
    }
2152
    }
2152
2153
2153
    // don't search through many directories fontconfig already told us about
2154
    // don't search through many directories fontconfig already told us about
2154
    if( ! bFontconfigSuccess )
2155
    if( ! m_bFontconfigSuccess )
2155
    {							
2156
    {							
2156
        Display *pDisplay = (Display*)pInitDisplay;
2157
        Display *pDisplay = (Display*)pInitDisplay;
2157
        
2158
        
Lines 2229-2235 Link Here
2229
            }
2230
            }
2230
        }
2231
        }
2231
#endif /* SOLARIS */
2232
#endif /* SOLARIS */
2232
    } // ! bFontconfigSuccess
2233
    } // ! m_bFontconfigSuccess
2233
2234
2234
    // fill XLFD aliases from fonts.alias files
2235
    // fill XLFD aliases from fonts.alias files
2235
    initFontsAlias();
2236
    initFontsAlias();

Return to issue 54603