58Font::Font() : mpImplFont(GetGlobalDefault())
80Font::Font(
const OUString& rFamilyName,
const OUString& rStyleName,
const Size& rSize )
166 if ( eCharSet == RTL_TEXTENCODING_SYMBOL )
186 mpImplFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
191 mpImplFont->SetCharSet( RTL_TEXTENCODING_DONTKNOW );
216 if (
const_cast<const ImplType&
>(
mpImplFont)->maCJKLanguageTag.getLanguageType(
false) != eLanguage)
217 mpImplFont->maCJKLanguageTag.reset( eLanguage);
323 mpImplFont = std::move(rFont.mpImplFont);
412 if(0 ==
mpImplFont->GetCalculatedAverageFontWidth())
421 pTempVirtualDevice->SetFont(aUnscaledFont);
425 const FontMetric aMetric(pTempVirtualDevice->GetFontMetric());
432 static constexpr OUStringLiteral aMeasureString
433 =
u"\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027"
434 "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F"
435 "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037"
436 "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F"
437 "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047"
438 "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F"
439 "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057"
440 "\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F"
441 "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067"
442 "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F"
443 "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077"
444 "\u0078\u0079\u007A\u007B\u007C\u007D\u007E";
446 const double fAverageFontWidth(
447 pTempVirtualDevice->GetTextWidth(aMeasureString) /
448 static_cast<double>(aMeasureString.getLength()));
453 return mpImplFont->GetCalculatedAverageFontWidth();
459 sal_uInt16 nTmp16(0);
460 sal_Int16 nTmps16(0);
512 sal_Int32 nNormedFontScaling(0);
514 rnNormedFontScaling = nNormedFontScaling;
571 if (nNormedFontScaling > 0)
580 sal_uInt32 nScaledWidth(0);
590 const double fScaleFactor(
static_cast<double>(nNormedFontScaling) /
static_cast<double>(nHeight));
629 if (nNormedFontScaling > 0)
636 nNormedFontScaling = 0;
651 const double fScaleFactor(
652 static_cast<double>(nNormedFontScaling)
654 nNormedFontScaling =
static_cast<tools::Long>(fScaleFactor * nHeight);
665 bool identifyTrueTypeFont(
const void* i_pBuffer, sal_uInt32 i_nSize,
Font& o_rResult )
667 bool bResult =
false;
684 o_rResult.
SetWeight( WEIGHT_ULTRALIGHT );
728 o_rResult.
SetPitch( (aInfo.
pitch == 0) ? PITCH_VARIABLE : PITCH_FIXED );
744 struct WeightSearchEntry
750 bool operator<(
const WeightSearchEntry& rRight )
const
752 return rtl_str_compareIgnoreAsciiCase_WithLength(
string, string_len, rRight.string, rRight.string_len ) < 0;
755 const weight_table[] =
769 bool identifyType1Font(
const char* i_pBuffer, sal_uInt32 i_nSize,
Font& o_rResult )
772 const char* pStream = i_pBuffer;
773 const char*
const pExec =
"eexec";
774 const char* pExecPos = std::search( pStream, pStream+i_nSize, pExec, pExec+5 );
775 if( pExecPos != pStream+i_nSize)
778 static const char*
const pFam =
"/FamilyName";
779 const char* pFamPos = std::search( pStream, pExecPos, pFam, pFam+11 );
780 if( pFamPos != pExecPos )
783 const char* pOpen = pFamPos+11;
784 while( pOpen < pExecPos && *pOpen !=
'(' )
786 const char* pClose = pOpen;
787 while( pClose < pExecPos && *pClose !=
')' )
789 if( pClose - pOpen > 1 )
791 o_rResult.
SetFamilyName( OStringToOUString( std::string_view( pOpen+1, pClose-pOpen-1 ), RTL_TEXTENCODING_ASCII_US ) );
796 static const char*
const pItalic =
"/ItalicAngle";
797 const char* pItalicPos = std::search( pStream, pExecPos, pItalic, pItalic+12 );
798 if( pItalicPos != pExecPos )
800 const char* pItalicEnd = pItalicPos + 12;
801 auto nItalic = rtl_str_toInt64_WithLength(pItalicEnd, 10, pExecPos - pItalicEnd);
802 o_rResult.
SetItalic( (nItalic != 0) ? ITALIC_NORMAL : ITALIC_NONE );
806 static const char*
const pWeight =
"/Weight";
807 const char* pWeightPos = std::search( pStream, pExecPos, pWeight, pWeight+7 );
808 if( pWeightPos != pExecPos )
811 const char* pOpen = pWeightPos+7;
812 while( pOpen < pExecPos && *pOpen !=
'(' )
814 const char* pClose = pOpen;
815 while( pClose < pExecPos && *pClose !=
')' )
817 if( pClose - pOpen > 1 )
819 WeightSearchEntry aEnt;
820 aEnt.string = pOpen+1;
821 aEnt.string_len = (pClose-pOpen)-1;
823 WeightSearchEntry
const * pFound = std::lower_bound( std::begin(weight_table), std::end(weight_table), aEnt );
824 if( pFound != std::end(weight_table) &&
825 rtl_str_compareIgnoreAsciiCase_WithLength( pFound->string, pFound->string_len, aEnt.string, aEnt.string_len) == 0 )
831 static const char*
const pFixed =
"/isFixedPitch";
832 const char* pFixedPos = std::search( pStream, pExecPos, pFixed, pFixed+13 );
833 if( pFixedPos != pExecPos )
836 while( pFixedPos < pExecPos-4 &&
837 ( *pFixedPos ==
' ' ||
838 *pFixedPos ==
'\t' ||
839 *pFixedPos ==
'\r' ||
840 *pFixedPos ==
'\n' ) )
845 if( rtl_str_compareIgnoreAsciiCase_WithLength( pFixedPos, 4,
"true", 4 ) == 0 )
848 o_rResult.
SetPitch( PITCH_VARIABLE );
858 if( ! identifyTrueTypeFont( i_pBuffer, i_nSize, aResult ) )
860 const char* pStream =
static_cast<const char*
>(i_pBuffer);
861 if( pStream && i_nSize > 100 &&
862 *pStream ==
'%' && pStream[1] ==
'!' )
864 identifyType1Font( pStream, i_nSize, aResult );
939 meCharSet( RTL_TEXTENCODING_DONTKNOW ),
942 mbSymbolFlag( false ),
944 mbConfigLookup( false ),
947 mbTransparent( true ),
953 mnCalculatedAverageFontWidth( 0 )
957 maFamilyName( rImplFont.maFamilyName ),
958 maStyleName( rImplFont.maStyleName ),
959 meWeight( rImplFont.meWeight ),
960 meFamily( rImplFont.meFamily ),
961 mePitch( rImplFont.mePitch ),
962 meWidthType( rImplFont.meWidthType ),
963 meItalic( rImplFont.meItalic ),
964 meAlign( rImplFont.meAlign ),
965 meUnderline( rImplFont.meUnderline ),
966 meOverline( rImplFont.meOverline ),
967 meStrikeout( rImplFont.meStrikeout ),
968 meRelief( rImplFont.meRelief ),
969 meEmphasisMark( rImplFont.meEmphasisMark ),
970 meKerning( rImplFont.meKerning ),
971 maAverageFontSize( rImplFont.maAverageFontSize ),
972 meCharSet( rImplFont.meCharSet ),
974 maCJKLanguageTag( rImplFont.maCJKLanguageTag ),
975 mbSymbolFlag( rImplFont.mbSymbolFlag ),
976 mbOutline( rImplFont.mbOutline ),
977 mbConfigLookup( rImplFont.mbConfigLookup ),
978 mbShadow( rImplFont.mbShadow ),
979 mbVertical( rImplFont.mbVertical ),
980 mbTransparent( rImplFont.mbTransparent ),
983 mbWordLine( rImplFont.mbWordLine ),
984 mnOrientation( rImplFont.mnOrientation ),
985 mnQuality( rImplFont.mnQuality ),
986 mnCalculatedAverageFontWidth( rImplFont.mnCalculatedAverageFontWidth )
1091 const utl::FontSubstConfiguration& rFontSubst = utl::FontSubstConfiguration::get();
1093 OUString aShortName;
1094 OUString aFamilyName;
1100 utl::FontSubstConfiguration::getMapName( aMapName,
1101 aShortName, aFamilyName, eWeight, eWidthType,
nType );
1107 if ( !pFontAttr && (aShortName != aMapName) )
1108 pFontAttr = rFontSubst.getSubstInfo( aShortName );
1115 if ( pFontAttr->
Type & ImplFontAttrs::Serif )
1117 else if ( pFontAttr->
Type & ImplFontAttrs::SansSerif )
1119 else if ( pFontAttr->
Type & ImplFontAttrs::Typewriter )
1121 else if ( pFontAttr->
Type & ImplFontAttrs::Italic )
1123 else if ( pFontAttr->
Type & ImplFontAttrs::Decorative )
1129 if ( pFontAttr->
Type & ImplFontAttrs::Fixed )
1137 if(
nType & ImplFontAttrs::Serif )
1139 else if(
nType & ImplFontAttrs::SansSerif )
1141 else if(
nType & ImplFontAttrs::Typewriter )
1143 else if(
nType & ImplFontAttrs::Italic )
1145 else if(
nType & ImplFontAttrs::Decorative )
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
bool IsTransparent() const
void SetPitch(const FontPitch ePitch)
void SetFamilyType(const FontFamily eFontFamily)
void SetItalic(const FontItalic eItalic)
void SetWeight(const FontWeight eWeight)
void SetStyleName(const OUString &sStyleName)
void SetWidthType(const FontWidth eWidthType)
void SetFamilyName(const OUString &sFamilyName)
void SetSymbolFlag(const bool)
rtl_TextEncoding meCharSet
const OUString & GetStyleName() const
FontFamily GetFamilyTypeNoAsk() const
size_t GetHashValue() const
size_t GetHashValueIgnoreColor() const
FontPitch GetPitchNoAsk() const
bool operator==(const ImplFont &) const
void SetWeight(const FontWeight eWeight)
rtl_TextEncoding GetCharSet() const
void SetFamilyType(const FontFamily eFontFamily)
FontEmphasisMark meEmphasisMark
void SetItalic(const FontItalic eItalic)
void SetCharSet(const rtl_TextEncoding eCharSet)
bool EqualIgnoreColor(const ImplFont &) const
FontStrikeout meStrikeout
void SetFamilyName(const OUString &sFamilyName)
FontWidth GetWidthTypeNoAsk() const
const OUString & GetFamilyName() const
FontWeight GetWeightNoAsk() const
FontLineStyle meUnderline
LanguageTag maCJKLanguageTag
FontItalic GetItalicNoAsk() const
void SetPitch(const FontPitch ePitch)
LanguageTag maLanguageTag
LanguageType getLanguageType(bool bResolveSystem=true) const
LanguageTag & reset(const OUString &rBcp47LanguageTag)
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
TOOLS_DLLPUBLIC size_t GetHashValue() const
constexpr tools::Long Width() const
SvStream & ReadCharAsBool(bool &rBool)
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & WriteBool(bool b)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & ReadUChar(unsigned char &rChar)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
sal_uInt16 GetVersion() const
FontKerning GetKerning() const
tools::Long GetFontHeight() const
void SetFontSize(const Size &)
void SetOrientation(Degree10 nLineOrientation)
void SetVertical(bool bVertical)
bool IsSameInstance(const Font &) const
FontFamily GetFamilyType()
void SetOutline(bool bOutline)
void SetWidthType(FontWidth)
void SetStyleName(const OUString &rStyleName)
const LanguageTag & GetLanguageTag() const
bool IsSymbolFont() const
void SetAverageFontWidth(tools::Long nWidth)
const LanguageTag & GetCJKContextLanguageTag() const
void SetWordLineMode(bool bWordLine)
void SetPitch(FontPitch ePitch)
size_t GetHashValue() const
void SetTransparent(bool bTransparent)
void Merge(const Font &rFont)
void SetFillColor(const Color &)
void SetColor(const Color &)
const OUString & GetStyleName() const
FontStrikeout GetStrikeout() const
FontLineStyle GetOverline() const
FontRelief GetRelief() const
FontEmphasisMark GetEmphasisMark() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
void SetFontHeight(tools::Long nHeight)
bool IsTransparent() const
tools::Long GetOrCalculateAverageFontWidth() const
const OUString & GetFamilyName() const
void SetCJKContextLanguageTag(const LanguageTag &)
void SetFamily(FontFamily)
void SetUnderline(FontLineStyle)
TextAlign GetAlignment() const
void SetCharSet(rtl_TextEncoding)
const Size & GetFontSize() const
void SetKerning(FontKerning nKerning)
LanguageType GetLanguage() const
size_t GetHashValueIgnoreColor() const
void IncreaseQualityBy(int)
const Color & GetColor() const
void SetAlignment(TextAlign)
void SetLanguageTag(const LanguageTag &)
bool EqualIgnoreColor(const Font &) const
void GetFontAttributes(FontAttributes &rAttrs) const
void SetOverline(FontLineStyle)
void SetFamilyName(const OUString &rFamilyName)
FontLineStyle GetUnderline() const
void DecreaseQualityBy(int)
rtl_TextEncoding GetCharSet() const
void SetLanguage(LanguageType)
void SetShadow(bool bShadow)
LanguageType GetCJKContextLanguage() const
void SetRelief(FontRelief)
bool IsWordLineMode() const
static Font identifyFont(const void *pBuffer, sal_uInt32 nLen)
void SetCJKContextLanguage(LanguageType)
Font & operator=(const Font &)
Degree10 GetOrientation() const
bool operator==(const Font &) const
const Color & GetFillColor() const
void SetEmphasisMark(FontEmphasisMark)
tools::Long GetAverageFontWidth() const
void SetStrikeout(FontStrikeout)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
SvStream & ReadFont(SvStream &rIStm, vcl::Font &rFont)
SvStream & WriteFont(SvStream &rOStm, const vcl::Font &rFont)
SvStream & WriteImplFont(SvStream &rOStm, const ImplFont &rImplFont, tools::Long nNormedFontScaling)
SvStream & ReadImplFont(SvStream &rIStm, ImplFont &rImplFont, tools::Long &rnNormedFontScaling)
UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName(std::u16string_view rName)
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
#define LANGUAGE_DONTKNOW
#define SAL_WARN(area, stream)
LanguageTag maLanguageTag
B2IRange fround(const B2DRange &rRange)
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
@ FWIDTH_CONDENSED
75% of normal
@ FWIDTH_ULTRA_CONDENSED
50% of normal
@ FWIDTH_SEMI_EXPANDED
112.5% of normal
@ FWIDTH_EXTRA_EXPANDED
150% of normal
@ FWIDTH_EXPANDED
125% of normal
@ FWIDTH_EXTRA_CONDENSED
62.5% of normal
@ FWIDTH_ULTRA_EXPANDED
200% of normal
@ FWIDTH_NORMAL
Medium, 100%
@ FWIDTH_SEMI_CONDENSED
87.5% of normal
@ FW_SEMIBOLD
Semi-bold (Demi-bold)
@ FW_NORMAL
Normal (Regular)
@ FW_EXTRALIGHT
Extra-light (Ultra-light)
@ FW_EXTRABOLD
Extra-bold (Ultra-bold)
uno::Sequence< double > maFillColor
rtl_TextEncoding GetStoreCharSet(rtl_TextEncoding eEncoding)
UNDERLYING_TYPE get() const
Return value of GetTTGlobalFontInfo()
int italicAngle
in counter-clockwise degrees * 65536
int width
value of WidthClass or 0 if can't be determined
sal_Unicode * ufamily
family name UCS2
int weight
value of WeightClass or 0 if can't be determined
char * subfamily
subfamily name
int pitch
0: proportional font, otherwise: monospaced
sal_Unicode * usubfamily
subfamily name UCS2
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
bool operator<(const wwFont &r1, const wwFont &r2)