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