Commits

hdu  committed 6ca75e8

#i64508# new code should avoid fruitless vclenum<->pspenum conversions
now that psp finally moved into vcl these conversions became even more redundant

Which of the enumerations for the same thing should survive? The original stuff or the new ones? My vote is on keeping the original ones unless the new ones provide any real value-add.

  • Participants
  • Parent commits 42bda35

Comments (0)

Files changed (3)

File vcl/inc/vcl/fontmanager.hxx

 
 #include "vcl/dllapi.h"
 #include "vcl/helper.hxx"
+#include "vcl/impfont.hxx"
 
 #include "com/sun/star/lang/Locale.hpp"
 
 };
 }
 
-namespace fchint
-{
-enum type {
-    Nohint = 0,
-    Slight = 1,
-    Medium = 2,
-    Full = 3
-};
-}
-
-struct FontConfigHints
-{
-    fcstatus::type m_eEmbeddedbitmap;
-    fcstatus::type m_eAntialias;
-    fcstatus::type m_eAutoHint;
-    fcstatus::type m_eHinting;
-    fchint::type m_eHintStyle;
-
-    FontConfigHints() :
-        m_eEmbeddedbitmap( fcstatus::isunset ),
-        m_eAntialias( fcstatus::isunset ),
-        m_eAutoHint( fcstatus::isunset ),
-        m_eHinting( fcstatus::isunset ),
-        m_eHintStyle( fchint::Full )
-        {}
-};
-
 /*
  *  the difference between FastPrintFontInfo and PrintFontInfo
  *  is that the information in FastPrintFontInfo can usually
     false else
      */
     bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
-    FontConfigHints getFontConfigHints(const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void *));
+    bool getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*), ImplFontOptions& rResult ) const;
 
     rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, 
         const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight, 

File vcl/unx/source/fontmanager/fontconfig.cxx

     return aName;
 }
 
-FontConfigHints PrintFontManager::getFontConfigHints( 
-    const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void *) )
+bool PrintFontManager::getFontOptions( 
+    const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*),
+    ImplFontOptions& rOptions) const
 {
-    FontConfigHints aHints;
-#ifdef ENABLE_FONTCONFIG
+#ifndef ENABLE_FONTCONFIG
+    return false;
+#else // ENABLE_FONTCONFIG
     FontCfgWrapper& rWrapper = FontCfgWrapper::get();
     if( ! rWrapper.isValid() )
-        return aHints;
+        return false;
 
     FcConfig* pConfig = rWrapper.FcConfigGetCurrent();
     FcPattern* pPattern = rWrapper.FcPatternCreate();
     rWrapper.FcDefaultSubstitute( pPattern );
 
     FcResult eResult = FcResultNoMatch;
-    FcFontSet *pFontSet = rWrapper.getFontSet();
+    FcFontSet* pFontSet = rWrapper.getFontSet();
     FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult );
-    if( pResult )
+    if( !pResult )
     {
         FcFontSet* pSet = rWrapper.FcFontSetCreate();
         rWrapper.FcFontSetAdd( pSet, pResult );
                 FC_AUTOHINT, 0, &autohint);
             FcResult eHinting = rWrapper.FcPatternGetBool(pSet->fonts[0], 
                 FC_HINTING, 0, &hinting);
-            FcResult eHintStyle = rWrapper.FcPatternGetInteger(pSet->fonts[0],
+            /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger( pSet->fonts[0],
                 FC_HINT_STYLE, 0, &hintstyle);
          
             if( eEmbeddedBitmap == FcResultMatch )
-                aHints.m_eEmbeddedbitmap = embitmap ? fcstatus::istrue : fcstatus::isfalse;
+                rOptions.meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
             if( eAntialias == FcResultMatch )
-                aHints.m_eAntialias = antialias ? fcstatus::istrue : fcstatus::isfalse;
+                rOptions.meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE;
             if( eAutoHint == FcResultMatch )
-                aHints.m_eAutoHint = autohint ? fcstatus::istrue : fcstatus::isfalse;
+                rOptions.meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE;
             if( eHinting == FcResultMatch )
-                aHints.m_eHinting = hinting ? fcstatus::istrue : fcstatus::isfalse;
-            if (eHintStyle != FcResultMatch)
-                aHints.m_eHintStyle = fchint::Full;
-            else
+                rOptions.meHinting = hinting ? HINTING_TRUE : HINTING_FALSE;
+            switch (hintstyle)
             {
-                switch (hintstyle)
-                {
-                    case FC_HINT_NONE:
-                        aHints.m_eHintStyle = fchint::Nohint;
-                        break;
-                    case FC_HINT_SLIGHT:
-                        aHints.m_eHintStyle = fchint::Slight;
-                        break;
-                    case FC_HINT_MEDIUM:
-                        aHints.m_eHintStyle = fchint::Medium;
-                        break;
-                    case FC_HINT_FULL:
-                    default:
-                        aHints.m_eHintStyle = fchint::Full;
-                        break;
-                }
+                case FC_HINT_NONE:   rOptions.meHintStyle = HINT_NONE; break;
+                case FC_HINT_SLIGHT: rOptions.meHintStyle = HINT_SLIGHT; break;
+                case FC_HINT_MEDIUM: rOptions.meHintStyle = HINT_MEDIUM; break;
+                default: // fall through
+                case FC_HINT_FULL:   rOptions.meHintStyle = HINT_FULL; break;
             }
         }
         // info: destroying the pSet destroys pResult implicitly
     // cleanup
     rWrapper.FcPatternDestroy( pPattern );
 
+    // TODO: return true only if non-default font options are set
+    const bool bOK = (pResult != NULL);
+    return bOK;
 #endif
-    return aHints;
 }
 
 bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale )

File vcl/unx/source/gdi/salgdi3.cxx

             break;
     }
 
-    psp::FontConfigHints aHints(psp::PrintFontManager::get().getFontConfigHints(aInfo, nSize,
-	cairosubcallback));
+    const psp::PrintFontManager& rPFM = psp::PrintFontManager::get();
+    bool bOK = rPFM.getFontOptions( aInfo, nSize, cairosubcallback, rFontOptions);
 
-    switch (aHints.m_eEmbeddedbitmap)
-    {
-        default: rFontOptions.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; break;
-        case psp::fcstatus::istrue: rFontOptions.meEmbeddedBitmap = EMBEDDEDBITMAP_TRUE; break;
-        case psp::fcstatus::isfalse: rFontOptions.meEmbeddedBitmap = EMBEDDEDBITMAP_FALSE; break;
-    }
-
-    switch (aHints.m_eAntialias)
-    {
-        default: rFontOptions.meAntiAlias = ANTIALIAS_DONTKNOW; break;
-        case psp::fcstatus::istrue: rFontOptions.meAntiAlias = ANTIALIAS_TRUE; break;
-        case psp::fcstatus::isfalse: rFontOptions.meAntiAlias = ANTIALIAS_FALSE; break;
-    }
-
-    switch (aHints.m_eAutoHint)
-    {
-        default: rFontOptions.meAutoHint = AUTOHINT_DONTKNOW; break;
-        case psp::fcstatus::istrue: rFontOptions.meAutoHint = AUTOHINT_TRUE; break;
-        case psp::fcstatus::isfalse: rFontOptions.meAutoHint = AUTOHINT_FALSE; break;
-    }
-
-    switch (aHints.m_eHinting)
-    {
-        default: rFontOptions.meHinting = HINTING_DONTKNOW; break;
-        case psp::fcstatus::istrue:  rFontOptions.meHinting = HINTING_TRUE; break;
-        case psp::fcstatus::isfalse: rFontOptions.meHinting = HINTING_FALSE; break;
-    }
-
-    switch (aHints.m_eHintStyle)
-    {
-        case psp::fchint::Nohint: rFontOptions.meHintStyle = HINT_NONE; break;
-        case psp::fchint::Slight: rFontOptions.meHintStyle = HINT_SLIGHT; break;
-        case psp::fchint::Medium: rFontOptions.meHintStyle = HINT_MEDIUM; break;
-        default: // fall through
-        case psp::fchint::Full:   rFontOptions.meHintStyle = HINT_FULL; break;
-    }
-
-    return true;
+    return bOK;
 }
 
 // ----------------------------------------------------------------------------