1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _SV_SALFONT_H 29*cdf0e10cSrcweir #define _SV_SALFONT_H 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // -=-= exports =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 32*cdf0e10cSrcweir class SalFontCache; 33*cdf0e10cSrcweir struct SalFontDimension; 34*cdf0e10cSrcweir class SalFontFamily; 35*cdf0e10cSrcweir class SalFontFamilyList; 36*cdf0e10cSrcweir class SalFontStruct; 37*cdf0e10cSrcweir class SalFontStructList; 38*cdf0e10cSrcweir class SalFonts; 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 41*cdf0e10cSrcweir #include <salstd.hxx> 42*cdf0e10cSrcweir #include <vcl/outfont.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir // -=-= forwards =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 45*cdf0e10cSrcweir typedef ULONG XFP_FLAGS; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir class SalDisplay; 48*cdf0e10cSrcweir class SalFontCacheItem; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // -=-= SalFontCache -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 51*cdf0e10cSrcweir DECLARE_LIST( SalFontCache, SalFontCacheItem* ) 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // -=-= SalFontDimension -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 54*cdf0e10cSrcweir struct SalFontDimension 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir USHORT nHeight_; // [pixel] 57*cdf0e10cSrcweir USHORT nPtHeight_; // [point/10] 58*cdf0e10cSrcweir USHORT nAverage_; // [pixel/10] 59*cdf0e10cSrcweir USHORT nXRes_; // [dpi] 60*cdf0e10cSrcweir USHORT nYRes_; // [dpi] 61*cdf0e10cSrcweir USHORT nSlant_; // [pixel] 62*cdf0e10cSrcweir // size_t nUnderlineThickness_; // [pixel] 63*cdf0e10cSrcweir // size_t nUnderlinePosition_; // [pixel] 64*cdf0e10cSrcweir // size_t nStrikeoutAscent_; // [pixel] 65*cdf0e10cSrcweir // size_t nStrikeoutDescent_; // [pixel] 66*cdf0e10cSrcweir // Subscript, Superscript, Capital, Space ... 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir inline SalFontDimension( USHORT nA = 0, USHORT nH = 0 ); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir inline BOOL IsScalable() const; 71*cdf0e10cSrcweir inline USHORT GetWidth() const { return (nAverage_ + 5) / 10; } 72*cdf0e10cSrcweir inline Size GetSize() const; 73*cdf0e10cSrcweir inline void SetSize( const Size & rSize ); 74*cdf0e10cSrcweir inline BOOL operator == ( const SalFontDimension &r ) const; 75*cdf0e10cSrcweir inline BOOL operator != ( const SalFontDimension &r ) const; 76*cdf0e10cSrcweir inline BOOL operator >= ( const SalFontDimension &r ) const; 77*cdf0e10cSrcweir }; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir inline SalFontDimension::SalFontDimension( USHORT nA, USHORT nH ) 80*cdf0e10cSrcweir : nHeight_( nH ), nAverage_( nA ) 81*cdf0e10cSrcweir { nPtHeight_ = nXRes_ = nYRes_ = nSlant_ = 0; } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir inline BOOL SalFontDimension::IsScalable() const 84*cdf0e10cSrcweir { return !nHeight_ && !nPtHeight_ && !nAverage_; } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir inline Size SalFontDimension::GetSize() const 87*cdf0e10cSrcweir { return Size( (nAverage_ + 5) / 10, nHeight_ ); } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir inline void SalFontDimension::SetSize( const Size & rSize ) 90*cdf0e10cSrcweir { nAverage_ = (USHORT)rSize.Width() * 10; nHeight_ = (USHORT)rSize.Height(); } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir inline BOOL SalFontDimension::operator == ( const SalFontDimension &r ) const 93*cdf0e10cSrcweir { return nHeight_ == r.nHeight_ && (!r.nAverage_ || nAverage_ == r.nAverage_); } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir inline BOOL SalFontDimension::operator != ( const SalFontDimension &r ) const 96*cdf0e10cSrcweir { return !(*this == r); } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir inline BOOL SalFontDimension::operator >= ( const SalFontDimension &r ) const 99*cdf0e10cSrcweir { return nHeight_ > r.nHeight_ 100*cdf0e10cSrcweir || (nHeight_ == r.nHeight_ && nAverage_ >= r.nAverage_); } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // -=-= SalFontStruct =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 103*cdf0e10cSrcweir class SalFontStruct : public ImplFontMetricData 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir friend class SalDisplay; 106*cdf0e10cSrcweir friend class SalGraphicsData; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir SalFontCacheItem*pCache_; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL 111*cdf0e10cSrcweir ByteString aFontName_; 112*cdf0e10cSrcweir #endif 113*cdf0e10cSrcweir USHORT nHeightCount_; // Anzahl der Hoehen-Eintraege 114*cdf0e10cSrcweir SalFontDimension*pDimensions_; // Hoehen-Array 115*cdf0e10cSrcweir USHORT nWeight_; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir USHORT nFoundry_; // properties indexies 118*cdf0e10cSrcweir USHORT nFamily_; 119*cdf0e10cSrcweir USHORT nWeightName_; 120*cdf0e10cSrcweir USHORT nSlant_; 121*cdf0e10cSrcweir USHORT nSetWidthName_; 122*cdf0e10cSrcweir ByteString aAddStyleName_; 123*cdf0e10cSrcweir USHORT nSpacing_; 124*cdf0e10cSrcweir USHORT nCharSet_; 125*cdf0e10cSrcweir USHORT nFaceName_; 126*cdf0e10cSrcweir BOOL mbValidFontDescription; // valid xlfd entries 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir void Init(); 129*cdf0e10cSrcweir BOOL Init( SalDisplay* pDisp, 130*cdf0e10cSrcweir const char* pFontName, 131*cdf0e10cSrcweir SalFontDimension& rDim ); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir ByteString GetXFontName( const SalFontDimension& ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir inline void SetFoundry( USHORT n ) 136*cdf0e10cSrcweir { nFoundry_ = n; } 137*cdf0e10cSrcweir inline void SetFamily( USHORT n ) 138*cdf0e10cSrcweir { meFamily = sal_FamilyToSal( nFamily_ = n ); } 139*cdf0e10cSrcweir inline void SetWeightName( USHORT n ) 140*cdf0e10cSrcweir { meWeight = sal_WeightToSal( nWeightName_ = n ); } 141*cdf0e10cSrcweir inline void SetSlant( USHORT n ) 142*cdf0e10cSrcweir { meItalic = sal_ItalicToSal( nSlant_ = n ); } 143*cdf0e10cSrcweir inline void SetSetWidthName( USHORT n ) 144*cdf0e10cSrcweir { nSetWidthName_ = n; } 145*cdf0e10cSrcweir inline void SetAddStyleName( const ByteString& rAddStyle ) 146*cdf0e10cSrcweir { aAddStyleName_ = rAddStyle; aAddStyleName_.ToLowerAscii(); } 147*cdf0e10cSrcweir inline void SetSpacing( USHORT n ) 148*cdf0e10cSrcweir { mePitch = sal_PitchToSal( nSpacing_ = n ); } 149*cdf0e10cSrcweir inline void SetAverage( long n ) 150*cdf0e10cSrcweir { mnWidth = (n + 5) / 10; } 151*cdf0e10cSrcweir void SetCharSet( USHORT n ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir SalFontStruct( const SalFontStruct& rFont ); 154*cdf0e10cSrcweir public: 155*cdf0e10cSrcweir SalFontStruct( SalDisplay* pDisp, 156*cdf0e10cSrcweir const char* pFontName, 157*cdf0e10cSrcweir SalFontDimension& rDim ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir ~SalFontStruct(); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir inline void Cache( SalFontCacheItem *p ) { pCache_ = p; } 162*cdf0e10cSrcweir inline SalFontCacheItem*IsCache() const { return pCache_; } 163*cdf0e10cSrcweir inline BOOL IsScalable() const { return TYPE_SCALABLE==meType; } 164*cdf0e10cSrcweir inline SalFontDimension*GetDim() const { return pDimensions_; } 165*cdf0e10cSrcweir inline BOOL IsValid() const { return mbValidFontDescription; } 166*cdf0e10cSrcweir #ifdef DBG_UTIL 167*cdf0e10cSrcweir const ByteString& GetName() const { return aFontName_; } 168*cdf0e10cSrcweir #endif 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir ImplFontData *GetDevFontData(); 171*cdf0e10cSrcweir SalFontCacheItem*Load( SalDisplay *pDisp, const SalFontDimension &rDim ); 172*cdf0e10cSrcweir CharSet GetCharSet() { return meCharSet; } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir }; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // -=-= SalFontStructList =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 177*cdf0e10cSrcweir DECLARE_LIST( SalFontStructList, SalFontStruct* ) 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir #endif // _SV_SALFONT_H 180*cdf0e10cSrcweir 181