xref: /aoo41x/main/vcl/source/gdi/metric.cxx (revision 43ad51ff)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <impfont.hxx>
28cdf0e10cSrcweir #include <vcl/metric.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir #include <set>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <cstdio>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // =======================================================================
36cdf0e10cSrcweir 
ImplFontMetric()37cdf0e10cSrcweir ImplFontMetric::ImplFontMetric()
38cdf0e10cSrcweir :   mnAscent( 0 ),
39cdf0e10cSrcweir     mnDescent( 0 ),
40cdf0e10cSrcweir     mnIntLeading( 0 ),
41cdf0e10cSrcweir     mnExtLeading( 0 ),
42cdf0e10cSrcweir     mnLineHeight( 0 ),
43cdf0e10cSrcweir     mnSlant( 0 ),
44cdf0e10cSrcweir     mnMiscFlags( 0 ),
45cdf0e10cSrcweir     mnRefCount( 1 )
46cdf0e10cSrcweir {}
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // -----------------------------------------------------------------------
49cdf0e10cSrcweir 
AddReference()50cdf0e10cSrcweir inline void ImplFontMetric::AddReference()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     // TODO: disable refcounting on the default maps?
53cdf0e10cSrcweir     ++mnRefCount;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // -----------------------------------------------------------------------
57cdf0e10cSrcweir 
DeReference()58cdf0e10cSrcweir inline void ImplFontMetric::DeReference()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     // TODO: disable refcounting on the default maps?
61cdf0e10cSrcweir     if( --mnRefCount <= 0 )
62cdf0e10cSrcweir         delete this;
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -----------------------------------------------------------------------
66cdf0e10cSrcweir 
operator ==(const ImplFontMetric & r) const67cdf0e10cSrcweir bool ImplFontMetric::operator==( const ImplFontMetric& r ) const
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     if( mnMiscFlags  != r.mnMiscFlags )
70cdf0e10cSrcweir         return false;
71cdf0e10cSrcweir     if( mnAscent     != r.mnAscent )
72cdf0e10cSrcweir         return false;
73cdf0e10cSrcweir     if( mnDescent    != r.mnDescent )
74cdf0e10cSrcweir         return false;
75cdf0e10cSrcweir     if( mnIntLeading != r.mnIntLeading )
76cdf0e10cSrcweir         return false;
77cdf0e10cSrcweir     if( mnExtLeading != r.mnExtLeading )
78cdf0e10cSrcweir         return false;
79cdf0e10cSrcweir     if( mnSlant      != r.mnSlant )
80cdf0e10cSrcweir         return false;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     return true;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // =======================================================================
86cdf0e10cSrcweir 
FontInfo()87cdf0e10cSrcweir FontInfo::FontInfo()
88cdf0e10cSrcweir :   mpImplMetric( new ImplFontMetric )
89cdf0e10cSrcweir {}
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // -----------------------------------------------------------------------
92cdf0e10cSrcweir 
FontInfo(const FontInfo & rInfo)93cdf0e10cSrcweir FontInfo::FontInfo( const FontInfo& rInfo )
94cdf0e10cSrcweir :  Font( rInfo )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     mpImplMetric = rInfo.mpImplMetric;
97cdf0e10cSrcweir     mpImplMetric->AddReference();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // -----------------------------------------------------------------------
101cdf0e10cSrcweir 
~FontInfo()102cdf0e10cSrcweir FontInfo::~FontInfo()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     mpImplMetric->DeReference();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir // -----------------------------------------------------------------------
108cdf0e10cSrcweir 
operator =(const FontInfo & rInfo)109cdf0e10cSrcweir FontInfo& FontInfo::operator=( const FontInfo& rInfo )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     Font::operator=( rInfo );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     if( mpImplMetric != rInfo.mpImplMetric )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         mpImplMetric->DeReference();
116cdf0e10cSrcweir         mpImplMetric = rInfo.mpImplMetric;
117cdf0e10cSrcweir         mpImplMetric->AddReference();
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     return *this;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // -----------------------------------------------------------------------
124cdf0e10cSrcweir 
operator ==(const FontInfo & rInfo) const125cdf0e10cSrcweir sal_Bool FontInfo::operator==( const FontInfo& rInfo ) const
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     if( !Font::operator==( rInfo ) )
128cdf0e10cSrcweir         return sal_False;
129cdf0e10cSrcweir     if( mpImplMetric == rInfo.mpImplMetric )
130cdf0e10cSrcweir         return sal_True;
131cdf0e10cSrcweir     if( *mpImplMetric == *rInfo.mpImplMetric  )
132cdf0e10cSrcweir         return sal_True;
133cdf0e10cSrcweir     return sal_False;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir // -----------------------------------------------------------------------
137cdf0e10cSrcweir 
GetType() const138cdf0e10cSrcweir FontType FontInfo::GetType() const
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     return (mpImplMetric->IsScalable() ? TYPE_SCALABLE : TYPE_RASTER);
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir // -----------------------------------------------------------------------
144cdf0e10cSrcweir 
IsDeviceFont() const145cdf0e10cSrcweir sal_Bool FontInfo::IsDeviceFont() const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     return mpImplMetric->IsDeviceFont();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -----------------------------------------------------------------------
151cdf0e10cSrcweir 
SupportsLatin() const152cdf0e10cSrcweir sal_Bool FontInfo::SupportsLatin() const
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     return mpImplMetric->SupportsLatin();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // -----------------------------------------------------------------------
158cdf0e10cSrcweir 
SupportsCJK() const159cdf0e10cSrcweir sal_Bool FontInfo::SupportsCJK() const
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     return mpImplMetric->SupportsCJK();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir // -----------------------------------------------------------------------
165cdf0e10cSrcweir 
SupportsCTL() const166cdf0e10cSrcweir sal_Bool FontInfo::SupportsCTL() const
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     return mpImplMetric->SupportsCTL();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir // =======================================================================
172cdf0e10cSrcweir 
FontMetric(const FontMetric & rMetric)173cdf0e10cSrcweir FontMetric::FontMetric( const FontMetric& rMetric )
174cdf0e10cSrcweir :    FontInfo( rMetric )
175cdf0e10cSrcweir {}
176cdf0e10cSrcweir 
177cdf0e10cSrcweir // -----------------------------------------------------------------------
178cdf0e10cSrcweir 
GetAscent() const179cdf0e10cSrcweir long FontMetric::GetAscent() const
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     return mpImplMetric->GetAscent();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir // -----------------------------------------------------------------------
185cdf0e10cSrcweir 
GetDescent() const186cdf0e10cSrcweir long FontMetric::GetDescent() const
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     return mpImplMetric->GetDescent();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // -----------------------------------------------------------------------
192cdf0e10cSrcweir 
GetIntLeading() const193cdf0e10cSrcweir long FontMetric::GetIntLeading() const
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     return mpImplMetric->GetIntLeading();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir // -----------------------------------------------------------------------
199cdf0e10cSrcweir 
GetExtLeading() const200cdf0e10cSrcweir long FontMetric::GetExtLeading() const
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     return mpImplMetric->GetExtLeading();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir // -----------------------------------------------------------------------
206cdf0e10cSrcweir 
GetLineHeight() const207cdf0e10cSrcweir long FontMetric::GetLineHeight() const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     return mpImplMetric->GetLineHeight();
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir // -----------------------------------------------------------------------
213cdf0e10cSrcweir 
GetSlant() const214cdf0e10cSrcweir long FontMetric::GetSlant() const
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     return mpImplMetric->GetSlant();
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir // -----------------------------------------------------------------------
220cdf0e10cSrcweir 
operator =(const FontMetric & rMetric)221cdf0e10cSrcweir FontMetric& FontMetric::operator =( const FontMetric& rMetric )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     FontInfo::operator=( rMetric );
224cdf0e10cSrcweir     return *this;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir // -----------------------------------------------------------------------
228cdf0e10cSrcweir 
operator ==(const FontMetric & rMetric) const229cdf0e10cSrcweir sal_Bool FontMetric::operator==( const FontMetric& rMetric ) const
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     return FontInfo::operator==( rMetric );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir // =======================================================================
235cdf0e10cSrcweir 
236