LibreOffice Module vcl (master)  1
metric.hxx
Go to the documentation of this file.
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 
34 
36 {
37 public:
38  explicit FontMetric();
39  FontMetric( const FontMetric& ); // TODO make this explicit
41  ~FontMetric() override;
42 
43  tools::Long GetAscent() const { return mnAscent; }
44  tools::Long GetDescent() const { return mnDescent; }
45  tools::Long GetInternalLeading() const { return mnIntLeading; }
46  tools::Long GetExternalLeading() const { return mnExtLeading; }
47  tools::Long GetLineHeight() const { return mnLineHeight; } // TODO this is ascent + descnt
48  tools::Long GetSlant() const { return mnSlant; }
49  tools::Long GetBulletOffset() const { return mnBulletOffset; }
50  tools::Long GetHangingBaseline() const { return mnHangingBaseline; }
51 
52  void SetAscent( tools::Long nAscent ) { mnAscent = nAscent; }
53  void SetDescent( tools::Long nDescent ) { mnDescent = nDescent; }
54  void SetExternalLeading( tools::Long nExtLeading ) { mnExtLeading = nExtLeading; }
55  void SetInternalLeading( tools::Long nIntLeading ) { mnIntLeading = nIntLeading; }
56  void SetLineHeight( tools::Long nHeight ) { mnLineHeight = nHeight; } // TODO this is ascent + descent
57  void SetSlant( tools::Long nSlant ) { mnSlant = nSlant; }
58  void SetBulletOffset( tools::Long nOffset ) { mnBulletOffset = nOffset; }
59  void SetHangingBaseline( tools::Long nBaseline ) { mnHangingBaseline = nBaseline; }
60 
61  bool IsFullstopCentered() const { return mbFullstopCentered; }
62 
63  void SetFullstopCenteredFlag( bool bCentered ) { mbFullstopCentered = bCentered; }
64 
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 ); }
71 
72  bool EqualIgnoreColor( const FontMetric& ) const;
73 
74  // Compute value usable as hash.
75  size_t GetHashValue() const;
76  size_t GetHashValueIgnoreColor() const;
77 
78 private:
79  bool EqualNoBase( const FontMetric& ) const;
80  size_t GetHashValueNoBase() const;
81  tools::Long mnAscent; // Ascent
82  tools::Long mnDescent; // Descent
83  tools::Long mnIntLeading; // Internal Leading
84  tools::Long mnExtLeading; // External Leading
85  tools::Long mnLineHeight; // Ascent+Descent+EmphasisMark
86  tools::Long mnSlant; // Slant
87  tools::Long mnBulletOffset; // Offset for non-printing character
88  tools::Long mnHangingBaseline; // Offset from Romn baseline to hanging baseline.
89 
91 };
92 
93 template< typename charT, typename traits >
94 inline std::basic_ostream<charT, traits> & operator <<(
95  std::basic_ostream<charT, traits> & stream, const FontMetric& rMetric )
96 {
97  stream << "{"
98  << "name=" << "\"" << rMetric.GetFamilyName() << "\""
99  << ",size=(" << rMetric.GetFontSize().Width() << "," << rMetric.GetFontSize().Height() << ")"
100  << ",ascent=" << rMetric.GetAscent()
101  << ",descent=" << rMetric.GetDescent()
102  << ",intLeading=" << rMetric.GetInternalLeading()
103  << ",extLeading=" << rMetric.GetExternalLeading()
104  << ",lineHeight=" << rMetric.GetLineHeight()
105  << ",slant=" << rMetric.GetSlant()
106  << "}";
107  return stream;
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long mnAscent
Definition: metric.hxx:81
size_t GetHashValue() const
Definition: font/font.cxx:337
Font & operator=(const Font &)
Definition: font/font.cxx:315
const OUString & GetFamilyName() const
Definition: font/font.cxx:878
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const FontMetric &rMetric)
Definition: metric.hxx:94
tools::Long GetSlant() const
Definition: metric.hxx:48
tools::Long mnLineHeight
Definition: metric.hxx:85
tools::Long mnExtLeading
Definition: metric.hxx:84
tools::Long mnBulletOffset
Definition: metric.hxx:87
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
void SetInternalLeading(tools::Long nIntLeading)
Definition: metric.hxx:55
bool mbFullstopCentered
Definition: metric.hxx:90
void SetHangingBaseline(tools::Long nBaseline)
Definition: metric.hxx:59
tools::Long GetExternalLeading() const
Definition: metric.hxx:46
constexpr tools::Long Width() const
tools::Long mnSlant
Definition: metric.hxx:86
tools::SvRef< FontCharMap > FontCharMapRef
Definition: metric.hxx:33
tools::Long GetAscent() const
Definition: metric.hxx:43
void SetExternalLeading(tools::Long nExtLeading)
Definition: metric.hxx:54
tools::Long mnIntLeading
Definition: metric.hxx:83
bool IsFullstopCentered() const
Definition: metric.hxx:61
void SetBulletOffset(tools::Long nOffset)
Definition: metric.hxx:58
bool EqualIgnoreColor(const Font &) const
Definition: font/font.cxx:332
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
const Size & GetFontSize() const
Definition: font/font.cxx:881
abstract base class for physical font faces
void SetLineHeight(tools::Long nHeight)
Definition: metric.hxx:56
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:342
constexpr tools::Long Height() const
bool operator==(const Font &) const
Definition: font/font.cxx:327
void SetDescent(tools::Long nDescent)
Definition: metric.hxx:53
tools::Long GetDescent() const
Definition: metric.hxx:44
tools::Long GetInternalLeading() const
Definition: metric.hxx:45
tools::Long mnHangingBaseline
Definition: metric.hxx:88
tools::Long GetHangingBaseline() const
Definition: metric.hxx:50
void SetAscent(tools::Long nAscent)
Definition: metric.hxx:52
tools::Long GetBulletOffset() const
Definition: metric.hxx:49
bool operator!=(const FontMetric &rMetric) const
Definition: metric.hxx:69
void SetSlant(tools::Long nSlant)
Definition: metric.hxx:57
void SetFullstopCenteredFlag(bool bCentered)
Definition: metric.hxx:63
tools::Long mnDescent
Definition: metric.hxx:82
tools::Long GetLineHeight() const
Definition: metric.hxx:47