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 );
519 }
520
521 if( aCompat.GetVersion() >= 3 )
522 {
523 rIStm.ReadUInt16( nTmp16 ); rImplFont.meOverline = static_cast<FontLineStyle>(nTmp16);
524 }
525
526 // tdf#127471 read NormedFontScaling
527 if( aCompat.GetVersion() >= 4 )
528 {
529 sal_Int32 nNormedFontScaling(0);
530 rIStm.ReadInt32(nNormedFontScaling);
531 rnNormedFontScaling = nNormedFontScaling;
532 }
533
534 if( aCompat.GetVersion() >= 5 )
535 {
536 rIStm.ReadInt16( nTmps16 );
537 rImplFont.mnSpacing = nTmps16;
538 }
539
540 // Relief
541 // CJKContextLanguage
542
543 return rIStm;
544}
545
546SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont, tools::Long nNormedFontScaling )
547{
548 // tdf#127471 increase to version 4
549 // tdf#66819 increase to version 5
550 VersionCompatWrite aCompat( rOStm, 5 );
551
552 TypeSerializer aSerializer(rOStm);
553 rOStm.WriteUniOrByteString( rImplFont.GetFamilyName(), rOStm.GetStreamCharSet() );
554 rOStm.WriteUniOrByteString( rImplFont.GetStyleName(), rOStm.GetStreamCharSet() );
555 aSerializer.writeSize(rImplFont.maAverageFontSize);
556
557 rOStm.WriteUInt16( GetStoreCharSet( rImplFont.GetCharSet() ) );
558 rOStm.WriteUInt16( rImplFont.GetFamilyTypeNoAsk() );
559 rOStm.WriteUInt16( rImplFont.GetPitchNoAsk() );
560 rOStm.WriteUInt16( rImplFont.GetWeightNoAsk() );
561 rOStm.WriteUInt16( rImplFont.meUnderline );
562 rOStm.WriteUInt16( rImplFont.meStrikeout );
563 rOStm.WriteUInt16( rImplFont.GetItalicNoAsk() );
564 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maLanguageTag.getLanguageType( false)) );
565 rOStm.WriteUInt16( rImplFont.GetWidthTypeNoAsk() );
566
567 rOStm.WriteInt16( rImplFont.mnOrientation.get() );
568
569 rOStm.WriteBool( rImplFont.mbWordLine );
570 rOStm.WriteBool( rImplFont.mbOutline );
571 rOStm.WriteBool( rImplFont.mbShadow );
572 rOStm.WriteUChar( static_cast<sal_uInt8>(rImplFont.meKerning) );
573
574 // new in version 2
575 rOStm.WriteUChar( static_cast<unsigned char>(rImplFont.meRelief) );
576 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maCJKLanguageTag.getLanguageType( false)) );
577 rOStm.WriteBool( rImplFont.mbVertical );
578 rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.meEmphasisMark) );
579
580 // new in version 3
581 rOStm.WriteUInt16( rImplFont.meOverline );
582
583 // new in version 4, NormedFontScaling
584 rOStm.WriteInt32(nNormedFontScaling);
585
586 // new in version 5
587 rOStm.WriteInt16( rImplFont.mnSpacing );
588 return rOStm;
589}
590
592{
593 // tdf#127471 try to read NormedFontScaling
594 tools::Long nNormedFontScaling(0);
595 SvStream& rRetval(ReadImplFont( rIStm, *rFont.mpImplFont, nNormedFontScaling ));
596
597 if (nNormedFontScaling > 0)
598 {
599#ifdef _WIN32
600 // we run on windows and a NormedFontScaling was written
601 if(rFont.GetFontSize().getWidth() == nNormedFontScaling)
602 {
603 // the writing producer was running on a non-windows system, adapt to needed windows
604 // system-specific pre-multiply
605 const tools::Long nHeight(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
606 sal_uInt32 nScaledWidth(0);
607
608 if(nHeight > 0)
609 {
610 vcl::Font aUnscaledFont(rFont);
611 aUnscaledFont.SetAverageFontWidth(0);
612 const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
613
614 if (nHeight > 0)
615 {
616 const double fScaleFactor(static_cast<double>(nNormedFontScaling) / static_cast<double>(nHeight));
617 nScaledWidth = basegfx::fround(static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor);
618 }
619 }
620
621 rFont.SetAverageFontWidth(nScaledWidth);
622 }
623 else
624 {
625 // the writing producer was on a windows system, correct pre-multiplied value
626 // is already set, nothing to do. Ignore 2nd value. Here a check
627 // could be done if adapting the 2nd, NormedFontScaling value would be similar to
628 // the set value for plausibility reasons
629 }
630#else
631 // we do not run on windows and a NormedFontScaling was written
632 if(rFont.GetFontSize().getWidth() == nNormedFontScaling)
633 {
634 // the writing producer was not on a windows system, correct value
635 // already set, nothing to do
636 }
637 else
638 {
639 // the writing producer was on a windows system, correct FontScaling.
640 // The correct non-pre-multiplied value is the 2nd one, use it
641 rFont.SetAverageFontWidth(nNormedFontScaling);
642 }
643#endif
644 }
645
646 return rRetval;
647}
648
649SvStream& WriteFont( SvStream& rOStm, const vcl::Font& rFont )
650{
651 // tdf#127471 prepare NormedFontScaling for additional export
652 tools::Long nNormedFontScaling(rFont.GetFontSize().getWidth());
653
654 // FontScaling usage at vcl-Font is detected by checking that FontWidth != 0
655 if (nNormedFontScaling > 0)
656 {
657 const tools::Long nHeight(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
658
659 // check for negative height
660 if(0 == nHeight)
661 {
662 nNormedFontScaling = 0;
663 }
664 else
665 {
666#ifdef _WIN32
667 // for WIN32 the value is pre-multiplied with AverageFontWidth
668 // which makes it system-dependent. Turn that back to have the
669 // normed non-windows form of it for export as 2nd value
670 vcl::Font aUnscaledFont(rFont);
671 aUnscaledFont.SetAverageFontWidth(0);
672 const FontMetric aUnscaledFontMetric(
673 Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
674
675 if (aUnscaledFontMetric.GetAverageFontWidth() > 0)
676 {
677 const double fScaleFactor(
678 static_cast<double>(nNormedFontScaling)
679 / static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()));
680 nNormedFontScaling = static_cast<tools::Long>(fScaleFactor * nHeight);
681 }
682#endif
683 }
684 }
685
686 return WriteImplFont( rOStm, *rFont.mpImplFont, nNormedFontScaling );
687}
688
689namespace
690{
691 bool identifyTrueTypeFont( const void* i_pBuffer, sal_uInt32 i_nSize, Font& o_rResult )
692 {
693 bool bResult = false;
694 TrueTypeFont* pTTF = nullptr;
695 if( OpenTTFontBuffer( i_pBuffer, i_nSize, 0, &pTTF ) == SFErrCodes::Ok )
696 {
697 TTGlobalFontInfo aInfo;
698 GetTTGlobalFontInfo( pTTF, &aInfo );
699 // most importantly: the family name
700 if( !aInfo.ufamily.isEmpty() )
701 o_rResult.SetFamilyName( aInfo.ufamily );
702 else if( !aInfo.family.isEmpty() )
703 o_rResult.SetFamilyName( OStringToOUString( aInfo.family, RTL_TEXTENCODING_ASCII_US ) );
704 // set weight
705 if( aInfo.weight )
706 {
707 if( aInfo.weight < FW_EXTRALIGHT )
708 o_rResult.SetWeight( WEIGHT_THIN );
709 else if( aInfo.weight < FW_LIGHT )
710 o_rResult.SetWeight( WEIGHT_ULTRALIGHT );
711 else if( aInfo.weight < FW_NORMAL )
712 o_rResult.SetWeight( WEIGHT_LIGHT );
713 else if( aInfo.weight < FW_MEDIUM )
714 o_rResult.SetWeight( WEIGHT_NORMAL );
715 else if( aInfo.weight < FW_SEMIBOLD )
716 o_rResult.SetWeight( WEIGHT_MEDIUM );
717 else if( aInfo.weight < FW_BOLD )
718 o_rResult.SetWeight( WEIGHT_SEMIBOLD );
719 else if( aInfo.weight < FW_EXTRABOLD )
720 o_rResult.SetWeight( WEIGHT_BOLD );
721 else if( aInfo.weight < FW_BLACK )
722 o_rResult.SetWeight( WEIGHT_ULTRABOLD );
723 else
724 o_rResult.SetWeight( WEIGHT_BLACK );
725 }
726 else
727 o_rResult.SetWeight( (aInfo.macStyle & 1) ? WEIGHT_BOLD : WEIGHT_NORMAL );
728 // set width
729 if( aInfo.width )
730 {
731 if( aInfo.width == FWIDTH_ULTRA_CONDENSED )
732 o_rResult.SetAverageFontWidth( WIDTH_ULTRA_CONDENSED );
733 else if( aInfo.width == FWIDTH_EXTRA_CONDENSED )
734 o_rResult.SetAverageFontWidth( WIDTH_EXTRA_CONDENSED );
735 else if( aInfo.width == FWIDTH_CONDENSED )
736 o_rResult.SetAverageFontWidth( WIDTH_CONDENSED );
737 else if( aInfo.width == FWIDTH_SEMI_CONDENSED )
738 o_rResult.SetAverageFontWidth( WIDTH_SEMI_CONDENSED );
739 else if( aInfo.width == FWIDTH_NORMAL )
740 o_rResult.SetAverageFontWidth( WIDTH_NORMAL );
741 else if( aInfo.width == FWIDTH_SEMI_EXPANDED )
742 o_rResult.SetAverageFontWidth( WIDTH_SEMI_EXPANDED );
743 else if( aInfo.width == FWIDTH_EXPANDED )
744 o_rResult.SetAverageFontWidth( WIDTH_EXPANDED );
745 else if( aInfo.width == FWIDTH_EXTRA_EXPANDED )
746 o_rResult.SetAverageFontWidth( WIDTH_EXTRA_EXPANDED );
747 else if( aInfo.width >= FWIDTH_ULTRA_EXPANDED )
748 o_rResult.SetAverageFontWidth( WIDTH_ULTRA_EXPANDED );
749 }
750 // set italic
751 o_rResult.SetItalic( (aInfo.italicAngle != 0) ? ITALIC_NORMAL : ITALIC_NONE );
752
753 // set pitch
754 o_rResult.SetPitch( (aInfo.pitch == 0) ? PITCH_VARIABLE : PITCH_FIXED );
755
756 // set style name
757 if( !aInfo.usubfamily.isEmpty() )
758 o_rResult.SetStyleName( aInfo.usubfamily );
759 else if( !aInfo.subfamily.isEmpty() )
760 o_rResult.SetStyleName( OUString::createFromAscii( aInfo.subfamily ) );
761
762 // cleanup
763 CloseTTFont( pTTF );
764 // success
765 bResult = true;
766 }
767 return bResult;
768 }
769
770 struct WeightSearchEntry
771 {
772 const char* string;
773 int string_len;
774 FontWeight weight;
775
776 bool operator<( const WeightSearchEntry& rRight ) const
777 {
778 return rtl_str_compareIgnoreAsciiCase_WithLength( string, string_len, rRight.string, rRight.string_len ) < 0;
779 }
780 }
781 const weight_table[] =
782 {
783 { "black", 5, WEIGHT_BLACK },
784 { "bold", 4, WEIGHT_BOLD },
785 { "book", 4, WEIGHT_LIGHT },
786 { "demi", 4, WEIGHT_SEMIBOLD },
787 { "heavy", 5, WEIGHT_BLACK },
788 { "light", 5, WEIGHT_LIGHT },
789 { "medium", 6, WEIGHT_MEDIUM },
790 { "regular", 7, WEIGHT_NORMAL },
791 { "super", 5, WEIGHT_ULTRABOLD },
792 { "thin", 4, WEIGHT_THIN }
793 };
794
795 bool identifyType1Font( const char* i_pBuffer, sal_uInt32 i_nSize, Font& o_rResult )
796 {
797 // might be a type1, find eexec
798 const char* pStream = i_pBuffer;
799 const char* const pExec = "eexec";
800 const char* pExecPos = std::search( pStream, pStream+i_nSize, pExec, pExec+5 );
801 if( pExecPos != pStream+i_nSize)
802 {
803 // find /FamilyName entry
804 static const char* const pFam = "/FamilyName";
805 const char* pFamPos = std::search( pStream, pExecPos, pFam, pFam+11 );
806 if( pFamPos != pExecPos )
807 {
808 // extract the string value behind /FamilyName
809 const char* pOpen = pFamPos+11;
810 while( pOpen < pExecPos && *pOpen != '(' )
811 pOpen++;
812 const char* pClose = pOpen;
813 while( pClose < pExecPos && *pClose != ')' )
814 pClose++;
815 if( pClose - pOpen > 1 )
816 {
817 o_rResult.SetFamilyName( OStringToOUString( std::string_view( pOpen+1, pClose-pOpen-1 ), RTL_TEXTENCODING_ASCII_US ) );
818 }
819 }
820
821 // parse /ItalicAngle
822 static const char* const pItalic = "/ItalicAngle";
823 const char* pItalicPos = std::search( pStream, pExecPos, pItalic, pItalic+12 );
824 if( pItalicPos != pExecPos )
825 {
826 const char* pItalicEnd = pItalicPos + 12;
827 auto nItalic = rtl_str_toInt64_WithLength(pItalicEnd, 10, pExecPos - pItalicEnd);
828 o_rResult.SetItalic( (nItalic != 0) ? ITALIC_NORMAL : ITALIC_NONE );
829 }
830
831 // parse /Weight
832 static const char* const pWeight = "/Weight";
833 const char* pWeightPos = std::search( pStream, pExecPos, pWeight, pWeight+7 );
834 if( pWeightPos != pExecPos )
835 {
836 // extract the string value behind /Weight
837 const char* pOpen = pWeightPos+7;
838 while( pOpen < pExecPos && *pOpen != '(' )
839 pOpen++;
840 const char* pClose = pOpen;
841 while( pClose < pExecPos && *pClose != ')' )
842 pClose++;
843 if( pClose - pOpen > 1 )
844 {
845 WeightSearchEntry aEnt;
846 aEnt.string = pOpen+1;
847 aEnt.string_len = (pClose-pOpen)-1;
848 aEnt.weight = WEIGHT_NORMAL;
849 WeightSearchEntry const * pFound = std::lower_bound( std::begin(weight_table), std::end(weight_table), aEnt );
850 if( pFound != std::end(weight_table) &&
851 rtl_str_compareIgnoreAsciiCase_WithLength( pFound->string, pFound->string_len, aEnt.string, aEnt.string_len) == 0 )
852 o_rResult.SetWeight( pFound->weight );
853 }
854 }
855
856 // parse isFixedPitch
857 static const char* const pFixed = "/isFixedPitch";
858 const char* pFixedPos = std::search( pStream, pExecPos, pFixed, pFixed+13 );
859 if( pFixedPos != pExecPos )
860 {
861 // skip whitespace
862 while( pFixedPos < pExecPos-4 &&
863 ( *pFixedPos == ' ' ||
864 *pFixedPos == '\t' ||
865 *pFixedPos == '\r' ||
866 *pFixedPos == '\n' ) )
867 {
868 pFixedPos++;
869 }
870 // find "true" value
871 if( rtl_str_compareIgnoreAsciiCase_WithLength( pFixedPos, 4, "true", 4 ) == 0 )
872 o_rResult.SetPitch( PITCH_FIXED );
873 else
874 o_rResult.SetPitch( PITCH_VARIABLE );
875 }
876 }
877 return false;
878 }
879}
880
881Font Font::identifyFont( const void* i_pBuffer, sal_uInt32 i_nSize )
882{
883 Font aResult;
884 if( ! identifyTrueTypeFont( i_pBuffer, i_nSize, aResult ) )
885 {
886 const char* pStream = static_cast<const char*>(i_pBuffer);
887 if( pStream && i_nSize > 100 &&
888 *pStream == '%' && pStream[1] == '!' )
889 {
890 identifyType1Font( pStream, i_nSize, aResult );
891 }
892 }
893
894 return aResult;
895}
896
897// The inlines from the font.hxx header are now instantiated for pImpl-ification
898const Color& Font::GetColor() const { return mpImplFont->maColor; }
899const Color& Font::GetFillColor() const { return mpImplFont->maFillColor; }
900bool Font::IsTransparent() const { return mpImplFont->mbTransparent; }
901
902TextAlign Font::GetAlignment() const { return mpImplFont->GetAlignment(); }
903
904const OUString& Font::GetFamilyName() const { return mpImplFont->GetFamilyName(); }
905const OUString& Font::GetStyleName() const { return mpImplFont->maStyleName; }
906
907const Size& Font::GetFontSize() const { return mpImplFont->GetFontSize(); }
908void Font::SetFontHeight( tools::Long nHeight ) { SetFontSize( Size( std::as_const(mpImplFont)->GetFontSize().Width(), nHeight ) ); }
909tools::Long Font::GetFontHeight() const { return mpImplFont->GetFontSize().Height(); }
910void Font::SetAverageFontWidth( tools::Long nWidth ) { SetFontSize( Size( nWidth, std::as_const(mpImplFont)->GetFontSize().Height() ) ); }
911tools::Long Font::GetAverageFontWidth() const { return mpImplFont->GetFontSize().Width(); }
912
913rtl_TextEncoding Font::GetCharSet() const { return mpImplFont->GetCharSet(); }
914
915const LanguageTag& Font::GetLanguageTag() const { return mpImplFont->maLanguageTag; }
916const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->maCJKLanguageTag; }
917LanguageType Font::GetLanguage() const { return mpImplFont->maLanguageTag.getLanguageType( false); }
918LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->maCJKLanguageTag.getLanguageType( false); }
919
920Degree10 Font::GetOrientation() const { return mpImplFont->mnOrientation; }
921bool Font::IsVertical() const { return mpImplFont->mbVertical; }
922FontKerning Font::GetKerning() const { return mpImplFont->meKerning; }
923
924FontPitch Font::GetPitch() { return mpImplFont->GetPitch(); }
925FontWeight Font::GetWeight() { return mpImplFont->GetWeight(); }
926FontWidth Font::GetWidthType() { return mpImplFont->GetWidthType(); }
927FontItalic Font::GetItalic() { return mpImplFont->GetItalic(); }
928FontFamily Font::GetFamilyType() { return mpImplFont->GetFamilyType(); }
929
930FontPitch Font::GetPitch() const { return mpImplFont->GetPitchNoAsk(); }
931FontWeight Font::GetWeight() const { return mpImplFont->GetWeightNoAsk(); }
932FontWidth Font::GetWidthType() const { return mpImplFont->GetWidthTypeNoAsk(); }
933FontItalic Font::GetItalic() const { return mpImplFont->GetItalicNoAsk(); }
934FontFamily Font::GetFamilyType() const { return mpImplFont->GetFamilyTypeNoAsk(); }
935
936int Font::GetQuality() const { return mpImplFont->GetQuality(); }
937void Font::SetQuality( int nQuality ) { mpImplFont->SetQuality( nQuality ); }
938void Font::IncreaseQualityBy( int nQualityAmount ) { mpImplFont->IncreaseQualityBy( nQualityAmount ); }
939void Font::DecreaseQualityBy( int nQualityAmount ) { mpImplFont->DecreaseQualityBy( nQualityAmount ); }
940
941bool Font::IsOutline() const { return mpImplFont->mbOutline; }
942bool Font::IsShadow() const { return mpImplFont->mbShadow; }
943FontRelief Font::GetRelief() const { return mpImplFont->meRelief; }
944FontLineStyle Font::GetUnderline() const { return mpImplFont->meUnderline; }
945FontLineStyle Font::GetOverline() const { return mpImplFont->meOverline; }
946FontStrikeout Font::GetStrikeout() const { return mpImplFont->meStrikeout; }
947FontEmphasisMark Font::GetEmphasisMark() const { return mpImplFont->meEmphasisMark; }
948bool Font::IsWordLineMode() const { return mpImplFont->mbWordLine; }
949bool Font::IsSameInstance( const vcl::Font& rFont ) const { return (mpImplFont == rFont.mpImplFont); }
950
951
953 meWeight( WEIGHT_DONTKNOW ),
954 meFamily( FAMILY_DONTKNOW ),
955 mePitch( PITCH_DONTKNOW ),
956 meWidthType( WIDTH_DONTKNOW ),
957 meItalic( ITALIC_NONE ),
958 meAlign( ALIGN_TOP ),
959 meUnderline( LINESTYLE_NONE ),
960 meOverline( LINESTYLE_NONE ),
961 meStrikeout( STRIKEOUT_NONE ),
962 meRelief( FontRelief::NONE ),
963 meEmphasisMark( FontEmphasisMark::NONE ),
964 meKerning( FontKerning::FontSpecific ),
965 mnSpacing( 0 ),
966 meCharSet( RTL_TEXTENCODING_DONTKNOW ),
968 maCJKLanguageTag( LANGUAGE_DONTKNOW ),
969 mbOutline( false ),
970 mbConfigLookup( false ),
971 mbShadow( false ),
972 mbVertical( false ),
973 mbTransparent( true ),
976 mbWordLine( false ),
977 mnOrientation( 0 ),
978 mnQuality( 0 ),
979 mnCalculatedAverageFontWidth( 0 )
980{}
981
982ImplFont::ImplFont( const ImplFont& rImplFont ) :
983 maFamilyName( rImplFont.maFamilyName ),
984 maStyleName( rImplFont.maStyleName ),
985 meWeight( rImplFont.meWeight ),
986 meFamily( rImplFont.meFamily ),
987 mePitch( rImplFont.mePitch ),
988 meWidthType( rImplFont.meWidthType ),
989 meItalic( rImplFont.meItalic ),
990 meAlign( rImplFont.meAlign ),
991 meUnderline( rImplFont.meUnderline ),
992 meOverline( rImplFont.meOverline ),
993 meStrikeout( rImplFont.meStrikeout ),
994 meRelief( rImplFont.meRelief ),
995 meEmphasisMark( rImplFont.meEmphasisMark ),
996 meKerning( rImplFont.meKerning ),
997 mnSpacing( rImplFont.mnSpacing ),
998 maAverageFontSize( rImplFont.maAverageFontSize ),
999 meCharSet( rImplFont.meCharSet ),
1000 maLanguageTag( rImplFont.maLanguageTag ),
1001 maCJKLanguageTag( rImplFont.maCJKLanguageTag ),
1002 mbOutline( rImplFont.mbOutline ),
1003 mbConfigLookup( rImplFont.mbConfigLookup ),
1004 mbShadow( rImplFont.mbShadow ),
1005 mbVertical( rImplFont.mbVertical ),
1006 mbTransparent( rImplFont.mbTransparent ),
1007 maColor( rImplFont.maColor ),
1008 maFillColor( rImplFont.maFillColor ),
1009 mbWordLine( rImplFont.mbWordLine ),
1010 mnOrientation( rImplFont.mnOrientation ),
1011 mnQuality( rImplFont.mnQuality ),
1012 mnCalculatedAverageFontWidth( rImplFont.mnCalculatedAverageFontWidth )
1013{}
1014
1015bool ImplFont::operator==( const ImplFont& rOther ) const
1016{
1017 if(!EqualIgnoreColor( rOther ))
1018 return false;
1019
1020 if( (maColor != rOther.maColor)
1021 || (maFillColor != rOther.maFillColor) )
1022 return false;
1023
1024 return true;
1025}
1026
1027bool ImplFont::EqualIgnoreColor( const ImplFont& rOther ) const
1028{
1029 // equality tests split up for easier debugging
1030 if( (meWeight != rOther.meWeight)
1031 || (meItalic != rOther.meItalic)
1032 || (meFamily != rOther.meFamily)
1033 || (mePitch != rOther.mePitch) )
1034 return false;
1035
1036 if( (meCharSet != rOther.meCharSet)
1037 || (maLanguageTag != rOther.maLanguageTag)
1038 || (maCJKLanguageTag != rOther.maCJKLanguageTag)
1039 || (meAlign != rOther.meAlign) )
1040 return false;
1041
1042 if( (maAverageFontSize != rOther.maAverageFontSize)
1043 || (mnOrientation != rOther.mnOrientation)
1044 || (mbVertical != rOther.mbVertical) )
1045 return false;
1046
1047 if( (maFamilyName != rOther.maFamilyName)
1048 || (maStyleName != rOther.maStyleName) )
1049 return false;
1050
1051 if( (meUnderline != rOther.meUnderline)
1052 || (meOverline != rOther.meOverline)
1053 || (meStrikeout != rOther.meStrikeout)
1054 || (meRelief != rOther.meRelief)
1055 || (meEmphasisMark != rOther.meEmphasisMark)
1056 || (mbWordLine != rOther.mbWordLine)
1057 || (mbOutline != rOther.mbOutline)
1058 || (mbShadow != rOther.mbShadow)
1059 || (meKerning != rOther.meKerning)
1060 || (mnSpacing != rOther.mnSpacing)
1061 || (mbTransparent != rOther.mbTransparent) )
1062 return false;
1063
1064 return true;
1065}
1066
1068{
1069 size_t hash = GetHashValueIgnoreColor();
1070 o3tl::hash_combine( hash, static_cast<sal_uInt32>( maColor ));
1071 o3tl::hash_combine( hash, static_cast<sal_uInt32>( maFillColor ));
1072 return hash;
1073}
1074
1076{
1077 size_t hash = 0;
1078
1082 o3tl::hash_combine( hash, mePitch );
1083
1087 o3tl::hash_combine( hash, meAlign );
1088
1092
1095
1107
1108 return hash;
1109}
1110
1112{
1113 if( mbConfigLookup )
1114 return;
1115
1116 mbConfigLookup = true;
1117
1118 // prepare the FontSubst configuration lookup
1119 const utl::FontSubstConfiguration& rFontSubst = utl::FontSubstConfiguration::get();
1120
1121 OUString aShortName;
1122 OUString aFamilyName;
1123 ImplFontAttrs nType = ImplFontAttrs::None;
1124 FontWeight eWeight = WEIGHT_DONTKNOW;
1125 FontWidth eWidthType = WIDTH_DONTKNOW;
1126 OUString aMapName = GetEnglishSearchFontName( maFamilyName );
1127
1128 utl::FontSubstConfiguration::getMapName( aMapName,
1129 aShortName, aFamilyName, eWeight, eWidthType, nType );
1130
1131 // lookup the font name in the configuration
1132 const utl::FontNameAttr* pFontAttr = rFontSubst.getSubstInfo( aMapName );
1133
1134 // if the direct lookup failed try again with an alias name
1135 if ( !pFontAttr && (aShortName != aMapName) )
1136 pFontAttr = rFontSubst.getSubstInfo( aShortName );
1137
1138 if( pFontAttr )
1139 {
1140 // the font was found in the configuration
1141 if( meFamily == FAMILY_DONTKNOW )
1142 {
1143 if ( pFontAttr->Type & ImplFontAttrs::Serif )
1145 else if ( pFontAttr->Type & ImplFontAttrs::SansSerif )
1147 else if ( pFontAttr->Type & ImplFontAttrs::Typewriter )
1149 else if ( pFontAttr->Type & ImplFontAttrs::Italic )
1151 else if ( pFontAttr->Type & ImplFontAttrs::Decorative )
1153 }
1154
1155 if( mePitch == PITCH_DONTKNOW )
1156 {
1157 if ( pFontAttr->Type & ImplFontAttrs::Fixed )
1159 }
1160 }
1161
1162 // if some attributes are still unknown then use the FontSubst magic
1163 if( meFamily == FAMILY_DONTKNOW )
1164 {
1165 if( nType & ImplFontAttrs::Serif )
1167 else if( nType & ImplFontAttrs::SansSerif )
1169 else if( nType & ImplFontAttrs::Typewriter )
1171 else if( nType & ImplFontAttrs::Italic )
1173 else if( nType & ImplFontAttrs::Decorative )
1175 }
1176
1177 if( GetWeight() == WEIGHT_DONTKNOW )
1178 SetWeight( eWeight );
1180 meWidthType = eWidthType;
1181}
1182
1183/* 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:1043
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:1067
FontItalic meItalic
Definition: impfont.hxx:110
OUString maFamilyName
Definition: impfont.hxx:104
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:1075
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:1015
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:1027
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:1111
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:922
tools::Long GetFontHeight() const
Definition: font/font.cxx:909
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:949
FontFamily GetFamilyType()
Definition: font/font.cxx:928
FontWidth GetWidthType()
Definition: font/font.cxx:926
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:915
void SetAverageFontWidth(tools::Long nWidth)
Definition: font/font.cxx:910
const LanguageTag & GetCJKContextLanguageTag() const
Definition: font/font.cxx:916
void SetQuality(int)
Definition: font/font.cxx:937
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:936
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:905
FontStrikeout GetStrikeout() const
Definition: font/font.cxx:946
bool IsShadow() const
Definition: font/font.cxx:942
FontLineStyle GetOverline() const
Definition: font/font.cxx:945
FontRelief GetRelief() const
Definition: font/font.cxx:943
FontEmphasisMark GetEmphasisMark() const
Definition: font/font.cxx:947
FontItalic GetItalic()
Definition: font/font.cxx:927
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:908
bool IsTransparent() const
Definition: font/font.cxx:900
tools::Long GetOrCalculateAverageFontWidth() const
Definition: font/font.cxx:421
const OUString & GetFamilyName() const
Definition: font/font.cxx:904
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:902
void SetCharSet(rtl_TextEncoding)
Definition: font/font.cxx:161
const Size & GetFontSize() const
Definition: font/font.cxx:907
void SetKerning(FontKerning nKerning)
Definition: font/font.cxx:209
LanguageType GetLanguage() const
Definition: font/font.cxx:917
size_t GetHashValueIgnoreColor() const
Definition: font/font.cxx:353
void IncreaseQualityBy(int)
Definition: font/font.cxx:938
const Color & GetColor() const
Definition: font/font.cxx:898
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:924
void GetFontAttributes(FontAttributes &rAttrs) const
Definition: font/font.cxx:408
FontWeight GetWeight()
Definition: font/font.cxx:925
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:944
void DecreaseQualityBy(int)
Definition: font/font.cxx:939
ImplType mpImplFont
rtl_TextEncoding GetCharSet() const
Definition: font/font.cxx:913
void SetLanguage(LanguageType)
Definition: font/font.cxx:179
bool IsVertical() const
Definition: font/font.cxx:921
bool IsFixKerning() const
Definition: font/font.cxx:231
void SetShadow(bool bShadow)
Definition: font/font.cxx:260
LanguageType GetCJKContextLanguage() const
Definition: font/font.cxx:918
void SetRelief(FontRelief)
Definition: font/font.cxx:284
bool IsOutline() const
Definition: font/font.cxx:941
bool IsWordLineMode() const
Definition: font/font.cxx:948
static Font identifyFont(const void *pBuffer, sal_uInt32 nLen)
Definition: font/font.cxx:881
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:920
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:899
void SetEmphasisMark(FontEmphasisMark)
Definition: font/font.cxx:290
tools::Long GetAverageFontWidth() const
Definition: font/font.cxx:911
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:591
SvStream & WriteFont(SvStream &rOStm, const vcl::Font &rFont)
Definition: font/font.cxx:649
SvStream & WriteImplFont(SvStream &rOStm, const ImplFont &rImplFont, tools::Long nNormedFontScaling)
Definition: font/font.cxx:546
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:2281
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1194
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1258
#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)