xref: /aoo41x/main/vcl/inc/unx/salfont.h (revision 24f6443d)
1*24f6443dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24f6443dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24f6443dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24f6443dSAndrew Rist  * distributed with this work for additional information
6*24f6443dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24f6443dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24f6443dSAndrew Rist  * "License"); you may not use this file except in compliance
9*24f6443dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24f6443dSAndrew Rist  *
11*24f6443dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24f6443dSAndrew Rist  *
13*24f6443dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24f6443dSAndrew Rist  * software distributed under the License is distributed on an
15*24f6443dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24f6443dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*24f6443dSAndrew Rist  * specific language governing permissions and limitations
18*24f6443dSAndrew Rist  * under the License.
19*24f6443dSAndrew Rist  *
20*24f6443dSAndrew Rist  *************************************************************/
21*24f6443dSAndrew Rist 
22*24f6443dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_SALFONT_H
25cdf0e10cSrcweir #define _SV_SALFONT_H
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // -=-= exports =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
28cdf0e10cSrcweir class	SalFontCache;
29cdf0e10cSrcweir struct	SalFontDimension;
30cdf0e10cSrcweir class	SalFontFamily;
31cdf0e10cSrcweir class	SalFontFamilyList;
32cdf0e10cSrcweir class	SalFontStruct;
33cdf0e10cSrcweir class	SalFontStructList;
34cdf0e10cSrcweir class	SalFonts;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
37cdf0e10cSrcweir #include <salstd.hxx>
38cdf0e10cSrcweir #include <vcl/outfont.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // -=-= forwards =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
41cdf0e10cSrcweir typedef ULONG XFP_FLAGS;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class	SalDisplay;
44cdf0e10cSrcweir class	SalFontCacheItem;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // -=-= SalFontCache -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
47cdf0e10cSrcweir DECLARE_LIST( SalFontCache, SalFontCacheItem* )
48cdf0e10cSrcweir 
49cdf0e10cSrcweir // -=-= SalFontDimension -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
50cdf0e10cSrcweir struct SalFontDimension
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 			USHORT		nHeight_;				// [pixel]
53cdf0e10cSrcweir 			USHORT		nPtHeight_;				// [point/10]
54cdf0e10cSrcweir 			USHORT		nAverage_;				// [pixel/10]
55cdf0e10cSrcweir 			USHORT		nXRes_;					// [dpi]
56cdf0e10cSrcweir 			USHORT		nYRes_;					// [dpi]
57cdf0e10cSrcweir 			USHORT      nSlant_;				// [pixel]
58cdf0e10cSrcweir //			size_t		nUnderlineThickness_;	// [pixel]
59cdf0e10cSrcweir //			size_t      nUnderlinePosition_;    // [pixel]
60cdf0e10cSrcweir //			size_t      nStrikeoutAscent_;      // [pixel]
61cdf0e10cSrcweir //			size_t      nStrikeoutDescent_;     // [pixel]
62cdf0e10cSrcweir //			Subscript, Superscript, Capital, Space ...
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	inline				SalFontDimension( USHORT nA = 0, USHORT nH = 0 );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	inline	BOOL		IsScalable() const;
GetWidthSalFontDimension67cdf0e10cSrcweir 	inline	USHORT		GetWidth() const { return (nAverage_ + 5) / 10; }
68cdf0e10cSrcweir 	inline	Size		GetSize() const;
69cdf0e10cSrcweir 	inline	void		SetSize( const Size & rSize );
70cdf0e10cSrcweir 	inline	BOOL		operator == ( const SalFontDimension &r ) const;
71cdf0e10cSrcweir 	inline	BOOL		operator != ( const SalFontDimension &r ) const;
72cdf0e10cSrcweir 	inline	BOOL		operator >= ( const SalFontDimension &r ) const;
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
SalFontDimension(USHORT nA,USHORT nH)75cdf0e10cSrcweir inline SalFontDimension::SalFontDimension( USHORT nA, USHORT nH )
76cdf0e10cSrcweir 	: nHeight_( nH ), nAverage_( nA )
77cdf0e10cSrcweir { nPtHeight_ = nXRes_ = nYRes_ = nSlant_ = 0; }
78cdf0e10cSrcweir 
IsScalable() const79cdf0e10cSrcweir inline BOOL	SalFontDimension::IsScalable() const
80cdf0e10cSrcweir { return !nHeight_ && !nPtHeight_ && !nAverage_; }
81cdf0e10cSrcweir 
GetSize() const82cdf0e10cSrcweir inline Size	SalFontDimension::GetSize() const
83cdf0e10cSrcweir { return Size( (nAverage_ + 5) / 10, nHeight_ ); }
84cdf0e10cSrcweir 
SetSize(const Size & rSize)85cdf0e10cSrcweir inline void	SalFontDimension::SetSize( const Size & rSize )
86cdf0e10cSrcweir { nAverage_ = (USHORT)rSize.Width() * 10; nHeight_ = (USHORT)rSize.Height(); }
87cdf0e10cSrcweir 
operator ==(const SalFontDimension & r) const88cdf0e10cSrcweir inline BOOL	SalFontDimension::operator == ( const SalFontDimension &r ) const
89cdf0e10cSrcweir { return nHeight_ == r.nHeight_ && (!r.nAverage_ || nAverage_ == r.nAverage_); }
90cdf0e10cSrcweir 
operator !=(const SalFontDimension & r) const91cdf0e10cSrcweir inline BOOL	SalFontDimension::operator != ( const SalFontDimension &r ) const
92cdf0e10cSrcweir { return !(*this == r); }
93cdf0e10cSrcweir 
operator >=(const SalFontDimension & r) const94cdf0e10cSrcweir inline BOOL	SalFontDimension::operator >= ( const SalFontDimension &r ) const
95cdf0e10cSrcweir { return nHeight_ > r.nHeight_
96cdf0e10cSrcweir 		 || (nHeight_ == r.nHeight_ && nAverage_ >= r.nAverage_); }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // -=-= SalFontStruct =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
99cdf0e10cSrcweir class SalFontStruct : public ImplFontMetricData
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	friend class SalDisplay;
102cdf0e10cSrcweir 	friend class SalGraphicsData;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 			SalFontCacheItem*pCache_;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined  DBG_UTIL
107cdf0e10cSrcweir 			ByteString		aFontName_;
108cdf0e10cSrcweir #endif
109cdf0e10cSrcweir 			USHORT			nHeightCount_;		// Anzahl der Hoehen-Eintraege
110cdf0e10cSrcweir 			SalFontDimension*pDimensions_;		// Hoehen-Array
111cdf0e10cSrcweir 			USHORT			nWeight_;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 			USHORT			nFoundry_;			// properties indexies
114cdf0e10cSrcweir 			USHORT			nFamily_;
115cdf0e10cSrcweir 			USHORT			nWeightName_;
116cdf0e10cSrcweir 			USHORT			nSlant_;
117cdf0e10cSrcweir 			USHORT			nSetWidthName_;
118cdf0e10cSrcweir 			ByteString		aAddStyleName_;
119cdf0e10cSrcweir 			USHORT			nSpacing_;
120cdf0e10cSrcweir 			USHORT			nCharSet_;
121cdf0e10cSrcweir 			USHORT			nFaceName_;
122cdf0e10cSrcweir 			BOOL            mbValidFontDescription;	// valid xlfd entries
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 			void			Init();
125cdf0e10cSrcweir 			BOOL			Init( SalDisplay*		pDisp,
126cdf0e10cSrcweir 								  const char*		pFontName,
127cdf0e10cSrcweir 								  SalFontDimension&	rDim );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 			ByteString		GetXFontName( const SalFontDimension& );
130cdf0e10cSrcweir 
SetFoundry(USHORT n)131cdf0e10cSrcweir 	inline	void			SetFoundry( USHORT n )
132cdf0e10cSrcweir 		{ nFoundry_ = n; }
SetFamily(USHORT n)133cdf0e10cSrcweir 	inline	void			SetFamily( USHORT n )
134cdf0e10cSrcweir 		{ meFamily = sal_FamilyToSal( nFamily_ = n ); }
SetWeightName(USHORT n)135cdf0e10cSrcweir 	inline	void			SetWeightName( USHORT n )
136cdf0e10cSrcweir 		{ meWeight = sal_WeightToSal( nWeightName_ = n ); }
SetSlant(USHORT n)137cdf0e10cSrcweir 	inline	void			SetSlant( USHORT n )
138cdf0e10cSrcweir 		{ meItalic = sal_ItalicToSal( nSlant_ = n ); }
SetSetWidthName(USHORT n)139cdf0e10cSrcweir 	inline	void			SetSetWidthName( USHORT n )
140cdf0e10cSrcweir 		{ nSetWidthName_ = n; }
SetAddStyleName(const ByteString & rAddStyle)141cdf0e10cSrcweir 	inline	void			SetAddStyleName( const ByteString& rAddStyle )
142cdf0e10cSrcweir 		{ aAddStyleName_ = rAddStyle; aAddStyleName_.ToLowerAscii(); }
SetSpacing(USHORT n)143cdf0e10cSrcweir 	inline	void			SetSpacing( USHORT n )
144cdf0e10cSrcweir 		{ mePitch = sal_PitchToSal( nSpacing_ = n ); }
SetAverage(long n)145cdf0e10cSrcweir 	inline	void			SetAverage( long n )
146cdf0e10cSrcweir 		{ mnWidth = (n + 5) / 10; }
147cdf0e10cSrcweir 	void					SetCharSet( USHORT n );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 							SalFontStruct( const SalFontStruct& rFont );
150cdf0e10cSrcweir public:
151cdf0e10cSrcweir 							SalFontStruct( SalDisplay*			pDisp,
152cdf0e10cSrcweir 										   const char*			pFontName,
153cdf0e10cSrcweir 										   SalFontDimension&	rDim );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 							~SalFontStruct();
156cdf0e10cSrcweir 
Cache(SalFontCacheItem * p)157cdf0e10cSrcweir 	inline	void			Cache( SalFontCacheItem *p ) { pCache_ = p; }
IsCache() const158cdf0e10cSrcweir 	inline	SalFontCacheItem*IsCache() const { return pCache_; }
IsScalable() const159cdf0e10cSrcweir 	inline	BOOL			IsScalable() const { return TYPE_SCALABLE==meType; }
GetDim() const160cdf0e10cSrcweir 	inline	SalFontDimension*GetDim() const { return pDimensions_; }
IsValid() const161cdf0e10cSrcweir 	inline  BOOL			IsValid() const { return mbValidFontDescription; }
162cdf0e10cSrcweir #ifdef DBG_UTIL
GetName() const163cdf0e10cSrcweir         	const ByteString&	GetName() const { return aFontName_; }
164cdf0e10cSrcweir #endif
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 			ImplFontData   *GetDevFontData();
167cdf0e10cSrcweir 			SalFontCacheItem*Load( SalDisplay *pDisp, const SalFontDimension &rDim );
GetCharSet()168cdf0e10cSrcweir 			CharSet GetCharSet() { return meCharSet; }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir };
171cdf0e10cSrcweir 
172cdf0e10cSrcweir // -=-= SalFontStructList =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
173cdf0e10cSrcweir DECLARE_LIST( SalFontStructList, SalFontStruct* )
174cdf0e10cSrcweir 
175cdf0e10cSrcweir #endif // _SV_SALFONT_H
176cdf0e10cSrcweir 
177