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