1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
24 #include <tools/ref.hxx>
25 #include <tools/gen.hxx>
27 #include <vcl/dllapi.h>
28 #include <vcl/font.hxx>
31 namespace vcl::font
{ class PhysicalFontFace
; }
33 typedef tools::SvRef
<FontCharMap
> FontCharMapRef
;
35 class VCL_DLLPUBLIC FontMetric
: public vcl::Font
38 explicit FontMetric();
39 FontMetric( const FontMetric
& ); // TODO make this explicit
40 FontMetric(vcl::font::PhysicalFontFace
const& rFace
);
41 ~FontMetric() override
;
43 sal_Int32
GetAscent() const { return mnAscent
; }
44 sal_Int32
GetDescent() const { return mnDescent
; }
45 sal_Int32
GetInternalLeading() const { return mnIntLeading
; }
46 sal_Int32
GetExternalLeading() const { return mnExtLeading
; }
47 sal_Int32
GetLineHeight() const { return mnLineHeight
; } // TODO this is ascent + descnt
48 sal_Int32
GetSlant() const { return mnSlant
; }
49 sal_Int32
GetBulletOffset() const { return mnBulletOffset
; }
50 sal_Int32
GetHangingBaseline() const { return mnHangingBaseline
; }
52 void SetAscent( sal_Int32 nAscent
) { mnAscent
= nAscent
; }
53 void SetDescent( sal_Int32 nDescent
) { mnDescent
= nDescent
; }
54 void SetExternalLeading( sal_Int32 nExtLeading
) { mnExtLeading
= nExtLeading
; }
55 void SetInternalLeading( sal_Int32 nIntLeading
) { mnIntLeading
= nIntLeading
; }
56 void SetLineHeight( sal_Int32 nHeight
) { mnLineHeight
= nHeight
; } // TODO this is ascent + descent
57 void SetSlant( sal_Int32 nSlant
) { mnSlant
= nSlant
; }
58 void SetBulletOffset( sal_Int32 nOffset
) { mnBulletOffset
= nOffset
; }
59 void SetHangingBaseline( sal_Int32 nBaseline
) { mnHangingBaseline
= nBaseline
; }
61 bool IsFullstopCentered() const { return mbFullstopCentered
; }
63 void SetFullstopCenteredFlag( bool bCentered
) { mbFullstopCentered
= bCentered
; }
65 using Font::operator=;
66 FontMetric
& operator=( const FontMetric
& rMetric
);
67 FontMetric
& operator=( FontMetric
&& rMetric
);
68 bool operator==( const FontMetric
& rMetric
) const;
69 bool operator!=( const FontMetric
& rMetric
) const
70 { return !operator==( rMetric
); }
72 bool EqualIgnoreColor( const FontMetric
& ) const;
74 // Compute value usable as hash.
75 size_t GetHashValueIgnoreColor() const;
78 bool EqualNoBase( const FontMetric
& ) const;
79 size_t GetHashValueNoBase() const;
80 sal_Int32 mnAscent
; // Ascent
81 sal_Int32 mnDescent
; // Descent
82 sal_Int32 mnIntLeading
; // Internal Leading
83 sal_Int32 mnExtLeading
; // External Leading
84 sal_Int32 mnLineHeight
; // Ascent+Descent+EmphasisMark
85 sal_Int32 mnSlant
; // Slant
86 sal_Int32 mnBulletOffset
; // Offset for non-printing character
87 sal_Int32 mnHangingBaseline
; // Offset from Romn baseline to hanging baseline.
89 bool mbFullstopCentered
;
92 template< typename charT
, typename traits
>
93 inline std::basic_ostream
<charT
, traits
> & operator <<(
94 std::basic_ostream
<charT
, traits
> & stream
, const FontMetric
& rMetric
)
97 << "name=" << "\"" << rMetric
.GetFamilyName() << "\""
98 << ",size=(" << rMetric
.GetFontSize().Width() << "," << rMetric
.GetFontSize().Height() << ")"
99 << ",ascent=" << rMetric
.GetAscent()
100 << ",descent=" << rMetric
.GetDescent()
101 << ",intLeading=" << rMetric
.GetInternalLeading()
102 << ",extLeading=" << rMetric
.GetExternalLeading()
103 << ",lineHeight=" << rMetric
.GetLineHeight()
104 << ",slant=" << rMetric
.GetSlant()
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */