LCOV - code coverage report
Current view: top level - vcl/inc - outfont.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 37 94.6 %
Date: 2015-06-13 12:38:46 Functions: 39 41 95.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_INC_OUTFONT_HXX
      21             : #define INCLUDED_VCL_INC_OUTFONT_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <sal/log.hxx>
      25             : #include <sal/types.h>
      26             : #include <i18nlangtag/lang.h>
      27             : #include <tools/solar.h>
      28             : #include <vcl/dllapi.h>
      29             : #include <unotools/fontdefs.hxx>
      30             : #include <vcl/vclenum.hxx>
      31             : 
      32             : #include <unordered_map>
      33             : 
      34             : class PhysicalFontFace;
      35             : class PhysicalFontFamily;
      36             : class ImplGetDevFontList;
      37             : class ImplGetDevSizeList;
      38             : class ImplFontEntry;
      39             : class ImplPreMatchFontSubstitution;
      40             : class ImplGlyphFallbackFontSubstitution;
      41             : class FontSelectPattern;
      42             : namespace vcl { class Font; }
      43             : class ConvertChar;
      44             : struct FontMatchStatus;
      45             : class OutputDevice;
      46             : class Size;
      47             : 
      48             : namespace com { namespace sun { namespace star { namespace lang { struct Locale; }}}}
      49             : 
      50             : // - ImplFontAttributes -
      51             : 
      52             : // device independent font properties
      53             : 
      54     7123221 : class ImplFontAttributes
      55             : {
      56             : public: // TODO: create matching interface class
      57     4576035 :     const OUString& GetFamilyName() const   { return maName; }
      58     4167095 :     const OUString& GetStyleName() const    { return maStyleName; }
      59    16134847 :     FontWeight      GetWeight() const       { return meWeight; }
      60    10675130 :     FontItalic      GetSlant() const        { return meItalic; }
      61     3167206 :     FontFamily      GetFamilyType() const   { return meFamily; }
      62     4629094 :     FontPitch       GetPitch() const        { return mePitch; }
      63     9826894 :     FontWidth       GetWidthType() const    { return meWidthType; }
      64    28324791 :     bool            IsSymbolFont() const    { return mbSymbolFlag; }
      65     2187587 :     void            SetFamilyName(const OUString& sFamilyName)  { maName = sFamilyName; }
      66     1167297 :     void            SetStyleName( const OUString& sStyleName)   { maStyleName = sStyleName; }
      67     1166190 :     void            SetFamilyType(const FontFamily eFontFamily) { meFamily = eFontFamily; }
      68     1175672 :     void            SetPitch(const FontPitch ePitch )          { mePitch = ePitch; }
      69     1164622 :     void            SetItalic(const FontItalic eItalic )       { meItalic = eItalic; }
      70     1164622 :     void            SetWeight(const FontWeight eWeight )       { meWeight = eWeight; }
      71     1164622 :     void            SetWidthType(const FontWidth eWidthType)   { meWidthType = eWidthType; }
      72     1155194 :     void            SetSymbolFlag(const bool bSymbolFlag )     { mbSymbolFlag = bSymbolFlag; }
      73             :     bool operator==(const ImplFontAttributes& rOther) const;
      74       50679 :     bool operator!=(const ImplFontAttributes& rOther) const
      75             :     {
      76       50679 :         return !(*this == rOther);
      77             :     }
      78             : 
      79             : private:
      80             :     OUString        maName;         // Font Family Name
      81             :     OUString        maStyleName;    // Font Style Name
      82             :     FontWeight      meWeight;       // Weight Type
      83             :     FontItalic      meItalic;       // Slant Type
      84             :     FontFamily      meFamily;       // Family Type
      85             :     FontPitch       mePitch;        // Pitch Type
      86             :     FontWidth       meWidthType;    // Width Type
      87             :     bool            mbSymbolFlag;
      88             : };
      89             : 
      90             : // - ImplDevFontAttributes -
      91             : 
      92             : // device dependent font properties
      93             : 
      94     2520275 : class ImplDevFontAttributes : public ImplFontAttributes
      95             : {
      96             : public: // TODO: create matching interface class
      97             :     const OUString&    GetAliasNames() const     { return maMapNames; }
      98             :     int                GetQuality() const        { return mnQuality; }
      99             :     bool               IsRotatable() const       { return mbOrientation; }
     100             :     bool               IsDeviceFont() const      { return mbDevice; }
     101           0 :     bool               IsEmbeddable() const      { return mbEmbeddable; }
     102           0 :     bool               IsSubsettable() const     { return mbSubsettable; }
     103             : 
     104             : public: // TODO: hide members behind accessor methods
     105             :     OUString           maMapNames;       // List of family name aliases separated with ';'
     106             :     int                mnQuality;        // Quality (used when similar fonts compete)
     107             :     bool               mbOrientation;    // true: physical font can be rotated
     108             :     bool               mbDevice;         // true: built in font
     109             :     bool               mbSubsettable;    // true: a subset of the font can be created
     110             :     bool               mbEmbeddable;     // true: the font can be embedded
     111             : };
     112             : 
     113     3610786 : class FontSelectPatternAttributes : public ImplFontAttributes
     114             : {
     115             : public:
     116             :                         FontSelectPatternAttributes( const vcl::Font&, const OUString& rSearchName,
     117             :                             const Size&, float fExactHeight );
     118             : #ifdef WNT
     119             :                         FontSelectPatternAttributes( const PhysicalFontFace&, const Size&,
     120             :                             float fExactHeight, int nOrientation, bool bVertical );
     121             : #endif
     122             : 
     123             :     size_t              hashCode() const;
     124             :     bool operator==(const FontSelectPatternAttributes& rOther) const;
     125             :     bool operator!=(const FontSelectPatternAttributes& rOther) const
     126             :     {
     127             :         return !(*this == rOther);
     128             :     }
     129             : 
     130             : public:
     131             :     OUString            maTargetName;       // name of the font name token that is chosen
     132             :     OUString            maSearchName;       // name of the font that matches best
     133             :     int                 mnWidth;            // width of font in pixel units
     134             :     int                 mnHeight;           // height of font in pixel units
     135             :     float               mfExactHeight;      // requested height (in pixels with subpixel details)
     136             :     int                 mnOrientation;      // text orientation in 3600 system
     137             :     LanguageType        meLanguage;         // text language
     138             :     bool                mbVertical;         // vertical mode of requested font
     139             :     bool                mbNonAntialiased;   // true if antialiasing is disabled
     140             : 
     141             :     bool                mbEmbolden;         // Force emboldening
     142             :     ItalicMatrix        maItalicMatrix;     // Force matrix for slant
     143             : };
     144             : 
     145     3560961 : class FontSelectPattern : public FontSelectPatternAttributes
     146             : {
     147             : public:
     148             :                         FontSelectPattern( const vcl::Font&, const OUString& rSearchName,
     149             :                             const Size&, float fExactHeight );
     150             : #ifdef WNT
     151             : // ifdeffed to prevent it going into unusedcode.easy
     152             :                         FontSelectPattern( const PhysicalFontFace&, const Size&,
     153             :                             float fExactHeight, int nOrientation, bool bVertical );
     154             : #endif
     155             : 
     156             : public: // TODO: change to private
     157             :     const PhysicalFontFace* mpFontData;         // a matching PhysicalFontFace object
     158             :     ImplFontEntry*      mpFontEntry;        // pointer to the resulting FontCache entry
     159             :     void copyAttributes(const FontSelectPatternAttributes &rAttributes);
     160             : };
     161             : 
     162             : // - ImplFontMetricData -
     163             : 
     164       13545 : class ImplFontMetricData : public ImplFontAttributes
     165             : {
     166             : public:
     167             :     explicit ImplFontMetricData( const FontSelectPattern& );
     168             :     void    ImplInitTextLineSize( const OutputDevice* pDev );
     169             :     void    ImplInitAboveTextLineSize();
     170             : 
     171             : public: // TODO: hide members behind accessor methods
     172             :     // font instance attributes from the font request
     173             :     long                mnWidth;                    // Reference Width
     174             :     short               mnOrientation;              // Rotation in 1/10 degrees
     175             : 
     176             :     // font metrics measured for the font instance
     177             :     long                mnAscent;                   // Ascent
     178             :     long                mnDescent;                  // Descent
     179             :     long                mnIntLeading;               // Internal Leading
     180             :     long                mnExtLeading;               // External Leading
     181             :     int                 mnSlant;                    // Slant (Italic/Oblique)
     182             :     long                mnMinKashida;               // Minimal width of kashida (Arabic)
     183             : 
     184             :     // font attributes queried from the font instance
     185             :     int                 meFamilyType;               // Font Family Type
     186             :     bool                mbDevice;                   // Flag for Device Fonts
     187             :     bool                mbScalableFont;
     188             :     bool                mbKernableFont;
     189             : 
     190             :     // font metrics that are usually derived from the measurements
     191             :     long                mnUnderlineSize;            // Lineheight of Underline
     192             :     long                mnUnderlineOffset;          // Offset from Underline to Baseline
     193             :     long                mnBUnderlineSize;           // Height of bold underline
     194             :     long                mnBUnderlineOffset;         // Offset from bold underline to baseline
     195             :     long                mnDUnderlineSize;           // Height of double underline
     196             :     long                mnDUnderlineOffset1;        // Offset from double underline to baseline
     197             :     long                mnDUnderlineOffset2;        // Offset from double underline to baseline
     198             :     long                mnWUnderlineSize;           // Height of WaveLine underline
     199             :     long                mnWUnderlineOffset;         // Offset from WaveLine underline to baseline, but centrered to WaveLine
     200             :     long                mnAboveUnderlineSize;       // Height of single underline (for Vertical Right)
     201             :     long                mnAboveUnderlineOffset;     // Offset from single underline to baseline (for Vertical Right)
     202             :     long                mnAboveBUnderlineSize;      // Height of bold underline (for Vertical Right)
     203             :     long                mnAboveBUnderlineOffset;    // Offset from bold underline to baseline (for Vertical Right)
     204             :     long                mnAboveDUnderlineSize;      // Height of double underline (for Vertical Right)
     205             :     long                mnAboveDUnderlineOffset1;   // Offset from double underline to baseline (for Vertical Right)
     206             :     long                mnAboveDUnderlineOffset2;   // Offset from double underline to baseline (for Vertical Right)
     207             :     long                mnAboveWUnderlineSize;      // Height of WaveLine-strike-out (for Vertical Right)
     208             :     long                mnAboveWUnderlineOffset;    // Offset from WaveLine-strike-out to baseline, but centrered to the WaveLine (for Vertical Right)
     209             :     long                mnStrikeoutSize;            // Height of single strike-out
     210             :     long                mnStrikeoutOffset;          // Offset from single strike-out to baseline
     211             :     long                mnBStrikeoutSize;           // Height of bold strike-out
     212             :     long                mnBStrikeoutOffset;         // Offset of bold strike-out to baseline
     213             :     long                mnDStrikeoutSize;           // Height of double strike-out
     214             :     long                mnDStrikeoutOffset1;        // Offset of double strike-out to baseline
     215             :     long                mnDStrikeoutOffset2;        // Offset of double strike-out to baseline
     216             : };
     217             : 
     218             : // - ImplFontEntry -
     219             : 
     220             : // TODO: rename ImplFontEntry to LogicalFontInstance
     221             : // TODO: allow sharing of metrics for related fonts
     222             : 
     223             : class VCL_PLUGIN_PUBLIC ImplFontEntry
     224             : {
     225             : public:
     226             :     explicit            ImplFontEntry( const FontSelectPattern& );
     227             :     virtual             ~ImplFontEntry();
     228             : 
     229             : public: // TODO: make data members private
     230             :     FontSelectPattern  maFontSelData;      // FontSelectionData
     231             :     ImplFontMetricData  maMetric;           // Font Metric
     232             :     const ConvertChar*  mpConversion;       // used e.g. for StarBats->StarSymbol
     233             :     long                mnLineHeight;
     234             :     sal_uLong               mnRefCount;
     235             :     sal_uInt16              mnSetFontFlags;     // Flags returned by SalGraphics::SetFont()
     236             :     short               mnOwnOrientation;   // text angle if lower layers don't rotate text themselves
     237             :     short               mnOrientation;      // text angle in 3600 system
     238             :     bool                mbInit;             // true if maMetric member is valid
     239             : 
     240             :     void                AddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
     241             :     bool                GetFallbackForUnicode( sal_UCS4, FontWeight eWeight, OUString* pFontName ) const;
     242             :     void                IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
     243             : 
     244             : private:
     245             :     // cache of Unicode characters and replacement font names
     246             :     // TODO: a fallback map can be shared with many other ImplFontEntries
     247             :     // TODO: at least the ones which just differ in orientation, stretching or height
     248             :     typedef ::std::pair<sal_UCS4,FontWeight> GFBCacheKey;
     249             :     struct GFBCacheKey_Hash{ size_t operator()( const GFBCacheKey& ) const; };
     250             :     typedef ::std::unordered_map<GFBCacheKey,OUString,GFBCacheKey_Hash> UnicodeFallbackList;
     251             :     UnicodeFallbackList* mpUnicodeFallbackList;
     252             : };
     253             : 
     254             : class ImplTextLineInfo
     255             : {
     256             : private:
     257             :     long        mnWidth;
     258             :     sal_Int32   mnIndex;
     259             :     sal_Int32   mnLen;
     260             : 
     261             : public:
     262        9859 :                ImplTextLineInfo( long nWidth, sal_Int32 nIndex, sal_Int32 nLen )
     263             :                {
     264        9859 :                    if(nIndex == -1 || nIndex == 0x0FFFF || nLen == -1 || nLen == 0x0FFFF)
     265             :                    {
     266             :                         SAL_INFO("sal.rtl.xub",
     267             :                                  "ImplTextLine Info Suspicious arguments nIndex:" << nIndex << " nLen:" << nLen);
     268             :                    }
     269        9859 :                    mnWidth = nWidth;
     270        9859 :                    mnIndex = nIndex;
     271        9859 :                    mnLen   = nLen;
     272        9859 :                }
     273             : 
     274       13453 :     long       GetWidth() const { return mnWidth; }
     275        4463 :     sal_Int32  GetIndex() const { return mnIndex; }
     276        4463 :     sal_Int32  GetLen() const { return mnLen; }
     277             : };
     278             : 
     279             : #define MULTITEXTLINEINFO_RESIZE    16
     280             : typedef ImplTextLineInfo* PImplTextLineInfo;
     281             : 
     282             : class ImplMultiTextLineInfo
     283             : {
     284             : private:
     285             :     PImplTextLineInfo*  mpLines;
     286             :     sal_Int32           mnLines;
     287             :     sal_Int32           mnSize;
     288             : 
     289             : public:
     290             :                         ImplMultiTextLineInfo();
     291             :                         ~ImplMultiTextLineInfo();
     292             : 
     293             :     void                AddLine( ImplTextLineInfo* pLine );
     294             :     void                Clear();
     295             : 
     296        9859 :     ImplTextLineInfo*   GetLine( sal_uInt16 nLine ) const
     297        9859 :                             { return mpLines[nLine]; }
     298        9710 :     sal_Int32           Count() const { return mnLines; }
     299             : 
     300             : private:
     301             :                             ImplMultiTextLineInfo( const ImplMultiTextLineInfo& ) SAL_DELETED_FUNCTION;
     302             :     ImplMultiTextLineInfo&  operator=( const ImplMultiTextLineInfo& ) SAL_DELETED_FUNCTION;
     303             : };
     304             : 
     305             : #endif // INCLUDED_VCL_INC_OUTFONT_HXX
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11