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