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

(-)openoffice.org.orig/vcl/inc/vcl/fontmanager.hxx (-2 / +2 lines)
Lines 765-772 Link Here
765
    FontConfigHints getFontConfigHints(const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void *));
765
    FontConfigHints getFontConfigHints(const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void *));
766
766
767
    rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, 
767
    rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, 
768
        const rtl::OString& rLangAttrib, italic::type eItalic, weight::type eWeight, 
768
        const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight, 
769
        width::type eWidth, pitch::type ePitch) const;
769
        width::type& rWidth, pitch::type& rPitch) const;
770
    bool hasFontconfig() const { return m_bFontconfigSuccess; }
770
    bool hasFontconfig() const { return m_bFontconfigSuccess; }
771
771
772
    int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
772
    int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
(-)openoffice.org.orig/vcl/unx/source/fontmanager/fontconfig.cxx (-42 / +83 lines)
Lines 560-565 Link Here
560
    return true;
560
    return true;
561
}
561
}
562
562
563
namespace
564
{
565
    weight::type convertWeight(int weight)
566
    {
567
        // set weight
568
        if( weight <= FC_WEIGHT_THIN )
569
            return weight::Thin;
570
        else if( weight <= FC_WEIGHT_ULTRALIGHT )
571
            return weight::UltraLight;
572
        else if( weight <= FC_WEIGHT_LIGHT )
573
            return weight::Light;
574
        else if( weight <= FC_WEIGHT_BOOK )
575
            return weight::SemiLight;
576
        else if( weight <= FC_WEIGHT_NORMAL )
577
            return weight::Normal;
578
        else if( weight <= FC_WEIGHT_MEDIUM )
579
            return weight::Medium;
580
        else if( weight <= FC_WEIGHT_SEMIBOLD )
581
            return weight::SemiBold;
582
        else if( weight <= FC_WEIGHT_BOLD )
583
            return weight::Bold;
584
        else if( weight <= FC_WEIGHT_ULTRABOLD )
585
            return weight::UltraBold;
586
        return weight::Black;
587
    }
588
589
    italic::type convertSlant(int slant)
590
    {
591
        // set italic
592
        if( slant == FC_SLANT_ITALIC )
593
            return italic::Italic;
594
        else if( slant == FC_SLANT_OBLIQUE )
595
            return italic::Oblique;
596
        return italic::Upright;
597
    }
598
599
    pitch::type convertSpacing(int spacing)
600
    {
601
        // set pitch
602
        if( spacing == FC_MONO || spacing == FC_CHARCELL )
603
            return pitch::Fixed;
604
        return pitch::Variable;
605
    }
606
607
    width::type convertWidth(int width)
608
    {
609
        if (width == FC_WIDTH_ULTRACONDENSED)
610
            return width::UltraCondensed;
611
        else if (width == FC_WIDTH_EXTRACONDENSED)
612
            return width::ExtraCondensed;
613
        else if (width == FC_WIDTH_CONDENSED)
614
            return width::Condensed;
615
        else if (width == FC_WIDTH_SEMICONDENSED)
616
            return width::SemiCondensed;
617
        else if (width == FC_WIDTH_SEMIEXPANDED)
618
            return width::SemiExpanded;
619
        else if (width == FC_WIDTH_EXPANDED)
620
            return width::Expanded;
621
        else if (width == FC_WIDTH_EXTRAEXPANDED)
622
            return width::ExtraExpanded;
623
        else if (width == FC_WIDTH_ULTRAEXPANDED)
624
            return width::UltraExpanded;
625
        return width::Normal;
626
    }
627
}
628
563
int PrintFontManager::countFontconfigFonts()
629
int PrintFontManager::countFontconfigFonts()
564
{
630
{
565
    int nFonts = 0;
631
    int nFonts = 0;
Lines 687-733 Link Here
687
                    pUpdate->m_nFamilyName = nFamilyName;
753
                    pUpdate->m_nFamilyName = nFamilyName;
688
                }
754
                }
689
                if( eWeightRes == FcResultMatch )
755
                if( eWeightRes == FcResultMatch )
690
                {
756
					pUpdate->m_eWeight = convertWeight(weight);
691
                    // set weight
692
                    if( weight <= FC_WEIGHT_THIN )
693
                        pUpdate->m_eWeight = weight::Thin;
694
                    else if( weight <= FC_WEIGHT_ULTRALIGHT )
695
                        pUpdate->m_eWeight = weight::UltraLight;
696
                    else if( weight <= FC_WEIGHT_LIGHT )
697
                        pUpdate->m_eWeight = weight::Light;
698
                    else if( weight <= FC_WEIGHT_BOOK )
699
                        pUpdate->m_eWeight = weight::SemiLight;
700
                    else if( weight <= FC_WEIGHT_NORMAL )
701
                        pUpdate->m_eWeight = weight::Normal;
702
                    else if( weight <= FC_WEIGHT_MEDIUM )
703
                        pUpdate->m_eWeight = weight::Medium;
704
                    else if( weight <= FC_WEIGHT_SEMIBOLD )
705
                        pUpdate->m_eWeight = weight::SemiBold;
706
                    else if( weight <= FC_WEIGHT_BOLD )
707
                        pUpdate->m_eWeight = weight::Bold;
708
                    else if( weight <= FC_WEIGHT_ULTRABOLD )
709
                        pUpdate->m_eWeight = weight::UltraBold;
710
                    else
711
                        pUpdate->m_eWeight = weight::Black;
712
                }
713
                if( eSpacRes == FcResultMatch )
757
                if( eSpacRes == FcResultMatch )
714
                {
758
                    pUpdate->m_ePitch = convertSpacing(spacing);
715
                    // set pitch
716
                    if( spacing == FC_PROPORTIONAL )
717
                        pUpdate->m_ePitch = pitch::Variable;
718
                    else if( spacing == FC_MONO || spacing == FC_CHARCELL )
719
                        pUpdate->m_ePitch = pitch::Fixed;
720
                }
721
                if( eSlantRes == FcResultMatch )
759
                if( eSlantRes == FcResultMatch )
722
                {
760
					pUpdate->m_eItalic = convertSlant(slant);
723
                    // set italic
724
                    if( slant == FC_SLANT_ROMAN )
725
                        pUpdate->m_eItalic = italic::Upright;
726
                    else if( slant == FC_SLANT_ITALIC )
727
                        pUpdate->m_eItalic = italic::Italic;
728
                    else if( slant == FC_SLANT_OBLIQUE )
729
                        pUpdate->m_eItalic = italic::Oblique;
730
                }
731
                if( eStyleRes == FcResultMatch )
761
                if( eStyleRes == FcResultMatch )
732
                {
762
                {
733
                    pUpdate->m_aStyleName = OStringToOUString( OString( (sal_Char*)style ), RTL_TEXTENCODING_UTF8 );
763
                    pUpdate->m_aStyleName = OStringToOUString( OString( (sal_Char*)style ), RTL_TEXTENCODING_UTF8 );
Lines 867-874 Link Here
867
897
868
rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName,
898
rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName,
869
    rtl::OUString& rMissingCodes, const rtl::OString &rLangAttrib,
899
    rtl::OUString& rMissingCodes, const rtl::OString &rLangAttrib,
870
    italic::type eItalic, weight::type eWeight,
900
    italic::type &rItalic, weight::type &rWeight,
871
    width::type eWidth, pitch::type ePitch) const
901
    width::type &rWidth, pitch::type &rPitch) const
872
{
902
{
873
    rtl::OUString aName;
903
    rtl::OUString aName;
874
    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
904
    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
Lines 903-909 Link Here
903
       rWrapper.FcCharSetDestroy( unicodes );
933
       rWrapper.FcCharSetDestroy( unicodes );
904
    }
934
    }
905
935
906
    addtopattern(rWrapper, pPattern, eItalic, eWeight, eWidth, ePitch);
936
    addtopattern(rWrapper, pPattern, rItalic, rWeight, rWidth, rPitch);
907
937
908
    // query fontconfig for a substitute
938
    // query fontconfig for a substitute
909
    rWrapper.FcConfigSubstitute( rWrapper.FcConfigGetCurrent(), pPattern, FcMatchPattern );
939
    rWrapper.FcConfigSubstitute( rWrapper.FcConfigGetCurrent(), pPattern, FcMatchPattern );
Lines 940-945 Link Here
940
                if (aI != rWrapper.m_aFontNameToLocalized.end())
970
                if (aI != rWrapper.m_aFontNameToLocalized.end())
941
                    sFamily = aI->second;
971
                    sFamily = aI->second;
942
                aName = rtl::OStringToOUString( sFamily, RTL_TEXTENCODING_UTF8 );
972
                aName = rtl::OStringToOUString( sFamily, RTL_TEXTENCODING_UTF8 );
973
974
975
                int val = 0;
976
                if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_WEIGHT, 0, &val))
977
                    rWeight = convertWeight(val);
978
                if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_SLANT, 0, &val))
979
                    rItalic = convertSlant(val);
980
                if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_SPACING, 0, &val))
981
                    rPitch = convertSpacing(val);
982
                if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_WIDTH, 0, &val))
983
                    rWidth = convertWidth(val);
943
            }
984
            }
944
985
945
			// update rMissingCodes by removing resolved unicodes
986
			// update rMissingCodes by removing resolved unicodes
(-)openoffice.org.orig/vcl/unx/source/gdi/salgdi3.cxx (-14 / +79 lines)
Lines 2069-2076 Link Here
2069
2069
2070
// -----------------------------------------------------------------------
2070
// -----------------------------------------------------------------------
2071
2071
2072
static rtl::OUString GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUString& rMissingCodes )
2072
static ImplFontSelectData GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUString& rMissingCodes )
2073
{
2073
{
2074
    ImplFontSelectData aRet(rFontSelData);
2075
2074
    const rtl::OString aLangAttrib; //TODO: = MsLangId::convertLanguageToIsoByteString( rFontSelData.meLanguage );
2076
    const rtl::OString aLangAttrib; //TODO: = MsLangId::convertLanguageToIsoByteString( rFontSelData.meLanguage );
2075
2077
2076
    psp::italic::type eItalic = psp::italic::Unknown;
2078
    psp::italic::type eItalic = psp::italic::Unknown;
Lines 2138-2144 Link Here
2138
    }
2140
    }
2139
2141
2140
    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
2142
    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
2141
    return rMgr.Substitute( rFontSelData.maTargetName, rMissingCodes, aLangAttrib, eItalic, eWeight, eWidth, ePitch);
2143
    aRet.maSearchName = rMgr.Substitute( rFontSelData.maTargetName, rMissingCodes, aLangAttrib, eItalic, eWeight, eWidth, ePitch);
2144
2145
    switch (eItalic)
2146
    {
2147
        case psp::italic::Upright: aRet.meItalic = ITALIC_NONE; break;
2148
        case psp::italic::Italic: aRet.meItalic = ITALIC_NORMAL; break;
2149
        case psp::italic::Oblique: aRet.meItalic = ITALIC_OBLIQUE; break;
2150
        default:
2151
            break;
2152
    }
2153
2154
    switch (eWeight)
2155
    {
2156
        case psp::weight::Thin: aRet.meWeight = WEIGHT_THIN; break;
2157
        case psp::weight::UltraLight: aRet.meWeight = WEIGHT_ULTRALIGHT; break;
2158
        case psp::weight::Light: aRet.meWeight = WEIGHT_LIGHT; break;
2159
        case psp::weight::SemiLight: aRet.meWeight = WEIGHT_SEMILIGHT; break;
2160
        case psp::weight::Normal: aRet.meWeight = WEIGHT_NORMAL; break;
2161
        case psp::weight::Medium: aRet.meWeight = WEIGHT_MEDIUM; break;
2162
        case psp::weight::SemiBold: aRet.meWeight = WEIGHT_SEMIBOLD; break;
2163
        case psp::weight::Bold: aRet.meWeight = WEIGHT_BOLD; break;
2164
        case psp::weight::UltraBold: aRet.meWeight = WEIGHT_ULTRABOLD; break;
2165
        case psp::weight::Black: aRet.meWeight = WEIGHT_BLACK; break;
2166
        default:
2167
                break;
2168
    }
2169
2170
    switch (eWidth)
2171
    {
2172
        case psp::width::UltraCondensed: aRet.meWidthType = WIDTH_ULTRA_CONDENSED; break;
2173
        case psp::width::ExtraCondensed: aRet.meWidthType = WIDTH_EXTRA_CONDENSED; break;
2174
        case psp::width::Condensed: aRet.meWidthType = WIDTH_CONDENSED; break;
2175
        case psp::width::SemiCondensed: aRet.meWidthType = WIDTH_SEMI_CONDENSED; break;
2176
        case psp::width::Normal: aRet.meWidthType = WIDTH_NORMAL; break;
2177
        case psp::width::SemiExpanded: aRet.meWidthType = WIDTH_SEMI_EXPANDED; break;
2178
        case psp::width::Expanded: aRet.meWidthType = WIDTH_EXPANDED; break;
2179
        case psp::width::ExtraExpanded: aRet.meWidthType = WIDTH_EXTRA_EXPANDED; break;
2180
        case psp::width::UltraExpanded: aRet.meWidthType = WIDTH_ULTRA_EXPANDED; break;
2181
        default:
2182
            break;
2183
    }
2184
2185
    switch (ePitch)
2186
    {
2187
        case psp::pitch::Fixed: aRet.mePitch = PITCH_FIXED; break;
2188
        case psp::pitch::Variable: aRet.mePitch = PITCH_VARIABLE; break;
2189
        default:
2190
            break;
2191
    }
2192
2193
    return aRet;
2194
}
2195
2196
namespace
2197
{
2198
    bool uselessmatch(const ImplFontSelectData &rOrig, const ImplFontSelectData &rNew)
2199
    {
2200
        return
2201
          (
2202
            rOrig.maTargetName == rNew.maSearchName &&
2203
            rOrig.meWeight == rNew.meWeight &&
2204
            rOrig.meItalic == rNew.meItalic &&
2205
            rOrig.mePitch == rNew.mePitch &&
2206
            rOrig.meWidthType == rNew.meWidthType
2207
          );
2208
    }
2142
}
2209
}
2143
2210
2144
//--------------------------------------------------------------------------
2211
//--------------------------------------------------------------------------
Lines 2154-2173 Link Here
2154
        return false;
2221
        return false;
2155
2222
2156
    rtl::OUString aDummy;
2223
    rtl::OUString aDummy;
2157
    const rtl::OUString aOUName = GetFcSubstitute( rFontSelData, aDummy );
2224
    const ImplFontSelectData aOut = GetFcSubstitute( rFontSelData, aDummy );
2158
    if( !aOUName.getLength() )
2225
    if (!aOut.maSearchName.Len())
2159
        return false;
2226
        return false;
2160
    const String aName( aOUName );
2227
    if( uselessmatch(rFontSelData, aOut ) )
2161
    if( aName == rFontSelData.maTargetName )
2162
        return false;
2228
        return false;
2163
2229
2164
#ifdef DEBUG
2230
#ifdef DEBUG
2165
    ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 );
2231
    ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 );
2166
    ByteString aSubstName( aName, RTL_TEXTENCODING_UTF8 );
2232
    ByteString aSubstName( aOut.maSearchName, RTL_TEXTENCODING_UTF8 );
2167
    printf( "FcPreMatchSubstititution \"%s\" -> \"%s\"\n",
2233
    printf( "FcPreMatchSubstititution \"%s\" -> \"%s\"\n",
2168
        aOrigName.GetBuffer(), aSubstName.GetBuffer() );
2234
        aOrigName.GetBuffer(), aSubstName.GetBuffer() );
2169
#endif
2235
#endif
2170
    rFontSelData.maSearchName = aName;
2236
    rFontSelData = aOut;
2171
    return true;
2237
    return true;
2172
}
2238
}
2173
2239
Lines 2184-2204 Link Here
2184
    ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
2250
    ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
2185
        return false;
2251
        return false;
2186
2252
2187
    const rtl::OUString aOUName = GetFcSubstitute( rFontSelData, rMissingCodes );
2253
    const ImplFontSelectData aOut = GetFcSubstitute( rFontSelData, rMissingCodes );
2188
    // TODO: cache the unicode+font specific result
2254
    // TODO: cache the unicode+font specific result
2189
    if( !aOUName.getLength() )
2255
    if (!aOut.maSearchName.Len())
2190
        return false;
2256
        return false;
2191
    const String aName( aOUName );
2257
    if (uselessmatch(rFontSelData, aOut))
2192
    if( aName == rFontSelData.maTargetName )
2193
        return false;
2258
        return false;
2194
2259
2195
#ifdef DEBUG
2260
#ifdef DEBUG
2196
    ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 );
2261
    ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 );
2197
    ByteString aSubstName( aName, RTL_TEXTENCODING_UTF8 );
2262
    ByteString aSubstName( aOut.maSearchName, RTL_TEXTENCODING_UTF8 );
2198
    printf( "FcGlyphFallbackSubstititution \"%s\" -> \"%s\"\n",
2263
    printf( "FcGlyphFallbackSubstititution \"%s\" -> \"%s\"\n",
2199
        aOrigName.GetBuffer(), aSubstName.GetBuffer() );
2264
        aOrigName.GetBuffer(), aSubstName.GetBuffer() );
2200
#endif
2265
#endif
2201
    rFontSelData.maSearchName = aName;
2266
    rFontSelData = aOut;
2202
    return true;
2267
    return true;
2203
}
2268
}
2204
2269

Return to issue 87970