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 _SVX_SVXFONT_HXX
20 #define _SVX_SVXFONT_HXX
22 #include <limits.h> // USHRT_MAX
23 #include <editeng/svxenum.hxx>
24 #include <i18nlangtag/lang.h>
25 #include <vcl/font.hxx>
26 #include "editeng/editengdllapi.h"
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
39 class EDITENG_DLLPUBLIC SvxFont
: public Font
41 LanguageType eLang
; // Language
42 SvxCaseMap eCaseMap
; // Text Markup
43 short nEsc
; // Degree of Superscript/Subscript
44 sal_uInt8 nPropr
; // Degree of reduction of the font height
45 short nKern
; // Kerning in Pt
49 SvxFont( const Font
&rFont
);
50 SvxFont( const SvxFont
&rFont
);
52 // Methods for Superscript/Subscript
53 inline short GetEscapement() const { return nEsc
; }
54 inline void SetEscapement( const short nNewEsc
) { nEsc
= nNewEsc
; }
56 inline sal_uInt8
GetPropr() const { return nPropr
; }
57 inline void SetPropr( const sal_uInt8 nNewPropr
) { nPropr
= nNewPropr
; }
58 inline void SetProprRel( const sal_uInt8 nNewPropr
)
59 { SetPropr( (sal_uInt8
)( (long)nNewPropr
* (long)nPropr
/ 100L ) ); }
62 inline short GetFixKerning() const { return nKern
; }
63 inline void SetFixKerning( const short nNewKern
) { nKern
= nNewKern
; }
65 inline SvxCaseMap
GetCaseMap() const { return eCaseMap
; }
66 inline void SetCaseMap( const SvxCaseMap eNew
) { eCaseMap
= eNew
; }
68 inline LanguageType
GetLanguage() const { return eLang
; }
69 inline void SetLanguage( const LanguageType eNewLan
)
70 { eLang
= eNewLan
; Font::SetLanguage(eNewLan
); }
73 inline sal_Bool
IsCaseMap() const { return SVX_CASEMAP_NOT_MAPPED
!= eCaseMap
; }
74 inline sal_Bool
IsCapital() const { return SVX_CASEMAP_KAPITAELCHEN
== eCaseMap
; }
75 inline sal_Bool
IsKern() const { return 0 != nKern
; }
76 inline sal_Bool
IsEsc() const { return 0 != nEsc
; }
78 // Consider Upper case, Lower case letters etc.
79 OUString
CalcCaseMap(const OUString
&rTxt
) const;
81 // Handle upper case letters
82 void DoOnCapitals( SvxDoCapitals
&rDo
,
83 const sal_uInt16 nPartLen
= USHRT_MAX
) const;
85 void SetPhysFont( OutputDevice
*pOut
) const;
86 Font
ChgPhysFont( OutputDevice
*pOut
) const;
88 Size
GetCapitalSize( const OutputDevice
*pOut
, const String
&rTxt
,
89 const sal_uInt16 nIdx
, const sal_uInt16 nLen
) const;
90 void DrawCapital( OutputDevice
*pOut
, const Point
&rPos
, const String
&rTxt
,
91 const sal_uInt16 nIdx
, const sal_uInt16 nLen
) const;
93 Size
GetPhysTxtSize( const OutputDevice
*pOut
, const String
&rTxt
,
94 const sal_uInt16 nIdx
, const sal_uInt16 nLen
) const;
96 Size
GetPhysTxtSize( const OutputDevice
*pOut
, const String
&rTxt
);
98 Size
GetTxtSize( const OutputDevice
*pOut
, const String
&rTxt
,
99 const sal_uInt16 nIdx
= 0, const sal_uInt16 nLen
= STRING_LEN
) const;
101 void QuickDrawText( OutputDevice
*pOut
, const Point
&rPos
, const String
&rTxt
,
102 const sal_uInt16 nIdx
= 0, const sal_uInt16 nLen
= STRING_LEN
, const sal_Int32
* pDXArray
= NULL
) const;
104 Size
QuickGetTextSize( const OutputDevice
*pOut
, const String
&rTxt
,
105 const sal_uInt16 nIdx
, const sal_uInt16 nLen
, sal_Int32
* pDXArray
= NULL
) const;
107 void DrawPrev( OutputDevice
* pOut
, Printer
* pPrinter
,
108 const Point
&rPos
, const String
&rTxt
,
109 const sal_uInt16 nIdx
= 0, const sal_uInt16 nLen
= STRING_LEN
) const;
111 static void DrawArrow( OutputDevice
&rOut
, const Rectangle
& rRect
,
112 const Size
& rSize
, const Color
& rCol
, sal_Bool bLeft
);
113 SvxFont
& operator=( const SvxFont
& rFont
);
114 SvxFont
& operator=( const Font
& rFont
);
117 #endif // #ifndef _SVX_SVXFONT_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */