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