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 <tools/long.hxx>
24 #include <vcl/font.hxx>
25 #include <editeng/editengdllapi.h>
26 #include <tools/poly.hxx>
28 // Percentage of height of lower case small capital letters compared to upper case letters
29 // See i#1526# for full explanation
30 #define SMALL_CAPS_PERCENTAGE 80
36 namespace tools
{ class Rectangle
; }
39 class EDITENG_DLLPUBLIC SvxFont
: public vcl::Font
41 SvxCaseMap eCaseMap
; // Text Markup
42 short nEsc
; // Degree of Superscript/Subscript
43 sal_uInt8 nPropr
; // Degree of reduction of the font height
44 short nKern
; // Kerning in Pt
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 ) ); }
63 short GetFixKerning() const { return nKern
; }
64 void SetFixKerning( const short nNewKern
) { nKern
= nNewKern
; }
66 SvxCaseMap
GetCaseMap() const { return eCaseMap
; }
67 void SetCaseMap( const SvxCaseMap eNew
) { eCaseMap
= eNew
; }
70 bool IsCaseMap() const { return SvxCaseMap::NotMapped
!= eCaseMap
; }
71 bool IsCapital() const { return SvxCaseMap::SmallCaps
== eCaseMap
; }
72 bool IsKern() const { return 0 != nKern
; }
73 bool IsEsc() const { return 0 != nEsc
; }
75 // Consider Upper case, Lower case letters etc.
76 OUString
CalcCaseMap(const OUString
&rTxt
) const;
78 // Handle upper case letters
79 void DoOnCapitals(SvxDoCapitals
&rDo
) const;
81 void SetPhysFont( OutputDevice
*pOut
) const;
82 vcl::Font
ChgPhysFont( OutputDevice
*pOut
) const;
84 Size
GetCapitalSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
85 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
86 void DrawCapital( OutputDevice
*pOut
, const Point
&rPos
, const OUString
&rTxt
,
87 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
89 Size
GetPhysTxtSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
90 const sal_Int32 nIdx
, const sal_Int32 nLen
) const;
92 Size
GetPhysTxtSize( const OutputDevice
*pOut
);
94 Size
GetTextSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
95 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
) const;
97 void QuickDrawText( OutputDevice
*pOut
, const Point
&rPos
, const OUString
&rTxt
,
98 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
, const tools::Long
* pDXArray
= nullptr ) const;
100 Size
QuickGetTextSize( const OutputDevice
*pOut
, const OUString
&rTxt
,
101 const sal_Int32 nIdx
, const sal_Int32 nLen
, tools::Long
* pDXArray
= nullptr ) const;
103 void DrawPrev( OutputDevice
* pOut
, Printer
* pPrinter
,
104 const Point
&rPos
, const OUString
&rTxt
,
105 const sal_Int32 nIdx
= 0, const sal_Int32 nLen
= SAL_MAX_INT32
) const;
107 static tools::Polygon
DrawArrow( OutputDevice
&rOut
, const tools::Rectangle
& rRect
,
108 const Size
& rSize
, const Color
& rCol
, bool bLeftOrTop
,
111 SvxFont
& operator=( const SvxFont
& rFont
);
112 SvxFont
& operator=( const Font
& rFont
);
115 #endif // INCLUDED_EDITENG_SVXFONT_HXX
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */