LibreOffice Module vcl (master) 1
font/font.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <tools/stream.hxx>
21#include <tools/vcompat.hxx>
22#include <tools/gen.hxx>
24#include <unotools/fontcfg.hxx>
25#include <unotools/fontdefs.hxx>
26#include <o3tl/hash_combine.hxx>
27
28#include <vcl/font.hxx>
29#include <vcl/svapp.hxx>
30#include <vcl/outdev.hxx>
31#include <vcl/virdev.hxx>
32
33#include <impfont.hxx>
34#include <fontattributes.hxx>
35#include <fontsubset.hxx>
36#include <sft.hxx>
37
38#include <algorithm>
39#include <string_view>
40
42
43#ifdef _WIN32
44#include <vcl/metric.hxx>
45#endif
46
47using namespace vcl;
48
49namespace
50{
51 Font::ImplType& GetGlobalDefault()
52 {
53 static Font::ImplType gDefault;
54 return gDefault;
55 }
56}
57
58Font::Font() : mpImplFont(GetGlobalDefault())
59{
60}
61
62Font::Font( const vcl::Font& rFont ) : mpImplFont( rFont.mpImplFont )
63{
64}
65
66Font::Font( vcl::Font&& rFont ) noexcept : mpImplFont( std::move(rFont.mpImplFont) )
67{
68}
69
70Font::Font( const OUString& rFamilyName, const Size& rSize )
71{
72 if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName
73 || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize)
74 {
75 mpImplFont->SetFamilyName( rFamilyName );
76 mpImplFont->SetFontSize( rSize );
77 }
78}
79
80Font::Font( const OUString& rFamilyName, const OUString& rStyleName, const Size& rSize )
81{
82 if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName
83 || const_cast<const ImplType&>(mpImplFont)->maStyleName != rStyleName
84 || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize)
85 {
86 mpImplFont->SetFamilyName( rFamilyName );
87 mpImplFont->SetStyleName( rStyleName );
88 mpImplFont->SetFontSize( rSize );
89 }
90}
91
92Font::Font( FontFamily eFamily, const Size& rSize )
93{
94 if (const_cast<const ImplType&>(mpImplFont)->meFamily != eFamily
95 || const_cast<const ImplType&>(mpImplFont)->maAverageFontSize != rSize)
96 {
97 mpImplFont->SetFamilyType( eFamily );
98 mpImplFont->SetFontSize( rSize );
99 }
100}
101
103{
104}
105
106void Font::SetColor( const Color& rColor )
107{
108 if (const_cast<const ImplType&>(mpImplFont)->maColor != rColor)
109 {
110 mpImplFont->maColor = rColor;
111 }
112}
113
114void Font::SetFillColor( const Color& rColor )
115{
116 if (const_cast<const ImplType&>(mpImplFont)->maFillColor != rColor)
117 {
118 mpImplFont->maFillColor = rColor;
119 if ( rColor.IsTransparent() )
120 mpImplFont->mbTransparent = true;
121 }
122}
123
124void Font::SetTransparent( bool bTransparent )
125{
126 if (const_cast<const ImplType&>(mpImplFont)->mbTransparent != bTransparent)
127 mpImplFont->mbTransparent = bTransparent;
128}
129
131{
132 if (const_cast<const ImplType&>(mpImplFont)->meAlign != eAlign)
133 mpImplFont->SetAlignment(eAlign);
134}
135
136void Font::SetFamilyName( const OUString& rFamilyName )
137{
138 if (const_cast<const ImplType&>(mpImplFont)->maFamilyName != rFamilyName)
139 mpImplFont->SetFamilyName( rFamilyName );
140}
141
142void Font::SetStyleName( const OUString& rStyleName )
143{
144 if (const_cast<const ImplType&>(mpImplFont)->maStyleName != rStyleName)
145 mpImplFont->maStyleName = rStyleName;
146}
147
148void Font::SetFontSize( const Size& rSize )
149{
150 if (const_cast<const ImplType&>(mpImplFont)->GetFontSize() != rSize)
151 mpImplFont->SetFontSize( rSize );
152}
153
155{
156 if (const_cast<const ImplType&>(mpImplFont)->GetFamilyTypeNoAsk() != eFamily)
157 mpImplFont->SetFamilyType( eFamily );
158}
159
160void Font::SetCharSet( rtl_TextEncoding eCharSet )
161{
162 if (const_cast<const ImplType&>(mpImplFont)->GetCharSet() != eCharSet)
163 {
164 mpImplFont->SetCharSet( eCharSet );
165
166 if ( eCharSet == RTL_TEXTENCODING_SYMBOL )
167 mpImplFont->SetSymbolFlag( true );
168 else
169 mpImplFont->SetSymbolFlag( false );
170 }
171}
172
174{
175 return mpImplFont->IsSymbolFont();
176}
177
178void Font::SetSymbolFlag( bool bSymbol )
179{
180 if (const_cast<const ImplType&>(mpImplFont)->mbSymbolFlag != bSymbol)
181 {
182 mpImplFont->SetSymbolFlag( bSymbol );
183
184 if ( IsSymbolFont() )
185 {
186 mpImplFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
187 }
188 else
189 {
190 if ( std::as_const(mpImplFont)->GetCharSet() == RTL_TEXTENCODING_SYMBOL )
191 mpImplFont->SetCharSet( RTL_TEXTENCODING_DONTKNOW );
192 }
193 }
194}
195
196void Font::SetLanguageTag( const LanguageTag& rLanguageTag )
197{
198 if (const_cast<const ImplType&>(mpImplFont)->maLanguageTag != rLanguageTag)
199 mpImplFont->maLanguageTag = rLanguageTag;
200}
201
203{
204 if (const_cast<const ImplType&>(mpImplFont)->maCJKLanguageTag != rLanguageTag)
205 mpImplFont->maCJKLanguageTag = rLanguageTag;
206}
207
209{
210 if (const_cast<const ImplType&>(mpImplFont)->maLanguageTag.getLanguageType(false) != eLanguage)
211 mpImplFont->maLanguageTag.reset( eLanguage);
212}
213
215{
216 if (const_cast<const ImplType&>(mpImplFont)->maCJKLanguageTag.getLanguageType(false) != eLanguage)
217 mpImplFont->maCJKLanguageTag.reset( eLanguage);
218}
219
221{
222 if (const_cast<const ImplType&>(mpImplFont)->GetPitchNoAsk() != ePitch)
223 mpImplFont->SetPitch( ePitch );
224}
225
226void Font::SetOrientation( Degree10 nOrientation )
227{
228 if (const_cast<const ImplType&>(mpImplFont)->mnOrientation != nOrientation)
229 mpImplFont->mnOrientation = nOrientation;
230}
231
232void Font::SetVertical( bool bVertical )
233{
234 if (const_cast<const ImplType&>(mpImplFont)->mbVertical != bVertical)
235 mpImplFont->mbVertical = bVertical;
236}
237
239{
240 if (const_cast<const ImplType&>(mpImplFont)->meKerning != eKerning)
241 mpImplFont->meKerning = eKerning;
242}
243
244bool Font::IsKerning() const
245{
246 return mpImplFont->meKerning != FontKerning::NONE;
247}
248
250{
251 if (const_cast<const ImplType&>(mpImplFont)->GetWeightNoAsk() != eWeight)
252 mpImplFont->SetWeight( eWeight );
253}
254
256{
257 if (const_cast<const ImplType&>(mpImplFont)->GetWidthTypeNoAsk() != eWidth)
258 mpImplFont->SetWidthType( eWidth );
259}
260
262{
263 if (const_cast<const ImplType&>(mpImplFont)->GetItalicNoAsk() != eItalic)
264 mpImplFont->SetItalic( eItalic );
265}
266
267void Font::SetOutline( bool bOutline )
268{
269 if (const_cast<const ImplType&>(mpImplFont)->mbOutline != bOutline)
270 mpImplFont->mbOutline = bOutline;
271}
272
273void Font::SetShadow( bool bShadow )
274{
275 if (const_cast<const ImplType&>(mpImplFont)->mbShadow != bShadow)
276 mpImplFont->mbShadow = bShadow;
277}
278
280{
281 if (const_cast<const ImplType&>(mpImplFont)->meUnderline != eUnderline)
282 mpImplFont->meUnderline = eUnderline;
283}
284
286{
287 if (const_cast<const ImplType&>(mpImplFont)->meOverline != eOverline)
288 mpImplFont->meOverline = eOverline;
289}
290
292{
293 if (const_cast<const ImplType&>(mpImplFont)->meStrikeout != eStrikeout)
294 mpImplFont->meStrikeout = eStrikeout;
295}
296
298{
299 if (const_cast<const ImplType&>(mpImplFont)->meRelief != eRelief)
300 mpImplFont->meRelief = eRelief;
301}
302
304{
305 if (const_cast<const ImplType&>(mpImplFont)->meEmphasisMark != eEmphasisMark )
306 mpImplFont->meEmphasisMark = eEmphasisMark;
307}
308
309void Font::SetWordLineMode( bool bWordLine )
310{
311 if (const_cast<const ImplType&>(mpImplFont)->mbWordLine != bWordLine)
312 mpImplFont->mbWordLine = bWordLine;
313}
314
316{
317 mpImplFont = rFont.mpImplFont;
318 return *this;
319}
320
321Font& Font::operator=( vcl::Font&& rFont ) noexcept
322{
323 mpImplFont = std::move(rFont.mpImplFont);
324 return *this;
325}
326
327bool Font::operator==( const vcl::Font& rFont ) const
328{
329 return mpImplFont == rFont.mpImplFont;
330}
331
332bool Font::EqualIgnoreColor( const vcl::Font& rFont ) const
333{
334 return mpImplFont->EqualIgnoreColor( *rFont.mpImplFont );
335}
336
337size_t Font::GetHashValue() const
338{
339 return mpImplFont->GetHashValue();
340}
341
343{
344 return mpImplFont->GetHashValueIgnoreColor();
345}
346
347void Font::Merge( const vcl::Font& rFont )
348{
349 if ( !rFont.GetFamilyName().isEmpty() )
350 {
351 SetFamilyName( rFont.GetFamilyName() );
352 SetStyleName( rFont.GetStyleName() );
356 // don't use access methods here, might lead to AskConfig(), if DONTKNOW
357 SetFamily( rFont.mpImplFont->GetFamilyTypeNoAsk() );
358 SetPitch( rFont.mpImplFont->GetPitchNoAsk() );
359 }
360
361 // don't use access methods here, might lead to AskConfig(), if DONTKNOW
362 if ( rFont.mpImplFont->GetWeightNoAsk() != WEIGHT_DONTKNOW )
363 SetWeight( rFont.GetWeight() );
364 if ( rFont.mpImplFont->GetItalicNoAsk() != ITALIC_DONTKNOW )
365 SetItalic( rFont.GetItalic() );
366 if ( rFont.mpImplFont->GetWidthTypeNoAsk() != WIDTH_DONTKNOW )
367 SetWidthType( rFont.GetWidthType() );
368
369 if ( rFont.GetFontSize().Height() )
370 SetFontSize( rFont.GetFontSize() );
371 if ( rFont.GetUnderline() != LINESTYLE_DONTKNOW )
372 {
373 SetUnderline( rFont.GetUnderline() );
375 }
376 if ( rFont.GetOverline() != LINESTYLE_DONTKNOW )
377 {
378 SetOverline( rFont.GetOverline() );
380 }
381 if ( rFont.GetStrikeout() != STRIKEOUT_DONTKNOW )
382 {
383 SetStrikeout( rFont.GetStrikeout() );
385 }
386
387 // Defaults?
389 SetVertical( rFont.IsVertical() );
392 SetOutline( rFont.IsOutline() );
393 SetShadow( rFont.IsShadow() );
394 SetRelief( rFont.GetRelief() );
395}
396
398{
399 rAttrs.SetFamilyName( mpImplFont->GetFamilyName() );
400 rAttrs.SetStyleName( mpImplFont->maStyleName );
401 rAttrs.SetFamilyType( mpImplFont->GetFamilyTypeNoAsk() );
402 rAttrs.SetPitch( mpImplFont->GetPitchNoAsk() );
403 rAttrs.SetItalic( mpImplFont->GetItalicNoAsk() );
404 rAttrs.SetWeight( mpImplFont->GetWeightNoAsk() );
406 rAttrs.SetSymbolFlag( mpImplFont->GetCharSet() == RTL_TEXTENCODING_SYMBOL );
407}
408
409// tdf#127471 for corrections on EMF/WMF we need the AvgFontWidth in Windows-specific notation
411{
412 if(0 == mpImplFont->GetCalculatedAverageFontWidth())
413 {
414 // VirtualDevice is not thread safe
415 SolarMutexGuard aGuard;
416
417 // create unscaled copy of font (this), a VirtualDevice and set it there
418 vcl::Font aUnscaledFont(*this);
420 aUnscaledFont.SetAverageFontWidth(0);
421 pTempVirtualDevice->SetFont(aUnscaledFont);
422
423#ifdef _WIN32
424 // on Windows systems use FontMetric to get/create AverageFontWidth from system
425 const FontMetric aMetric(pTempVirtualDevice->GetFontMetric());
426 const_cast<Font*>(this)->mpImplFont->SetCalculatedAverageFontWidth(aMetric.GetAverageFontWidth());
427#else
428 // On non-Windows systems we need to calculate AvgFontWidth
429 // as close as possible (discussion see documentation in task),
430 // so calculate it. For discussion of method used, see task
431 // buffer measure string creation, will always use the same
432 static constexpr OUStringLiteral aMeasureString
433 = u"\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027"
434 "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F"
435 "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037"
436 "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F"
437 "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047"
438 "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F"
439 "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057"
440 "\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F"
441 "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067"
442 "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F"
443 "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077"
444 "\u0078\u0079\u007A\u007B\u007C\u007D\u007E";
445
446 const double fAverageFontWidth(
447 pTempVirtualDevice->GetTextWidth(aMeasureString) /
448 static_cast<double>(aMeasureString.getLength()));
449 const_cast<Font*>(this)->mpImplFont->SetCalculatedAverageFontWidth(basegfx::fround(fAverageFontWidth));
450#endif
451 }
452
453 return mpImplFont->GetCalculatedAverageFontWidth();
454}
455
456SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont, tools::Long& rnNormedFontScaling )
457{
458 VersionCompatRead aCompat( rIStm );
459 sal_uInt16 nTmp16(0);
460 sal_Int16 nTmps16(0);
461 bool bTmp(false);
462 sal_uInt8 nTmp8(0);
463
464 rImplFont.SetFamilyName( rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()) );
465 rImplFont.maStyleName = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
466 TypeSerializer aSerializer(rIStm);
467 aSerializer.readSize(rImplFont.maAverageFontSize);
468
469 static const bool bFuzzing = utl::ConfigManager::IsFuzzing();
470 if (bFuzzing)
471 {
472 if (rImplFont.maAverageFontSize.Width() > 8192)
473 {
474 SAL_WARN("vcl.gdi", "suspicious average width of: " << rImplFont.maAverageFontSize.Width());
475 rImplFont.maAverageFontSize.setWidth(8192);
476 }
477 }
478
479 rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( static_cast<rtl_TextEncoding>(nTmp16) );
480 rIStm.ReadUInt16( nTmp16 ); rImplFont.SetFamilyType( static_cast<FontFamily>(nTmp16) );
481 rIStm.ReadUInt16( nTmp16 ); rImplFont.SetPitch( static_cast<FontPitch>(nTmp16) );
482 rIStm.ReadUInt16( nTmp16 ); rImplFont.SetWeight( static_cast<FontWeight>(nTmp16) );
483 rIStm.ReadUInt16( nTmp16 ); rImplFont.meUnderline = static_cast<FontLineStyle>(nTmp16);
484 rIStm.ReadUInt16( nTmp16 ); rImplFont.meStrikeout = static_cast<FontStrikeout>(nTmp16);
485 rIStm.ReadUInt16( nTmp16 ); rImplFont.SetItalic( static_cast<FontItalic>(nTmp16) );
486 rIStm.ReadUInt16( nTmp16 ); rImplFont.maLanguageTag.reset( LanguageType(nTmp16) );
487 rIStm.ReadUInt16( nTmp16 ); rImplFont.meWidthType = static_cast<FontWidth>(nTmp16);
488
489 rIStm.ReadInt16( nTmps16 ); rImplFont.mnOrientation = Degree10(nTmps16);
490
491 rIStm.ReadCharAsBool( bTmp ); rImplFont.mbWordLine = bTmp;
492 rIStm.ReadCharAsBool( bTmp ); rImplFont.mbOutline = bTmp;
493 rIStm.ReadCharAsBool( bTmp ); rImplFont.mbShadow = bTmp;
494 rIStm.ReadUChar( nTmp8 ); rImplFont.meKerning = static_cast<FontKerning>(nTmp8);
495
496 if( aCompat.GetVersion() >= 2 )
497 {
498 rIStm.ReadUChar( nTmp8 ); rImplFont.meRelief = static_cast<FontRelief>(nTmp8);
499 rIStm.ReadUInt16( nTmp16 ); rImplFont.maCJKLanguageTag.reset( LanguageType(nTmp16) );
500 rIStm.ReadCharAsBool( bTmp ); rImplFont.mbVertical = bTmp;
501 rIStm.ReadUInt16( nTmp16 ); rImplFont.meEmphasisMark = static_cast<FontEmphasisMark>(nTmp16);
502 }
503
504 if( aCompat.GetVersion() >= 3 )
505 {
506 rIStm.ReadUInt16( nTmp16 ); rImplFont.meOverline = static_cast<FontLineStyle>(nTmp16);
507 }
508
509 // tdf#127471 read NormedFontScaling
510 if( aCompat.GetVersion() >= 4 )
511 {
512 sal_Int32 nNormedFontScaling(0);
513 rIStm.ReadInt32(nNormedFontScaling);
514 rnNormedFontScaling = nNormedFontScaling;
515 }
516
517 // Relief
518 // CJKContextLanguage
519
520 return rIStm;
521}
522
523SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont, tools::Long nNormedFontScaling )
524{
525 // tdf#127471 increase to version 4
526 VersionCompatWrite aCompat( rOStm, 4 );
527
528 TypeSerializer aSerializer(rOStm);
529 rOStm.WriteUniOrByteString( rImplFont.GetFamilyName(), rOStm.GetStreamCharSet() );
530 rOStm.WriteUniOrByteString( rImplFont.GetStyleName(), rOStm.GetStreamCharSet() );
531 aSerializer.writeSize(rImplFont.maAverageFontSize);
532
533 rOStm.WriteUInt16( GetStoreCharSet( rImplFont.GetCharSet() ) );
534 rOStm.WriteUInt16( rImplFont.GetFamilyTypeNoAsk() );
535 rOStm.WriteUInt16( rImplFont.GetPitchNoAsk() );
536 rOStm.WriteUInt16( rImplFont.GetWeightNoAsk() );
537 rOStm.WriteUInt16( rImplFont.meUnderline );
538 rOStm.WriteUInt16( rImplFont.meStrikeout );
539 rOStm.WriteUInt16( rImplFont.GetItalicNoAsk() );
540 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maLanguageTag.getLanguageType( false)) );
541 rOStm.WriteUInt16( rImplFont.GetWidthTypeNoAsk() );
542
543 rOStm.WriteInt16( rImplFont.mnOrientation.get() );
544
545 rOStm.WriteBool( rImplFont.mbWordLine );
546 rOStm.WriteBool( rImplFont.mbOutline );
547 rOStm.WriteBool( rImplFont.mbShadow );
548 rOStm.WriteUChar( static_cast<sal_uInt8>(rImplFont.meKerning) );
549
550 // new in version 2
551 rOStm.WriteUChar( static_cast<unsigned char>(rImplFont.meRelief) );
552 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maCJKLanguageTag.getLanguageType( false)) );
553 rOStm.WriteBool( rImplFont.mbVertical );
554 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.meEmphasisMark) );
555
556 // new in version 3
557 rOStm.WriteUInt16( rImplFont.meOverline );
558
559 // new in version 4, NormedFontScaling
560 rOStm.WriteInt32(nNormedFontScaling);
561
562 return rOStm;
563}
564
566{
567 // tdf#127471 try to read NormedFontScaling
568 tools::Long nNormedFontScaling(0);
569 SvStream& rRetval(ReadImplFont( rIStm, *rFont.mpImplFont, nNormedFontScaling ));
570
571 if (nNormedFontScaling > 0)
572 {
573#ifdef _WIN32
574 // we run on windows and a NormedFontScaling was written
575 if(rFont.GetFontSize().getWidth() == nNormedFontScaling)
576 {
577 // the writing producer was running on a non-windows system, adapt to needed windows
578 // system-specific pre-multiply
579 const tools::Long nHeight(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
580 sal_uInt32 nScaledWidth(0);
581
582 if(nHeight > 0)
583 {
584 vcl::Font aUnscaledFont(rFont);
585 aUnscaledFont.SetAverageFontWidth(0);
586 const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
587
588 if (nHeight > 0)
589 {
590 const double fScaleFactor(static_cast<double>(nNormedFontScaling) / static_cast<double>(nHeight));
591 nScaledWidth = basegfx::fround(static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor);
592 }
593 }
594
595 rFont.SetAverageFontWidth(nScaledWidth);
596 }
597 else
598 {
599 // the writing producer was on a windows system, correct pre-multiplied value
600 // is already set, nothing to do. Ignore 2nd value. Here a check
601 // could be done if adapting the 2nd, NormedFontScaling value would be similar to
602 // the set value for plausibility reasons
603 }
604#else
605 // we do not run on windows and a NormedFontScaling was written
606 if(rFont.GetFontSize().getWidth() == nNormedFontScaling)
607 {
608 // the writing producer was not on a windows system, correct value
609 // already set, nothing to do
610 }
611 else
612 {
613 // the writing producer was on a windows system, correct FontScaling.
614 // The correct non-pre-multiplied value is the 2nd one, use it
615 rFont.SetAverageFontWidth(nNormedFontScaling);
616 }
617#endif
618 }
619
620 return rRetval;
621}
622
623SvStream& WriteFont( SvStream& rOStm, const vcl::Font& rFont )
624{
625 // tdf#127471 prepare NormedFontScaling for additional export
626 tools::Long nNormedFontScaling(rFont.GetFontSize().getWidth());
627
628 // FontScaling usage at vcl-Font is detected by checking that FontWidth != 0
629 if (nNormedFontScaling > 0)
630 {
631 const tools::Long nHeight(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
632
633 // check for negative height
634 if(0 == nHeight)
635 {
636 nNormedFontScaling = 0;
637 }
638 else
639 {
640#ifdef _WIN32
641 // for WIN32 the value is pre-multiplied with AverageFontWidth
642 // which makes it system-dependent. Turn that back to have the
643 // normed non-windows form of it for export as 2nd value
644 vcl::Font aUnscaledFont(rFont);
645 aUnscaledFont.SetAverageFontWidth(0);
646 const FontMetric aUnscaledFontMetric(
647 Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
648
649 if (aUnscaledFontMetric.GetAverageFontWidth() > 0)
650 {
651 const double fScaleFactor(
652 static_cast<double>(nNormedFontScaling)
653 / static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()));
654 nNormedFontScaling = static_cast<tools::Long>(fScaleFactor * nHeight);
655 }
656#endif
657 }
658 }
659
660 return WriteImplFont( rOStm, *rFont.mpImplFont, nNormedFontScaling );
661}
662
663namespace
664{
665 bool identifyTrueTypeFont( const void* i_pBuffer, sal_uInt32 i_nSize, Font& o_rResult )
666 {
667 bool bResult = false;
668 TrueTypeFont* pTTF = nullptr;
669 if( OpenTTFontBuffer( i_pBuffer, i_nSize, 0, &pTTF ) == SFErrCodes::Ok )
670 {
671 TTGlobalFontInfo aInfo;
672 GetTTGlobalFontInfo( pTTF, &aInfo );
673 // most importantly: the family name
674 if( aInfo.ufamily )
675 o_rResult.SetFamilyName( OUString(aInfo.ufamily) );
676 else if( aInfo.family )
677 o_rResult.SetFamilyName( OStringToOUString( aInfo.family, RTL_TEXTENCODING_ASCII_US ) );
678 // set weight
679 if( aInfo.weight )
680 {
681 if( aInfo.weight < FW_EXTRALIGHT )
682 o_rResult.SetWeight( WEIGHT_THIN );
683 else if( aInfo.weight < FW_LIGHT )
684 o_rResult.SetWeight( WEIGHT_ULTRALIGHT );
685 else if( aInfo.weight < FW_NORMAL )
686 o_rResult.SetWeight( WEIGHT_LIGHT );
687 else if( aInfo.weight < FW_MEDIUM )
688 o_rResult.SetWeight( WEIGHT_NORMAL );
689 else if( aInfo.weight < FW_SEMIBOLD )
690 o_rResult.SetWeight( WEIGHT_MEDIUM );
691 else if( aInfo.weight < FW_BOLD )
692 o_rResult.SetWeight( WEIGHT_SEMIBOLD );
693 else if( aInfo.weight < FW_EXTRABOLD )
694 o_rResult.SetWeight( WEIGHT_BOLD );
695 else if( aInfo.weight < FW_BLACK )
696 o_rResult.SetWeight( WEIGHT_ULTRABOLD );
697 else
698 o_rResult.SetWeight( WEIGHT_BLACK );
699 }
700 else
701 o_rResult.SetWeight( (aInfo.macStyle & 1) ? WEIGHT_BOLD : WEIGHT_NORMAL );
702 // set width
703 if( aInfo.width )
704 {
705 if( aInfo.width == FWIDTH_ULTRA_CONDENSED )
706 o_rResult.SetAverageFontWidth( WIDTH_ULTRA_CONDENSED );
707 else if( aInfo.width == FWIDTH_EXTRA_CONDENSED )
708 o_rResult.SetAverageFontWidth( WIDTH_EXTRA_CONDENSED );
709 else if( aInfo.width == FWIDTH_CONDENSED )
710 o_rResult.SetAverageFontWidth( WIDTH_CONDENSED );
711 else if( aInfo.width == FWIDTH_SEMI_CONDENSED )
712 o_rResult.SetAverageFontWidth( WIDTH_SEMI_CONDENSED );
713 else if( aInfo.width == FWIDTH_NORMAL )
714 o_rResult.SetAverageFontWidth( WIDTH_NORMAL );
715 else if( aInfo.width == FWIDTH_SEMI_EXPANDED )
716 o_rResult.SetAverageFontWidth( WIDTH_SEMI_EXPANDED );
717 else if( aInfo.width == FWIDTH_EXPANDED )
718 o_rResult.SetAverageFontWidth( WIDTH_EXPANDED );
719 else if( aInfo.width == FWIDTH_EXTRA_EXPANDED )
720 o_rResult.SetAverageFontWidth( WIDTH_EXTRA_EXPANDED );
721 else if( aInfo.width >= FWIDTH_ULTRA_EXPANDED )
722 o_rResult.SetAverageFontWidth( WIDTH_ULTRA_EXPANDED );
723 }
724 // set italic
725 o_rResult.SetItalic( (aInfo.italicAngle != 0) ? ITALIC_NORMAL : ITALIC_NONE );
726
727 // set pitch
728 o_rResult.SetPitch( (aInfo.pitch == 0) ? PITCH_VARIABLE : PITCH_FIXED );
729
730 // set style name
731 if( aInfo.usubfamily )
732 o_rResult.SetStyleName( OUString( aInfo.usubfamily ) );
733 else if( aInfo.subfamily )
734 o_rResult.SetStyleName( OUString::createFromAscii( aInfo.subfamily ) );
735
736 // cleanup
737 CloseTTFont( pTTF );
738 // success
739 bResult = true;
740 }
741 return bResult;
742 }
743
744 struct WeightSearchEntry
745 {
746 const char* string;
747 int string_len;
748 FontWeight weight;
749
750 bool operator<( const WeightSearchEntry& rRight ) const
751 {
752 return rtl_str_compareIgnoreAsciiCase_WithLength( string, string_len, rRight.string, rRight.string_len ) < 0;
753 }
754 }
755 const weight_table[] =
756 {
757 { "black", 5, WEIGHT_BLACK },
758 { "bold", 4, WEIGHT_BOLD },
759 { "book", 4, WEIGHT_LIGHT },
760 { "demi", 4, WEIGHT_SEMIBOLD },
761 { "heavy", 5, WEIGHT_BLACK },
762 { "light", 5, WEIGHT_LIGHT },
763 { "medium", 6, WEIGHT_MEDIUM },
764 { "regular", 7, WEIGHT_NORMAL },
765 { "super", 5, WEIGHT_ULTRABOLD },
766 { "thin", 4, WEIGHT_THIN }
767 };
768
769 bool identifyType1Font( const char* i_pBuffer, sal_uInt32 i_nSize, Font& o_rResult )
770 {
771 // might be a type1, find eexec
772 const char* pStream = i_pBuffer;
773 const char* const pExec = "eexec";
774 const char* pExecPos = std::search( pStream, pStream+i_nSize, pExec, pExec+5 );
775 if( pExecPos != pStream+i_nSize)
776 {
777 // find /FamilyName entry
778 static const char* const pFam = "/FamilyName";
779 const char* pFamPos = std::search( pStream, pExecPos, pFam, pFam+11 );
780 if( pFamPos != pExecPos )
781 {
782 // extract the string value behind /FamilyName
783 const char* pOpen = pFamPos+11;
784 while( pOpen < pExecPos && *pOpen != '(' )
785 pOpen++;
786 const char* pClose = pOpen;
787 while( pClose < pExecPos && *pClose != ')' )
788 pClose++;
789 if( pClose - pOpen > 1 )
790 {
791 o_rResult.SetFamilyName( OStringToOUString( std::string_view( pOpen+1, pClose-pOpen-1 ), RTL_TEXTENCODING_ASCII_US ) );
792 }
793 }
794
795 // parse /ItalicAngle
796 static const char* const pItalic = "/ItalicAngle";
797 const char* pItalicPos = std::search( pStream, pExecPos, pItalic, pItalic+12 );
798 if( pItalicPos != pExecPos )
799 {
800 const char* pItalicEnd = pItalicPos + 12;
801 auto nItalic = rtl_str_toInt64_WithLength(pItalicEnd, 10, pExecPos - pItalicEnd);
802 o_rResult.SetItalic( (nItalic != 0) ? ITALIC_NORMAL : ITALIC_NONE );
803 }
804
805 // parse /Weight
806 static const char* const pWeight = "/Weight";
807 const char* pWeightPos = std::search( pStream, pExecPos, pWeight, pWeight+7 );
808 if( pWeightPos != pExecPos )
809 {
810 // extract the string value behind /Weight
811 const char* pOpen = pWeightPos+7;
812 while( pOpen < pExecPos && *pOpen != '(' )
813 pOpen++;
814 const char* pClose = pOpen;
815 while( pClose < pExecPos && *pClose != ')' )
816 pClose++;
817 if( pClose - pOpen > 1 )
818 {
819 WeightSearchEntry aEnt;
820 aEnt.string = pOpen+1;
821 aEnt.string_len = (pClose-pOpen)-1;
822 aEnt.weight = WEIGHT_NORMAL;
823 WeightSearchEntry const * pFound = std::lower_bound( std::begin(weight_table), std::end(weight_table), aEnt );
824 if( pFound != std::end(weight_table) &&
825 rtl_str_compareIgnoreAsciiCase_WithLength( pFound->string, pFound->string_len, aEnt.string, aEnt.string_len) == 0 )
826 o_rResult.SetWeight( pFound->weight );
827 }
828 }
829
830 // parse isFixedPitch
831 static const char* const pFixed = "/isFixedPitch";
832 const char* pFixedPos = std::search( pStream, pExecPos, pFixed, pFixed+13 );
833 if( pFixedPos != pExecPos )
834 {
835 // skip whitespace
836 while( pFixedPos < pExecPos-4 &&
837 ( *pFixedPos == ' ' ||
838 *pFixedPos == '\t' ||
839 *pFixedPos == '\r' ||
840 *pFixedPos == '\n' ) )
841 {
842 pFixedPos++;
843 }
844 // find "true" value
845 if( rtl_str_compareIgnoreAsciiCase_WithLength( pFixedPos, 4, "true", 4 ) == 0 )
846 o_rResult.SetPitch( PITCH_FIXED );
847 else
848 o_rResult.SetPitch( PITCH_VARIABLE );
849 }
850 }
851 return false;
852 }
853}
854
855Font Font::identifyFont( const void* i_pBuffer, sal_uInt32 i_nSize )
856{
857 Font aResult;
858 if( ! identifyTrueTypeFont( i_pBuffer, i_nSize, aResult ) )
859 {
860 const char* pStream = static_cast<const char*>(i_pBuffer);
861 if( pStream && i_nSize > 100 &&
862 *pStream == '%' && pStream[1] == '!' )
863 {
864 identifyType1Font( pStream, i_nSize, aResult );
865 }
866 }
867
868 return aResult;
869}
870
871// The inlines from the font.hxx header are now instantiated for pImpl-ification
872const Color& Font::GetColor() const { return mpImplFont->maColor; }
873const Color& Font::GetFillColor() const { return mpImplFont->maFillColor; }
874bool Font::IsTransparent() const { return mpImplFont->mbTransparent; }
875
876TextAlign Font::GetAlignment() const { return mpImplFont->GetAlignment(); }
877
878const OUString& Font::GetFamilyName() const { return mpImplFont->GetFamilyName(); }
879const OUString& Font::GetStyleName() const { return mpImplFont->maStyleName; }
880
881const Size& Font::GetFontSize() const { return mpImplFont->GetFontSize(); }
882void Font::SetFontHeight( tools::Long nHeight ) { SetFontSize( Size( std::as_const(mpImplFont)->GetFontSize().Width(), nHeight ) ); }
883tools::Long Font::GetFontHeight() const { return mpImplFont->GetFontSize().Height(); }
884void Font::SetAverageFontWidth( tools::Long nWidth ) { SetFontSize( Size( nWidth, std::as_const(mpImplFont)->GetFontSize().Height() ) ); }
885tools::Long Font::GetAverageFontWidth() const { return mpImplFont->GetFontSize().Width(); }
886
887rtl_TextEncoding Font::GetCharSet() const { return mpImplFont->GetCharSet(); }
888
889const LanguageTag& Font::GetLanguageTag() const { return mpImplFont->maLanguageTag; }
890const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->maCJKLanguageTag; }
891LanguageType Font::GetLanguage() const { return mpImplFont->maLanguageTag.getLanguageType( false); }
892LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->maCJKLanguageTag.getLanguageType( false); }
893
894Degree10 Font::GetOrientation() const { return mpImplFont->mnOrientation; }
895bool Font::IsVertical() const { return mpImplFont->mbVertical; }
896FontKerning Font::GetKerning() const { return mpImplFont->meKerning; }
897
898FontPitch Font::GetPitch() { return mpImplFont->GetPitch(); }
899FontWeight Font::GetWeight() { return mpImplFont->GetWeight(); }
900FontWidth Font::GetWidthType() { return mpImplFont->GetWidthType(); }
901FontItalic Font::GetItalic() { return mpImplFont->GetItalic(); }
902FontFamily Font::GetFamilyType() { return mpImplFont->GetFamilyType(); }
903
904FontPitch Font::GetPitch() const { return mpImplFont->GetPitchNoAsk(); }
905FontWeight Font::GetWeight() const { return mpImplFont->GetWeightNoAsk(); }
906FontWidth Font::GetWidthType() const { return mpImplFont->GetWidthTypeNoAsk(); }
907FontItalic Font::GetItalic() const { return mpImplFont->GetItalicNoAsk(); }
908FontFamily Font::GetFamilyType() const { return mpImplFont->GetFamilyTypeNoAsk(); }
909
910int Font::GetQuality() const { return mpImplFont->GetQuality(); }
911void Font::SetQuality( int nQuality ) { mpImplFont->SetQuality( nQuality ); }
912void Font::IncreaseQualityBy( int nQualityAmount ) { mpImplFont->IncreaseQualityBy( nQualityAmount ); }
913void Font::DecreaseQualityBy( int nQualityAmount ) { mpImplFont->DecreaseQualityBy( nQualityAmount ); }
914
915bool Font::IsOutline() const { return mpImplFont->mbOutline; }
916bool Font::IsShadow() const { return mpImplFont->mbShadow; }
917FontRelief Font::GetRelief() const { return mpImplFont->meRelief; }
918FontLineStyle Font::GetUnderline() const { return mpImplFont->meUnderline; }
919FontLineStyle Font::GetOverline() const { return mpImplFont->meOverline; }
920FontStrikeout Font::GetStrikeout() const { return mpImplFont->meStrikeout; }
921FontEmphasisMark Font::GetEmphasisMark() const { return mpImplFont->meEmphasisMark; }
922bool Font::IsWordLineMode() const { return mpImplFont->mbWordLine; }
923bool Font::IsSameInstance( const vcl::Font& rFont ) const { return (mpImplFont == rFont.mpImplFont); }
924
925
927 meWeight( WEIGHT_DONTKNOW ),
928 meFamily( FAMILY_DONTKNOW ),
929 mePitch( PITCH_DONTKNOW ),
930 meWidthType( WIDTH_DONTKNOW ),
931 meItalic( ITALIC_NONE ),
932 meAlign( ALIGN_TOP ),
933 meUnderline( LINESTYLE_NONE ),
934 meOverline( LINESTYLE_NONE ),
935 meStrikeout( STRIKEOUT_NONE ),
936 meRelief( FontRelief::NONE ),
937 meEmphasisMark( FontEmphasisMark::NONE ),
938 meKerning( FontKerning::FontSpecific ),
939 meCharSet( RTL_TEXTENCODING_DONTKNOW ),
941 maCJKLanguageTag( LANGUAGE_DONTKNOW ),
942 mbSymbolFlag( false ),
943 mbOutline( false ),
944 mbConfigLookup( false ),
945 mbShadow( false ),
946 mbVertical( false ),
947 mbTransparent( true ),
950 mbWordLine( false ),
951 mnOrientation( 0 ),
952 mnQuality( 0 ),
953 mnCalculatedAverageFontWidth( 0 )
954{}
955
956ImplFont::ImplFont( const ImplFont& rImplFont ) :
957 maFamilyName( rImplFont.maFamilyName ),
958 maStyleName( rImplFont.maStyleName ),
959 meWeight( rImplFont.meWeight ),
960 meFamily( rImplFont.meFamily ),
961 mePitch( rImplFont.mePitch ),
962 meWidthType( rImplFont.meWidthType ),
963 meItalic( rImplFont.meItalic ),
964 meAlign( rImplFont.meAlign ),
965 meUnderline( rImplFont.meUnderline ),
966 meOverline( rImplFont.meOverline ),
967 meStrikeout( rImplFont.meStrikeout ),
968 meRelief( rImplFont.meRelief ),
969 meEmphasisMark( rImplFont.meEmphasisMark ),
970 meKerning( rImplFont.meKerning ),
971 maAverageFontSize( rImplFont.maAverageFontSize ),
972 meCharSet( rImplFont.meCharSet ),
973 maLanguageTag( rImplFont.maLanguageTag ),
974 maCJKLanguageTag( rImplFont.maCJKLanguageTag ),
975 mbSymbolFlag( rImplFont.mbSymbolFlag ),
976 mbOutline( rImplFont.mbOutline ),
977 mbConfigLookup( rImplFont.mbConfigLookup ),
978 mbShadow( rImplFont.mbShadow ),
979 mbVertical( rImplFont.mbVertical ),
980 mbTransparent( rImplFont.mbTransparent ),
981 maColor( rImplFont.maColor ),
982 maFillColor( rImplFont.maFillColor ),
983 mbWordLine( rImplFont.mbWordLine ),
984 mnOrientation( rImplFont.mnOrientation ),
985 mnQuality( rImplFont.mnQuality ),
986 mnCalculatedAverageFontWidth( rImplFont.mnCalculatedAverageFontWidth )
987{}
988
989bool ImplFont::operator==( const ImplFont& rOther ) const
990{
991 if(!EqualIgnoreColor( rOther ))
992 return false;
993
994 if( (maColor != rOther.maColor)
995 || (maFillColor != rOther.maFillColor) )
996 return false;
997
998 return true;
999}
1000
1001bool ImplFont::EqualIgnoreColor( const ImplFont& rOther ) const
1002{
1003 // equality tests split up for easier debugging
1004 if( (meWeight != rOther.meWeight)
1005 || (meItalic != rOther.meItalic)
1006 || (meFamily != rOther.meFamily)
1007 || (mePitch != rOther.mePitch) )
1008 return false;
1009
1010 if( (meCharSet != rOther.meCharSet)
1011 || (maLanguageTag != rOther.maLanguageTag)
1012 || (maCJKLanguageTag != rOther.maCJKLanguageTag)
1013 || (meAlign != rOther.meAlign) )
1014 return false;
1015
1016 if( (maAverageFontSize != rOther.maAverageFontSize)
1017 || (mnOrientation != rOther.mnOrientation)
1018 || (mbVertical != rOther.mbVertical) )
1019 return false;
1020
1021 if( (maFamilyName != rOther.maFamilyName)
1022 || (maStyleName != rOther.maStyleName) )
1023 return false;
1024
1025 if( (meUnderline != rOther.meUnderline)
1026 || (meOverline != rOther.meOverline)
1027 || (meStrikeout != rOther.meStrikeout)
1028 || (meRelief != rOther.meRelief)
1029 || (meEmphasisMark != rOther.meEmphasisMark)
1030 || (mbWordLine != rOther.mbWordLine)
1031 || (mbOutline != rOther.mbOutline)
1032 || (mbShadow != rOther.mbShadow)
1033 || (meKerning != rOther.meKerning)
1034 || (mbTransparent != rOther.mbTransparent) )
1035 return false;
1036
1037 return true;
1038}
1039
1041{
1042 size_t hash = GetHashValueIgnoreColor();
1043 o3tl::hash_combine( hash, static_cast<sal_uInt32>( maColor ));
1044 o3tl::hash_combine( hash, static_cast<sal_uInt32>( maFillColor ));
1045 return hash;
1046}
1047
1049{
1050 size_t hash = 0;
1051
1055 o3tl::hash_combine( hash, mePitch );
1056
1060 o3tl::hash_combine( hash, meAlign );
1061
1065
1068
1079
1080 return hash;
1081}
1082
1084{
1085 if( mbConfigLookup )
1086 return;
1087
1088 mbConfigLookup = true;
1089
1090 // prepare the FontSubst configuration lookup
1091 const utl::FontSubstConfiguration& rFontSubst = utl::FontSubstConfiguration::get();
1092
1093 OUString aShortName;
1094 OUString aFamilyName;
1095 ImplFontAttrs nType = ImplFontAttrs::None;
1096 FontWeight eWeight = WEIGHT_DONTKNOW;
1097 FontWidth eWidthType = WIDTH_DONTKNOW;
1098 OUString aMapName = GetEnglishSearchFontName( maFamilyName );
1099
1100 utl::FontSubstConfiguration::getMapName( aMapName,
1101 aShortName, aFamilyName, eWeight, eWidthType, nType );
1102
1103 // lookup the font name in the configuration
1104 const utl::FontNameAttr* pFontAttr = rFontSubst.getSubstInfo( aMapName );
1105
1106 // if the direct lookup failed try again with an alias name
1107 if ( !pFontAttr && (aShortName != aMapName) )
1108 pFontAttr = rFontSubst.getSubstInfo( aShortName );
1109
1110 if( pFontAttr )
1111 {
1112 // the font was found in the configuration
1113 if( meFamily == FAMILY_DONTKNOW )
1114 {
1115 if ( pFontAttr->Type & ImplFontAttrs::Serif )
1117 else if ( pFontAttr->Type & ImplFontAttrs::SansSerif )
1119 else if ( pFontAttr->Type & ImplFontAttrs::Typewriter )
1121 else if ( pFontAttr->Type & ImplFontAttrs::Italic )
1123 else if ( pFontAttr->Type & ImplFontAttrs::Decorative )
1125 }
1126
1127 if( mePitch == PITCH_DONTKNOW )
1128 {
1129 if ( pFontAttr->Type & ImplFontAttrs::Fixed )
1131 }
1132 }
1133
1134 // if some attributes are still unknown then use the FontSubst magic
1135 if( meFamily == FAMILY_DONTKNOW )
1136 {
1137 if( nType & ImplFontAttrs::Serif )
1139 else if( nType & ImplFontAttrs::SansSerif )
1141 else if( nType & ImplFontAttrs::Typewriter )
1143 else if( nType & ImplFontAttrs::Italic )
1145 else if( nType & ImplFontAttrs::Decorative )
1147 }
1148
1149 if( GetWeight() == WEIGHT_DONTKNOW )
1150 SetWeight( eWeight );
1152 meWidthType = eWidthType;
1153}
1154
1155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1164
bool IsTransparent() const
void SetPitch(const FontPitch ePitch)
void SetFamilyType(const FontFamily eFontFamily)
void SetItalic(const FontItalic eItalic)
void SetWeight(const FontWeight eWeight)
void SetStyleName(const OUString &sStyleName)
void SetWidthType(const FontWidth eWidthType)
void SetFamilyName(const OUString &sFamilyName)
void SetSymbolFlag(const bool)
FontKerning meKerning
Definition: impfont.hxx:121
Color maColor
Definition: impfont.hxx:137
rtl_TextEncoding meCharSet
Definition: impfont.hxx:123
const OUString & GetStyleName() const
Definition: impfont.hxx:42
FontWeight meWeight
Definition: impfont.hxx:110
FontFamily GetFamilyTypeNoAsk() const
Definition: impfont.hxx:78
size_t GetHashValue() const
Definition: font/font.cxx:1040
FontItalic meItalic
Definition: impfont.hxx:114
OUString maFamilyName
Definition: impfont.hxx:108
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:1048
FontRelief meRelief
Definition: impfont.hxx:119
bool mbShadow
Definition: impfont.hxx:132
bool mbConfigLookup
Definition: impfont.hxx:131
FontPitch GetPitchNoAsk() const
Definition: impfont.hxx:81
bool operator==(const ImplFont &) const
Definition: font/font.cxx:989
void SetWeight(const FontWeight eWeight)
Definition: impfont.hxx:60
rtl_TextEncoding GetCharSet() const
Definition: impfont.hxx:49
void SetFamilyType(const FontFamily eFontFamily)
Definition: impfont.hxx:56
FontLineStyle meOverline
Definition: impfont.hxx:117
FontWeight GetWeight()
Definition: impfont.hxx:44
OUString maStyleName
Definition: impfont.hxx:109
FontWidth meWidthType
Definition: impfont.hxx:113
bool mbWordLine
Definition: impfont.hxx:141
Color maFillColor
Definition: impfont.hxx:138
FontEmphasisMark meEmphasisMark
Definition: impfont.hxx:120
void SetItalic(const FontItalic eItalic)
Definition: impfont.hxx:59
FontFamily meFamily
Definition: impfont.hxx:111
Degree10 mnOrientation
Definition: impfont.hxx:144
void SetCharSet(const rtl_TextEncoding eCharSet)
Definition: impfont.hxx:63
bool EqualIgnoreColor(const ImplFont &) const
Definition: font/font.cxx:1001
bool mbOutline
Definition: impfont.hxx:130
FontStrikeout meStrikeout
Definition: impfont.hxx:118
void SetFamilyName(const OUString &sFamilyName)
Definition: impfont.hxx:54
FontWidth GetWidthTypeNoAsk() const
Definition: impfont.hxx:82
void AskConfig()
Definition: font/font.cxx:1083
TextAlign meAlign
Definition: impfont.hxx:115
const OUString & GetFamilyName() const
Definition: impfont.hxx:40
FontWeight GetWeightNoAsk() const
Definition: impfont.hxx:79
bool mbVertical
Definition: impfont.hxx:133
FontLineStyle meUnderline
Definition: impfont.hxx:116
LanguageTag maCJKLanguageTag
Definition: impfont.hxx:126
FontItalic GetItalicNoAsk() const
Definition: impfont.hxx:80
FontPitch mePitch
Definition: impfont.hxx:112
void SetPitch(const FontPitch ePitch)
Definition: impfont.hxx:58
LanguageTag maLanguageTag
Definition: impfont.hxx:125
bool mbTransparent
Definition: impfont.hxx:134
Size maAverageFontSize
Definition: impfont.hxx:122
LanguageType getLanguageType(bool bResolveSystem=true) const
LanguageTag & reset(const OUString &rBcp47LanguageTag)
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
TOOLS_DLLPUBLIC size_t GetHashValue() const
constexpr tools::Long Width() const
SvStream & ReadCharAsBool(bool &rBool)
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & WriteBool(bool b)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & ReadUChar(unsigned char &rChar)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: vclptr.hxx:58
sal_uInt16 GetVersion() const
void readSize(Size &rSize)
void writeSize(const Size &rSize)
static bool IsFuzzing()
FontKerning GetKerning() const
Definition: font/font.cxx:896
tools::Long GetFontHeight() const
Definition: font/font.cxx:883
void SetFontSize(const Size &)
Definition: font/font.cxx:148
virtual ~Font()
Definition: font/font.cxx:102
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:226
void SetVertical(bool bVertical)
Definition: font/font.cxx:232
bool IsSameInstance(const Font &) const
Definition: font/font.cxx:923
FontFamily GetFamilyType()
Definition: font/font.cxx:902
FontWidth GetWidthType()
Definition: font/font.cxx:900
void SetOutline(bool bOutline)
Definition: font/font.cxx:267
void SetWidthType(FontWidth)
Definition: font/font.cxx:255
void SetStyleName(const OUString &rStyleName)
Definition: font/font.cxx:142
const LanguageTag & GetLanguageTag() const
Definition: font/font.cxx:889
bool IsSymbolFont() const
Definition: font/font.cxx:173
void SetAverageFontWidth(tools::Long nWidth)
Definition: font/font.cxx:884
const LanguageTag & GetCJKContextLanguageTag() const
Definition: font/font.cxx:890
void SetQuality(int)
Definition: font/font.cxx:911
void SetWordLineMode(bool bWordLine)
Definition: font/font.cxx:309
void SetPitch(FontPitch ePitch)
Definition: font/font.cxx:220
size_t GetHashValue() const
Definition: font/font.cxx:337
int GetQuality() const
Definition: font/font.cxx:910
void SetTransparent(bool bTransparent)
Definition: font/font.cxx:124
void Merge(const Font &rFont)
Definition: font/font.cxx:347
void SetFillColor(const Color &)
Definition: font/font.cxx:114
bool IsKerning() const
Definition: font/font.cxx:244
void SetColor(const Color &)
Definition: font/font.cxx:106
const OUString & GetStyleName() const
Definition: font/font.cxx:879
FontStrikeout GetStrikeout() const
Definition: font/font.cxx:920
bool IsShadow() const
Definition: font/font.cxx:916
FontLineStyle GetOverline() const
Definition: font/font.cxx:919
FontRelief GetRelief() const
Definition: font/font.cxx:917
FontEmphasisMark GetEmphasisMark() const
Definition: font/font.cxx:921
FontItalic GetItalic()
Definition: font/font.cxx:901
void SetItalic(FontItalic)
Definition: font/font.cxx:261
void SetWeight(FontWeight)
Definition: font/font.cxx:249
void SetFontHeight(tools::Long nHeight)
Definition: font/font.cxx:882
bool IsTransparent() const
Definition: font/font.cxx:874
tools::Long GetOrCalculateAverageFontWidth() const
Definition: font/font.cxx:410
const OUString & GetFamilyName() const
Definition: font/font.cxx:878
void SetCJKContextLanguageTag(const LanguageTag &)
Definition: font/font.cxx:202
void SetFamily(FontFamily)
Definition: font/font.cxx:154
void SetUnderline(FontLineStyle)
Definition: font/font.cxx:279
TextAlign GetAlignment() const
Definition: font/font.cxx:876
void SetCharSet(rtl_TextEncoding)
Definition: font/font.cxx:160
const Size & GetFontSize() const
Definition: font/font.cxx:881
void SetKerning(FontKerning nKerning)
Definition: font/font.cxx:238
LanguageType GetLanguage() const
Definition: font/font.cxx:891
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:342
void IncreaseQualityBy(int)
Definition: font/font.cxx:912
const Color & GetColor() const
Definition: font/font.cxx:872
void SetAlignment(TextAlign)
Definition: font/font.cxx:130
void SetLanguageTag(const LanguageTag &)
Definition: font/font.cxx:196
bool EqualIgnoreColor(const Font &) const
Definition: font/font.cxx:332
FontPitch GetPitch()
Definition: font/font.cxx:898
void GetFontAttributes(FontAttributes &rAttrs) const
Definition: font/font.cxx:397
FontWeight GetWeight()
Definition: font/font.cxx:899
void SetOverline(FontLineStyle)
Definition: font/font.cxx:285
void SetFamilyName(const OUString &rFamilyName)
Definition: font/font.cxx:136
FontLineStyle GetUnderline() const
Definition: font/font.cxx:918
void DecreaseQualityBy(int)
Definition: font/font.cxx:913
ImplType mpImplFont
rtl_TextEncoding GetCharSet() const
Definition: font/font.cxx:887
void SetLanguage(LanguageType)
Definition: font/font.cxx:208
bool IsVertical() const
Definition: font/font.cxx:895
void SetShadow(bool bShadow)
Definition: font/font.cxx:273
LanguageType GetCJKContextLanguage() const
Definition: font/font.cxx:892
void SetRelief(FontRelief)
Definition: font/font.cxx:297
bool IsOutline() const
Definition: font/font.cxx:915
bool IsWordLineMode() const
Definition: font/font.cxx:922
static Font identifyFont(const void *pBuffer, sal_uInt32 nLen)
Definition: font/font.cxx:855
void SetCJKContextLanguage(LanguageType)
Definition: font/font.cxx:214
Font & operator=(const Font &)
Definition: font/font.cxx:315
Degree10 GetOrientation() const
Definition: font/font.cxx:894
void SetSymbolFlag(bool)
Definition: font/font.cxx:178
bool operator==(const Font &) const
Definition: font/font.cxx:327
const Color & GetFillColor() const
Definition: font/font.cxx:873
void SetEmphasisMark(FontEmphasisMark)
Definition: font/font.cxx:303
tools::Long GetAverageFontWidth() const
Definition: font/font.cxx:885
void SetStrikeout(FontStrikeout)
Definition: font/font.cxx:291
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
float u
FontRelief
Definition: fntstyle.hxx:26
FontKerning
Definition: fntstyle.hxx:29
SvStream & ReadFont(SvStream &rIStm, vcl::Font &rFont)
Definition: font/font.cxx:565
SvStream & WriteFont(SvStream &rOStm, const vcl::Font &rFont)
Definition: font/font.cxx:623
SvStream & WriteImplFont(SvStream &rOStm, const ImplFont &rImplFont, tools::Long nNormedFontScaling)
Definition: font/font.cxx:523
SvStream & ReadImplFont(SvStream &rIStm, ImplFont &rImplFont, tools::Long &rnNormedFontScaling)
Definition: font/font.cxx:456
ImplFontAttrs
UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName(std::u16string_view rName)
FontLineStyle
LINESTYLE_NONE
LINESTYLE_DONTKNOW
FontStrikeout
STRIKEOUT_NONE
STRIKEOUT_DONTKNOW
FontPitch
PITCH_FIXED
PITCH_DONTKNOW
FontItalic
ITALIC_NONE
ITALIC_DONTKNOW
FontEmphasisMark
FontWidth
WIDTH_DONTKNOW
ALIGN_TOP
FontFamily
FAMILY_DECORATIVE
FAMILY_DONTKNOW
FAMILY_SCRIPT
FAMILY_SWISS
FAMILY_MODERN
FAMILY_ROMAN
WEIGHT_ULTRABOLD
WEIGHT_THIN
WEIGHT_BOLD
WEIGHT_NORMAL
WEIGHT_LIGHT
WEIGHT_DONTKNOW
WEIGHT_SEMIBOLD
WEIGHT_MEDIUM
WEIGHT_BLACK
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1165
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1238
void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
Definition: sft.cxx:2162
#define LANGUAGE_DONTKNOW
#define SAL_WARN(area, stream)
LanguageTag maLanguageTag
NONE
B2IRange fround(const B2DRange &rRange)
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
TextAlign
FontWeight
long Long
@ FWIDTH_CONDENSED
75% of normal
Definition: sft.hxx:91
@ FWIDTH_ULTRA_CONDENSED
50% of normal
Definition: sft.hxx:89
@ FWIDTH_SEMI_EXPANDED
112.5% of normal
Definition: sft.hxx:94
@ FWIDTH_EXTRA_EXPANDED
150% of normal
Definition: sft.hxx:96
@ FWIDTH_EXPANDED
125% of normal
Definition: sft.hxx:95
@ FWIDTH_EXTRA_CONDENSED
62.5% of normal
Definition: sft.hxx:90
@ FWIDTH_ULTRA_EXPANDED
200% of normal
Definition: sft.hxx:97
@ FWIDTH_NORMAL
Medium, 100%
Definition: sft.hxx:93
@ FWIDTH_SEMI_CONDENSED
87.5% of normal
Definition: sft.hxx:92
@ FW_LIGHT
Light
Definition: sft.hxx:77
@ FW_SEMIBOLD
Semi-bold (Demi-bold)
Definition: sft.hxx:80
@ FW_NORMAL
Normal (Regular)
Definition: sft.hxx:78
@ FW_EXTRALIGHT
Extra-light (Ultra-light)
Definition: sft.hxx:76
@ FW_BLACK
Black (Heavy)
Definition: sft.hxx:83
@ FW_EXTRABOLD
Extra-bold (Ultra-bold)
Definition: sft.hxx:82
@ FW_BOLD
Bold
Definition: sft.hxx:81
@ FW_MEDIUM
Medium
Definition: sft.hxx:79
uno::Sequence< double > maFillColor
QPRO_FUNC_TYPE nType
Sun Font Tools.
rtl_TextEncoding GetStoreCharSet(rtl_TextEncoding eEncoding)
UNDERLYING_TYPE get() const
ImplFontAttrs Type
Return value of GetTTGlobalFontInfo()
Definition: sft.hxx:147
int italicAngle
in counter-clockwise degrees * 65536
Definition: sft.hxx:157
int width
value of WidthClass or 0 if can't be determined
Definition: sft.hxx:155
sal_Unicode * ufamily
family name UCS2
Definition: sft.hxx:149
int weight
value of WeightClass or 0 if can't be determined
Definition: sft.hxx:154
char * subfamily
subfamily name
Definition: sft.hxx:150
char * family
family name
Definition: sft.hxx:148
int pitch
0: proportional font, otherwise: monospaced
Definition: sft.hxx:156
sal_Unicode * usubfamily
subfamily name UCS2
Definition: sft.hxx:151
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
Definition: sft.hxx:153
unsigned char sal_uInt8
bool operator<(const wwFont &r1, const wwFont &r2)