1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <sal/config.h>
12 #include <font/EmphasisMark.hxx>
16 EmphasisMark::EmphasisMark(FontEmphasisMark eEmphasis
, tools::Long nHeight
, sal_Int32 nDPIY
)
18 static const PolyFlags aAccentPolyFlags
[24] =
20 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
21 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
22 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
23 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
24 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
25 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
,
26 PolyFlags::Normal
, PolyFlags::Normal
, PolyFlags::Control
,
27 PolyFlags::Normal
, PolyFlags::Control
, PolyFlags::Control
30 static const Point aAccentPos
[24] =
65 FontEmphasisMark nEmphasisStyle
= eEmphasis
& FontEmphasisMark::Style
;
66 tools::Long nDotSize
= 0;
67 switch ( nEmphasisStyle
)
69 case FontEmphasisMark::Dot
:
70 // Dot has 55% of the height
71 nDotSize
= (nHeight
*550)/1000;
75 maRect1
= tools::Rectangle( Point(), Size( nDotSize
, nDotSize
) );
78 tools::Long nRad
= nDotSize
/2;
79 tools::Polygon
aPoly( Point( nRad
, nRad
), nRad
, nRad
);
80 maPolyPoly
.Insert( aPoly
);
82 mnYOff
= ((nHeight
*250)/1000)/2; // Center to the another EmphasisMarks
86 case FontEmphasisMark::Circle
:
87 // Dot has 80% of the height
88 nDotSize
= (nHeight
*800)/1000;
92 maRect1
= tools::Rectangle( Point(), Size( nDotSize
, nDotSize
) );
95 tools::Long nRad
= nDotSize
/2;
96 tools::Polygon
aPoly( Point( nRad
, nRad
), nRad
, nRad
);
97 maPolyPoly
.Insert( aPoly
);
98 // Border mnWidth is 15%
99 tools::Long nBorder
= (nDotSize
*150)/1000;
104 tools::Polygon
aPoly2( Point( nRad
, nRad
),
105 nRad
-nBorder
, nRad
-nBorder
);
106 maPolyPoly
.Insert( aPoly2
);
112 case FontEmphasisMark::Disc
:
113 // Dot has 80% of the height
114 nDotSize
= (nHeight
*800)/1000;
118 maRect1
= tools::Rectangle( Point(), Size( nDotSize
, nDotSize
) );
121 tools::Long nRad
= nDotSize
/2;
122 tools::Polygon
aPoly( Point( nRad
, nRad
), nRad
, nRad
);
123 maPolyPoly
.Insert( aPoly
);
128 case FontEmphasisMark::Accent
:
129 // Dot has 80% of the height
130 nDotSize
= (nHeight
*800)/1000;
137 maRect1
= tools::Rectangle( Point(), Size( nDotSize
, nDotSize
) );
142 maRect1
= tools::Rectangle( Point(), Size( 1, 1 ) );
143 maRect2
= tools::Rectangle( Point( 1, 1 ), Size( 1, 1 ) );
148 tools::Polygon
aPoly( SAL_N_ELEMENTS(aAccentPos
), aAccentPos
,
150 double dScale
= static_cast<double>(nDotSize
)/1000.0;
151 aPoly
.Scale( dScale
, dScale
);
152 tools::Polygon aTemp
;
153 aPoly
.AdaptiveSubdivide( aTemp
);
154 tools::Rectangle aBoundRect
= aTemp
.GetBoundRect();
155 mnWidth
= aBoundRect
.GetWidth();
156 nDotSize
= aBoundRect
.GetHeight();
157 maPolyPoly
.Insert( aTemp
);
163 // calculate position
164 tools::Long nOffY
= 1+(nDPIY
/300); // one visible pixel space
165 tools::Long nSpaceY
= nHeight
-nDotSize
;
166 if ( nSpaceY
>= nOffY
*2 )
169 if ( !(eEmphasis
& FontEmphasisMark::PosBelow
) )
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */