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 .
19 #ifndef INCLUDED_EDITENG_SVXFONT_HXX
20 #define INCLUDED_EDITENG_SVXFONT_HXX
22 #include <editeng/svxenum.hxx>
23 #include <o3tl/span.hxx>
24 #include <tools/long.hxx>
25 #include <vcl/font.hxx>
26 #include <editeng/editengdllapi.h>
27 #include <tools/poly.hxx>
29 // Percentage of height of lower case small capital letters compared to upper case letters
30 // See i#1526# for full explanation
31 #define SMALL_CAPS_PERCENTAGE 80
38 namespace tools
{ class Rectangle
; }
40 class EDITENG_DLLPUBLIC SvxFont
: public vcl::Font
42 SvxCaseMap eCaseMap
; // Text Markup
43 short nEsc
; // Degree of Superscript/Subscript
44 sal_uInt8 nPropr
; // Degree of reduction of the font height
48 SvxFont( const vcl::Font
&rFont
);
49 SvxFont( const SvxFont
&rFont
);
51 // Methods for Superscript/Subscript
52 short GetEscapement() const { return nEsc
; }
53 void SetEscapement( const short nNewEsc
) { nEsc
= nNewEsc
; }
54 // set specific values instead of automatic, and ensure valid value. Depends on nPropr being set already.
55 void SetNonAutoEscapement(short nNewEsc
, const OutputDevice
* pOutDev
= nullptr);
57 sal_uInt8
GetPropr() const { return nPropr
; }
58 void SetPropr( const sal_uInt8 nNewPropr
) { nPropr
= nNewPropr
; }
59 void SetProprRel( const sal_uInt8 nNewPropr
)
60 { SetPropr( static_cast<sal_uInt8
>( static_cast<tools::Long
>(nNewPropr
) * static_cast<tools::Long
>(nPropr
) / 100 ) ); }
62 SvxCaseMap
GetCaseMap() const { return eCaseMap
; }
63 void SetCaseMap( const SvxCaseMap eNew
) { eCaseMap
= eNew
; }
66 bool IsCaseMap() const { return SvxCaseMap::NotMapped
!= eCaseMap
; }
67 bool IsCapital() const { return SvxCaseMap::SmallCaps
== eCaseMap
; }
68 bool IsEsc() const { return 0 != nEsc
; }
70 // Consider Upper case, Lower case letters etc.
71 OUString
CalcCaseMap(const OUString
&rTxt
) const;
73 // Handle upper case letters
74 void DoOnCapitals(SvxDoCapitals
&rDo
) const;
76 void SetPhysFont(OutputDevice
& rOut
) const;
77 vcl::Font
ChgPhysFont(OutputDevice
& rOut
) const;
79 Size
GetCapitalSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
80 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
81 void DrawCapital( OutputDevice
*pOut
, const Point
&rPos
, const OUString
&rTxt
,
82 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
84 Size
GetPhysTxtSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
85 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
87 Size
GetPhysTxtSize( const OutputDevice
*pOut
);
89 Size
GetTextSize(const OutputDevice
& rOut
, const OUString
&rTxt
,
90 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
) const;
92 void QuickDrawText( OutputDevice
*pOut
, const Point
&rPos
, const OUString
&rTxt
,
93 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
,
94 o3tl::span
<const sal_Int32
> pDXArray
= {},
95 o3tl::span
<const sal_Bool
> pKashidaArray
= {} ) const;
97 Size
QuickGetTextSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
98 const sal_Int32 nIdx
, const sal_Int32 nLen
,
99 KernArray
* pDXArray
= nullptr ) const;
101 void DrawPrev( OutputDevice
* pOut
, Printer
* pPrinter
,
102 const Point
&rPos
, const OUString
&rTxt
,
103 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
) const;
105 static tools::Polygon
DrawArrow( OutputDevice
&rOut
, const tools::Rectangle
& rRect
,
106 const Size
& rSize
, const Color
& rCol
, bool bLeftOrTop
,
109 SvxFont
& operator=( const SvxFont
& rFont
);
110 SvxFont
& operator=( const Font
& rFont
);
113 #endif // INCLUDED_EDITENG_SVXFONT_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */