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 .
20 #include <tools/stream.hxx>
21 #include <vcl/svapp.hxx>
22 #include <editeng/scripttypeitem.hxx>
27 // Latin default-fonts
28 static const DefaultFontType aLatinDefFnts
[FNT_END
] =
30 DefaultFontType::SERIF
, // FNT_VARIABLE
31 DefaultFontType::SERIF
, // FNT_FUNCTION
32 DefaultFontType::SERIF
, // FNT_NUMBER
33 DefaultFontType::SERIF
, // FNT_TEXT
34 DefaultFontType::SERIF
, // FNT_SERIF
35 DefaultFontType::SANS
, // FNT_SANS
36 DefaultFontType::FIXED
// FNT_FIXED
37 //OpenSymbol, // FNT_MATH
41 //! we use non-asian fonts for variables, functions and numbers since they
42 //! look better and even in asia only latin letters will be used for those.
43 //! At least that's what I was told...
44 static const DefaultFontType aCJKDefFnts
[FNT_END
] =
46 DefaultFontType::SERIF
, // FNT_VARIABLE
47 DefaultFontType::SERIF
, // FNT_FUNCTION
48 DefaultFontType::SERIF
, // FNT_NUMBER
49 DefaultFontType::CJK_TEXT
, // FNT_TEXT
50 DefaultFontType::CJK_TEXT
, // FNT_SERIF
51 DefaultFontType::CJK_DISPLAY
, // FNT_SANS
52 DefaultFontType::CJK_TEXT
// FNT_FIXED
53 //OpenSymbol, // FNT_MATH
57 static const DefaultFontType aCTLDefFnts
[FNT_END
] =
59 DefaultFontType::CTL_TEXT
, // FNT_VARIABLE
60 DefaultFontType::CTL_TEXT
, // FNT_FUNCTION
61 DefaultFontType::CTL_TEXT
, // FNT_NUMBER
62 DefaultFontType::CTL_TEXT
, // FNT_TEXT
63 DefaultFontType::CTL_TEXT
, // FNT_SERIF
64 DefaultFontType::CTL_TEXT
, // FNT_SANS
65 DefaultFontType::CTL_TEXT
// FNT_FIXED
66 //OpenSymbol, // FNT_MATH
70 OUString
GetDefaultFontName( LanguageType nLang
, sal_uInt16 nIdent
)
72 OSL_ENSURE( /*FNT_BEGIN <= nIdent &&*/ nIdent
<= FNT_END
,
73 "index out opd range" );
75 if (FNT_MATH
== nIdent
)
76 return OUString(FNTNAME_MATH
);
79 const DefaultFontType
*pTable
;
80 switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang
) )
82 case SvtScriptType::LATIN
: pTable
= aLatinDefFnts
; break;
83 case SvtScriptType::ASIAN
: pTable
= aCJKDefFnts
; break;
84 case SvtScriptType::COMPLEX
: pTable
= aCTLDefFnts
; break;
86 pTable
= aLatinDefFnts
;
87 SAL_WARN("starmath", "unknown script-type");
90 return OutputDevice::GetDefaultFont(
91 pTable
[ nIdent
], nLang
,
92 GetDefaultFontFlags::OnlyOne
).GetName();
99 : aBaseSize(0, SmPtsTo100th_mm(12))
101 nVersion
= SM_FMT_VERSION_NOW
;
103 eHorAlign
= AlignCenter
;
105 bIsTextmode
= bScaleNormalBrackets
= false;
107 vSize
[SIZ_TEXT
] = 100;
108 vSize
[SIZ_INDEX
] = 60;
109 vSize
[SIZ_FUNCTION
] =
110 vSize
[SIZ_OPERATOR
] = 100;
111 vSize
[SIZ_LIMITS
] = 60;
113 vDist
[DIS_HORIZONTAL
] = 10;
114 vDist
[DIS_VERTICAL
] = 5;
116 vDist
[DIS_SUPERSCRIPT
] =
117 vDist
[DIS_SUBSCRIPT
] = 20;
118 vDist
[DIS_NUMERATOR
] =
119 vDist
[DIS_DENOMINATOR
] = 0;
120 vDist
[DIS_FRACTION
] = 10;
121 vDist
[DIS_STROKEWIDTH
] = 5;
122 vDist
[DIS_UPPERLIMIT
] =
123 vDist
[DIS_LOWERLIMIT
] = 0;
124 vDist
[DIS_BRACKETSIZE
] =
125 vDist
[DIS_BRACKETSPACE
] = 5;
126 vDist
[DIS_MATRIXROW
] = 3;
127 vDist
[DIS_MATRIXCOL
] = 30;
128 vDist
[DIS_ORNAMENTSIZE
] =
129 vDist
[DIS_ORNAMENTSPACE
] = 0;
130 vDist
[DIS_OPERATORSIZE
] = 50;
131 vDist
[DIS_OPERATORSPACE
] = 20;
132 vDist
[DIS_LEFTSPACE
] =
133 vDist
[DIS_RIGHTSPACE
] = 100;
134 vDist
[DIS_TOPSPACE
] =
135 vDist
[DIS_BOTTOMSPACE
] =
136 vDist
[DIS_NORMALBRACKETSIZE
] = 0;
138 vFont
[FNT_VARIABLE
] =
139 vFont
[FNT_FUNCTION
] =
142 vFont
[FNT_SERIF
] = SmFace(OUString(FNTNAME_TIMES
), aBaseSize
);
143 vFont
[FNT_SANS
] = SmFace(OUString(FNTNAME_HELV
), aBaseSize
);
144 vFont
[FNT_FIXED
] = SmFace(OUString(FNTNAME_COUR
), aBaseSize
);
145 vFont
[FNT_MATH
] = SmFace(OUString(FNTNAME_MATH
), aBaseSize
);
147 vFont
[FNT_MATH
].SetCharSet( RTL_TEXTENCODING_UNICODE
);
149 vFont
[FNT_VARIABLE
].SetItalic(ITALIC_NORMAL
);
150 vFont
[FNT_FUNCTION
].SetItalic(ITALIC_NONE
);
151 vFont
[FNT_NUMBER
] .SetItalic(ITALIC_NONE
);
152 vFont
[FNT_TEXT
] .SetItalic(ITALIC_NONE
);
153 vFont
[FNT_SERIF
] .SetItalic(ITALIC_NONE
);
154 vFont
[FNT_SANS
] .SetItalic(ITALIC_NONE
);
155 vFont
[FNT_FIXED
] .SetItalic(ITALIC_NONE
);
157 for ( sal_uInt16 i
= FNT_BEGIN
; i
<= FNT_END
; i
++ )
159 SmFace
&rFace
= vFont
[i
];
160 rFace
.SetTransparent( true );
161 rFace
.SetAlign( ALIGN_BASELINE
);
162 rFace
.SetColor( COL_AUTO
);
163 bDefaultFont
[i
] = false;
168 void SmFormat::SetFont(sal_uInt16 nIdent
, const SmFace
&rFont
, bool bDefault
)
170 vFont
[nIdent
] = rFont
;
171 vFont
[nIdent
].SetTransparent( true );
172 vFont
[nIdent
].SetAlign( ALIGN_BASELINE
);
174 bDefaultFont
[nIdent
] = bDefault
;
177 SmFormat
& SmFormat::operator = (const SmFormat
&rFormat
)
179 SetBaseSize(rFormat
.GetBaseSize());
180 SetVersion (rFormat
.GetVersion());
181 SetHorAlign(rFormat
.GetHorAlign());
182 SetTextmode(rFormat
.IsTextmode());
183 SetGreekCharStyle(rFormat
.GetGreekCharStyle());
184 SetScaleNormalBrackets(rFormat
.IsScaleNormalBrackets());
187 for (i
= FNT_BEGIN
; i
<= FNT_END
; i
++)
189 SetFont(i
, rFormat
.GetFont(i
));
190 SetDefaultFont(i
, rFormat
.IsDefaultFont(i
));
192 for (i
= SIZ_BEGIN
; i
<= SIZ_END
; i
++)
193 SetRelSize(i
, rFormat
.GetRelSize(i
));
194 for (i
= DIS_BEGIN
; i
<= DIS_END
; i
++)
195 SetDistance(i
, rFormat
.GetDistance(i
));
201 bool SmFormat::operator == (const SmFormat
&rFormat
) const
203 bool bRes
= aBaseSize
== rFormat
.aBaseSize
&&
204 eHorAlign
== rFormat
.eHorAlign
&&
205 nGreekCharStyle
== rFormat
.nGreekCharStyle
&&
206 bIsTextmode
== rFormat
.bIsTextmode
&&
207 bScaleNormalBrackets
== rFormat
.bScaleNormalBrackets
;
210 for (i
= 0; i
<= SIZ_END
&& bRes
; ++i
)
212 if (vSize
[i
] != rFormat
.vSize
[i
])
215 for (i
= 0; i
<= DIS_END
&& bRes
; ++i
)
217 if (vDist
[i
] != rFormat
.vDist
[i
])
220 for (i
= 0; i
<= FNT_END
&& bRes
; ++i
)
222 if (vFont
[i
] != rFormat
.vFont
[i
] ||
223 bDefaultFont
[i
] != rFormat
.bDefaultFont
[i
])
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */