Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/metric.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#pragma once
21
22
#include <sal/config.h>
23
24
#include <tools/ref.hxx>
25
#include <tools/gen.hxx>
26
27
#include <vcl/dllapi.h>
28
#include <vcl/font.hxx>
29
30
class FontCharMap;
31
namespace vcl::font { class PhysicalFontFace; }
32
33
typedef tools::SvRef<FontCharMap> FontCharMapRef;
34
35
class VCL_DLLPUBLIC FontMetric : public vcl::Font
36
{
37
public:
38
    explicit            FontMetric();
39
                        FontMetric( const FontMetric& );  // TODO make this explicit
40
    SAL_DLLPRIVATE      FontMetric(vcl::font::PhysicalFontFace const& rFace);
41
                        ~FontMetric() override;
42
43
18.6M
    sal_Int32           GetAscent() const                           { return mnAscent; }
44
9.07M
    sal_Int32           GetDescent() const                          { return mnDescent; }
45
20.9M
    sal_Int32           GetInternalLeading() const                  { return mnIntLeading; }
46
1.04M
    sal_Int32           GetExternalLeading() const                  { return mnExtLeading; }
47
5.47k
    sal_Int32           GetLineHeight() const                       { return mnLineHeight; } // TODO this is ascent + descnt
48
0
    sal_Int32           GetSlant() const                            { return mnSlant; }
49
0
    sal_Int32           GetBulletOffset() const                     { return mnBulletOffset; }
50
67.2k
    sal_Int32           GetHangingBaseline() const                  { return mnHangingBaseline; }
51
52
0
    double GetUnitEm() const { return mdEmSize; }
53
0
    double GetHorCJKAdvance() const { return mdHorCJKAdvanceSize; }
54
0
    double GetVertCJKAdvance() const { return mdVertCJKAdvanceSize; }
55
56
30.1M
    void                SetAscent( sal_Int32 nAscent )                   { mnAscent = nAscent; }
57
30.1M
    void                SetDescent( sal_Int32 nDescent )                 { mnDescent = nDescent; }
58
30.1M
    void                SetExternalLeading( sal_Int32 nExtLeading )      { mnExtLeading = nExtLeading; }
59
30.1M
    void                SetInternalLeading( sal_Int32 nIntLeading )      { mnIntLeading = nIntLeading; }
60
30.1M
    void                SetLineHeight( sal_Int32 nHeight )               { mnLineHeight = nHeight; } // TODO this is ascent + descent
61
30.1M
    void                SetSlant( sal_Int32 nSlant )                     { mnSlant = nSlant; }
62
30.1M
    void                SetBulletOffset( sal_Int32 nOffset )             { mnBulletOffset = nOffset; }
63
30.1M
    void                SetHangingBaseline( sal_Int32 nBaseline )        { mnHangingBaseline = nBaseline; }
64
65
30.1M
    void SetUnitEm(double dValue) { mdEmSize = dValue; }
66
30.1M
    void SetHorCJKAdvance(double dValue) { mdHorCJKAdvanceSize = dValue; }
67
30.1M
    void SetVertCJKAdvance(double dValue) { mdVertCJKAdvanceSize = dValue; }
68
69
0
    bool                IsFullstopCentered() const                  { return mbFullstopCentered; }
70
71
30.1M
    void                SetFullstopCenteredFlag( bool bCentered )   { mbFullstopCentered = bCentered; }
72
73
    using Font::operator=;
74
    FontMetric&         operator=( const FontMetric& rMetric );
75
    FontMetric&         operator=( FontMetric&& rMetric );
76
    bool                operator==( const FontMetric& rMetric ) const;
77
    bool                operator!=( const FontMetric& rMetric ) const
78
0
                            { return !operator==( rMetric ); }
79
80
    SAL_DLLPRIVATE bool EqualIgnoreColor( const FontMetric& ) const;
81
82
    // Compute value usable as hash.
83
    size_t              GetHashValueIgnoreColor() const;
84
85
private:
86
    SAL_DLLPRIVATE bool EqualNoBase( const FontMetric& ) const;
87
    SAL_DLLPRIVATE size_t GetHashValueNoBase() const;
88
    sal_Int32           mnAscent;                      // Ascent
89
    sal_Int32           mnDescent;                     // Descent
90
    sal_Int32           mnIntLeading;                  // Internal Leading
91
    sal_Int32           mnExtLeading;                  // External Leading
92
    sal_Int32           mnLineHeight;                  // Ascent+Descent+EmphasisMark
93
    sal_Int32           mnSlant;                       // Slant
94
    sal_Int32           mnBulletOffset;                // Offset for non-printing character
95
    sal_Int32           mnHangingBaseline;             // Offset from Romn baseline to hanging baseline.
96
    double mdEmSize; // Size of an 'em' unit
97
    double mdHorCJKAdvanceSize; // Size of an 'ic' unit in horizontal layout
98
    double mdVertCJKAdvanceSize; // Size of an 'ic' unit in vertical layout
99
100
    bool                mbFullstopCentered;
101
};
102
103
template< typename charT, typename traits >
104
inline std::basic_ostream<charT, traits> & operator <<(
105
    std::basic_ostream<charT, traits> & stream, const FontMetric& rMetric )
106
0
{
107
0
    stream << "{"
108
0
           << "name=" << "\"" << rMetric.GetFamilyName() << "\""
109
0
           << ",size=(" << rMetric.GetFontSize().Width() << "," << rMetric.GetFontSize().Height() << ")"
110
0
           << ",ascent=" << rMetric.GetAscent()
111
0
           << ",descent=" << rMetric.GetDescent()
112
0
           << ",intLeading=" << rMetric.GetInternalLeading()
113
0
           << ",extLeading=" << rMetric.GetExternalLeading()
114
0
           << ",lineHeight=" << rMetric.GetLineHeight()
115
0
           << ",slant=" << rMetric.GetSlant()
116
0
           << "}";
117
0
    return stream;
118
0
}
119
120
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */