LCOV - code coverage report
Current view: top level - vcl/inc - impfont.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 30 36.7 %
Date: 2012-08-25 Functions: 11 22 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 18 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_IMPFONT_HXX
      30                 :            : #define _SV_IMPFONT_HXX
      31                 :            : 
      32                 :            : #include <tools/gen.hxx>
      33                 :            : #include <tools/string.hxx>
      34                 :            : #include <i18npool/lang.h>
      35                 :            : #include <tools/color.hxx>
      36                 :            : #include <vcl/dllapi.h>
      37                 :            : #include <vcl/vclenum.hxx>
      38                 :            : #include <vcl/fntstyle.hxx>
      39                 :            : 
      40                 :            : // ------------
      41                 :            : // - Impl_Font -
      42                 :            : // ------------
      43                 :            : 
      44         [ +  - ]:    2757759 : class Impl_Font
      45                 :            : {
      46                 :            : public:
      47                 :            :              Impl_Font();
      48                 :            :              Impl_Font( const Impl_Font& );
      49                 :            : 
      50                 :            :     bool     operator==( const Impl_Font& ) const;
      51                 :            : 
      52         [ +  + ]:      60495 :     FontPitch           GetPitch()      { if(mePitch==PITCH_DONTKNOW)    AskConfig(); return mePitch; }
      53         [ +  + ]:      39576 :     FontFamily          GetFamily()     { if(meFamily==FAMILY_DONTKNOW)  AskConfig(); return meFamily; }
      54         [ -  + ]:    2163931 :     FontItalic          GetItalic()     { if(meItalic==ITALIC_DONTKNOW)  AskConfig(); return meItalic; }
      55         [ +  + ]:     453541 :     FontWeight          GetWeight()     { if(meWeight==WEIGHT_DONTKNOW)  AskConfig(); return meWeight; }
      56         [ -  + ]:       7313 :     FontWidth           GetWidthType()  { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
      57                 :            : 
      58                 :            : private:
      59                 :            :     friend class Font;
      60                 :            :     void                AskConfig();
      61                 :            : 
      62                 :            :     int                 mnRefCount;
      63                 :            :     String              maFamilyName;
      64                 :            :     String              maStyleName;
      65                 :            :     Size                maSize;
      66                 :            :     Color               maColor;        // compatibility, now on output device
      67                 :            :     Color               maFillColor;    // compatibility, now on output device
      68                 :            :     rtl_TextEncoding    meCharSet;
      69                 :            :     LanguageType        meLanguage;
      70                 :            :     LanguageType        meCJKLanguage;
      71                 :            :     FontFamily          meFamily;
      72                 :            :     FontPitch           mePitch;
      73                 :            :     TextAlign           meAlign;
      74                 :            :     FontWeight          meWeight;
      75                 :            :     FontWidth           meWidthType;
      76                 :            :     FontItalic          meItalic;
      77                 :            :     FontUnderline       meUnderline;
      78                 :            :     FontUnderline       meOverline;
      79                 :            :     FontStrikeout       meStrikeout;
      80                 :            :     FontRelief          meRelief;
      81                 :            :     FontEmphasisMark    meEmphasisMark;
      82                 :            :     short               mnOrientation;
      83                 :            :     FontKerning         mnKerning;
      84                 :            :     sal_Bool                mbWordLine:1,
      85                 :            :                         mbOutline:1,
      86                 :            :                         mbConfigLookup:1,   // there was a config lookup
      87                 :            :                         mbShadow:1,
      88                 :            :                         mbVertical:1,
      89                 :            :                         mbTransparent:1;    // compatibility, now on output device
      90                 :            : 
      91                 :            :     friend SvStream&    operator>>( SvStream& rIStm, Impl_Font& );
      92                 :            :     friend SvStream&    operator<<( SvStream& rOStm, const Impl_Font& );
      93                 :            : };
      94                 :            : 
      95                 :            : // ------------------
      96                 :            : // - ImplFontMetric -
      97                 :            : // ------------------
      98                 :            : 
      99                 :            : class ImplFontMetric
     100                 :            : {
     101                 :            :     friend class OutputDevice;
     102                 :            : 
     103                 :            : private:
     104                 :            :     long    mnAscent;      // Ascent
     105                 :            :     long    mnDescent;     // Descent
     106                 :            :     long    mnIntLeading;  // Internal Leading
     107                 :            :     long    mnExtLeading;  // External Leading
     108                 :            :     long    mnLineHeight;  // Ascent+Descent+EmphasisMark
     109                 :            :     long    mnSlant;       // Slant
     110                 :            :     sal_uInt16  mnMiscFlags;   // Misc Flags
     111                 :            :     sal_uInt32  mnRefCount;    // Reference Counter
     112                 :            : 
     113                 :            :     enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 };
     114                 :            : 
     115                 :            : public:
     116                 :            :             ImplFontMetric();
     117                 :            :     void    AddReference();
     118                 :            :     void    DeReference();
     119                 :            : 
     120                 :     522721 :     long    GetAscent() const       { return mnAscent; }
     121                 :     450533 :     long    GetDescent() const      { return mnDescent; }
     122                 :     889347 :     long    GetIntLeading() const   { return mnIntLeading; }
     123                 :       3864 :     long    GetExtLeading() const   { return mnExtLeading; }
     124                 :          0 :     long    GetLineHeight() const   { return mnLineHeight; }
     125                 :          0 :     long    GetSlant() const        { return mnSlant; }
     126                 :            : 
     127                 :            :     bool    IsDeviceFont() const    { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
     128                 :     752769 :     bool    IsScalable() const      { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
     129                 :            :     bool    SupportsLatin() const   { return ((mnMiscFlags & LATIN_FLAG) != 0); }
     130                 :            :     bool    SupportsCJK() const     { return ((mnMiscFlags & CJK_FLAG) != 0); }
     131                 :            :     bool    SupportsCTL() const     { return ((mnMiscFlags & CTL_FLAG) != 0); }
     132                 :            : 
     133                 :            :     bool    operator==( const ImplFontMetric& ) const;
     134                 :            : };
     135                 :            : 
     136                 :            : // ------------------
     137                 :            : // - ImplFontOptions -
     138                 :            : // ------------------
     139                 :            : 
     140                 :            : class ImplFontOptions
     141                 :            : {
     142                 :            : public:
     143                 :            :     FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used
     144                 :            :     FontAntiAlias      meAntiAlias;      // whether the font should be antialiased
     145                 :            :     FontAutoHint       meAutoHint;       // whether the font should be autohinted
     146                 :            :     FontHinting        meHinting;        // whether the font should be hinted
     147                 :            :     FontHintStyle      meHintStyle;      // type of font hinting to be used
     148                 :            : public:
     149                 :          0 :     ImplFontOptions() :
     150                 :            :         meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
     151                 :            :         meAntiAlias(ANTIALIAS_DONTKNOW),
     152                 :            :         meAutoHint(AUTOHINT_DONTKNOW),
     153                 :            :         meHinting(HINTING_DONTKNOW),
     154                 :          0 :         meHintStyle(HINT_SLIGHT)
     155                 :          0 :     {}
     156                 :          0 :     virtual ~ImplFontOptions()
     157         [ #  # ]:          0 :     {}
     158                 :          0 :     FontAutoHint GetUseAutoHint() const
     159                 :          0 :         { return meAutoHint; }
     160                 :          0 :     FontHintStyle GetHintStyle() const
     161                 :          0 :         { return meHintStyle; }
     162                 :          0 :     bool DontUseEmbeddedBitmaps() const
     163                 :          0 :         { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
     164                 :          0 :     bool DontUseAntiAlias() const
     165                 :          0 :         { return meAntiAlias == ANTIALIAS_FALSE; }
     166                 :          0 :     bool DontUseHinting() const
     167 [ #  # ][ #  # ]:          0 :         { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
     168                 :          0 :     virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
     169                 :          0 :         { return NULL; }
     170                 :            : };
     171                 :            : 
     172                 :            : // -------------------
     173                 :            : // - ImplFontCharMap -
     174                 :            : // -------------------
     175                 :            : 
     176                 :            : class CmapResult;
     177                 :            : 
     178                 :            : class VCL_PLUGIN_PUBLIC ImplFontCharMap
     179                 :            : {
     180                 :            : public:
     181                 :            :     explicit             ImplFontCharMap( const CmapResult& );
     182                 :            :     virtual              ~ImplFontCharMap();
     183                 :            : 
     184                 :            :     static ImplFontCharMap* GetDefaultMap( bool bSymbols=false);
     185                 :            : 
     186                 :            :     bool                IsDefaultMap() const;
     187                 :            :     bool                HasChar( sal_uInt32 ) const;
     188                 :            :     int                 CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const;
     189                 :            :     int                 GetCharCount() const;
     190                 :            : 
     191                 :            :     sal_uInt32          GetFirstChar() const;
     192                 :            :     sal_uInt32          GetLastChar() const;
     193                 :            : 
     194                 :            :     sal_uInt32          GetNextChar( sal_uInt32 ) const;
     195                 :            :     sal_uInt32          GetPrevChar( sal_uInt32 ) const;
     196                 :            : 
     197                 :            :     int                 GetIndexFromChar( sal_uInt32 ) const;
     198                 :            :     sal_uInt32          GetCharFromIndex( int ) const;
     199                 :            : 
     200                 :            :     void                AddReference() const;
     201                 :            :     void                DeReference() const;
     202                 :            : 
     203                 :            :     int                 GetGlyphIndex( sal_uInt32 ) const;
     204                 :            : 
     205                 :            : private:
     206                 :            :     int                 ImplFindRangeIndex( sal_uInt32 ) const;
     207                 :            : 
     208                 :            :     // prevent assignment and copy construction
     209                 :            :     explicit            ImplFontCharMap( const ImplFontCharMap& );
     210                 :            :     void                operator=( const ImplFontCharMap& );
     211                 :            : 
     212                 :            : private:
     213                 :            :     const sal_uInt32*   mpRangeCodes;     // pairs of StartCode/(EndCode+1)
     214                 :            :     const int*          mpStartGlyphs;    // range-specific mapper to glyphs
     215                 :            :     const sal_uInt16*       mpGlyphIds;       // individual glyphid mappings
     216                 :            :     int                 mnRangeCount;
     217                 :            :     int                 mnCharCount;      // covered codepoints
     218                 :            :     mutable int         mnRefCount;
     219                 :            : };
     220                 :            : 
     221                 :            : // CmapResult is a normalized version of the many CMAP formats
     222                 :            : class VCL_PLUGIN_PUBLIC CmapResult
     223                 :            : {
     224                 :            : public:
     225                 :            :     explicit    CmapResult( bool bSymbolic = false,
     226                 :            :                     const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
     227                 :            :                     const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
     228                 :            : 
     229                 :            :     const sal_uInt32* mpRangeCodes;
     230                 :            :     const int*        mpStartGlyphs;
     231                 :            :     const sal_uInt16*     mpGlyphIds;
     232                 :            :     int               mnRangeCount;
     233                 :            :     bool              mbSymbolic;
     234                 :            :     bool              mbRecoded;
     235                 :            : };
     236                 :            : 
     237                 :            : bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
     238                 :            : 
     239                 :            : #endif // _SV_IMPFONT_HXX
     240                 :            : 
     241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10