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

Generated by: LCOV version 1.10