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