59Font::Font() : mpImplFont(GetGlobalDefault())
81Font::Font(
const OUString& rFamilyName,
const OUString& rStyleName,
const Size& rSize )
187 if (
const_cast<const ImplType&
>(
mpImplFont)->maCJKLanguageTag.getLanguageType(
false) != eLanguage)
188 mpImplFont->maCJKLanguageTag.reset( eLanguage);
310 mpImplFont = std::move(rFont.mpImplFont);
320 if (!(nEmphasisMark & (FontEmphasisMark::PosAbove | FontEmphasisMark::PosBelow)))
326 nEmphasisMark |= FontEmphasisMark::PosBelow;
334 nEmphasisMark |= FontEmphasisMark::PosBelow;
336 nEmphasisMark |= FontEmphasisMark::PosAbove;
340 return nEmphasisMark;
423 if(0 ==
mpImplFont->GetCalculatedAverageFontWidth())
432 pTempVirtualDevice->SetFont(aUnscaledFont);
436 const FontMetric aMetric(pTempVirtualDevice->GetFontMetric());
443 static constexpr OUStringLiteral aMeasureString
444 =
u"\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027"
445 "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F"
446 "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037"
447 "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F"
448 "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047"
449 "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F"
450 "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057"
451 "\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F"
452 "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067"
453 "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F"
454 "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077"
455 "\u0078\u0079\u007A\u007B\u007C\u007D\u007E";
457 const double fAverageFontWidth(
458 pTempVirtualDevice->GetTextWidth(aMeasureString) /
459 static_cast<double>(aMeasureString.getLength()));
464 return mpImplFont->GetCalculatedAverageFontWidth();
470 sal_uInt16 nTmp16(0);
471 sal_Int16 nTmps16(0);
529 sal_Int32 nNormedFontScaling(0);
531 rnNormedFontScaling = nNormedFontScaling;
597 if (nNormedFontScaling > 0)
606 sal_uInt32 nScaledWidth(0);
616 const double fScaleFactor(
static_cast<double>(nNormedFontScaling) /
static_cast<double>(nHeight));
655 if (nNormedFontScaling > 0)
662 nNormedFontScaling = 0;
677 const double fScaleFactor(
678 static_cast<double>(nNormedFontScaling)
680 nNormedFontScaling =
static_cast<tools::Long>(fScaleFactor * nHeight);
691 bool identifyTrueTypeFont(
const void* i_pBuffer, sal_uInt32 i_nSize,
Font& o_rResult )
693 bool bResult =
false;
702 else if( !aInfo.
family.isEmpty() )
710 o_rResult.
SetWeight( WEIGHT_ULTRALIGHT );
754 o_rResult.
SetPitch( (aInfo.
pitch == 0) ? PITCH_VARIABLE : PITCH_FIXED );
770 struct WeightSearchEntry
776 bool operator<(
const WeightSearchEntry& rRight )
const
778 return rtl_str_compareIgnoreAsciiCase_WithLength(
string, string_len, rRight.string, rRight.string_len ) < 0;
781 const weight_table[] =
795 bool identifyType1Font(
const char* i_pBuffer, sal_uInt32 i_nSize,
Font& o_rResult )
798 const char* pStream = i_pBuffer;
799 const char*
const pExec =
"eexec";
800 const char* pExecPos = std::search( pStream, pStream+i_nSize, pExec, pExec+5 );
801 if( pExecPos != pStream+i_nSize)
804 static const char*
const pFam =
"/FamilyName";
805 const char* pFamPos = std::search( pStream, pExecPos, pFam, pFam+11 );
806 if( pFamPos != pExecPos )
809 const char* pOpen = pFamPos+11;
810 while( pOpen < pExecPos && *pOpen !=
'(' )
812 const char* pClose = pOpen;
813 while( pClose < pExecPos && *pClose !=
')' )
815 if( pClose - pOpen > 1 )
817 o_rResult.
SetFamilyName( OStringToOUString( std::string_view( pOpen+1, pClose-pOpen-1 ), RTL_TEXTENCODING_ASCII_US ) );
822 static const char*
const pItalic =
"/ItalicAngle";
823 const char* pItalicPos = std::search( pStream, pExecPos, pItalic, pItalic+12 );
824 if( pItalicPos != pExecPos )
826 const char* pItalicEnd = pItalicPos + 12;
827 auto nItalic = rtl_str_toInt64_WithLength(pItalicEnd, 10, pExecPos - pItalicEnd);
828 o_rResult.
SetItalic( (nItalic != 0) ? ITALIC_NORMAL : ITALIC_NONE );
832 static const char*
const pWeight =
"/Weight";
833 const char* pWeightPos = std::search( pStream, pExecPos, pWeight, pWeight+7 );
834 if( pWeightPos != pExecPos )
837 const char* pOpen = pWeightPos+7;
838 while( pOpen < pExecPos && *pOpen !=
'(' )
840 const char* pClose = pOpen;
841 while( pClose < pExecPos && *pClose !=
')' )
843 if( pClose - pOpen > 1 )
845 WeightSearchEntry aEnt;
846 aEnt.string = pOpen+1;
847 aEnt.string_len = (pClose-pOpen)-1;
849 WeightSearchEntry
const * pFound = std::lower_bound( std::begin(weight_table), std::end(weight_table), aEnt );
850 if( pFound != std::end(weight_table) &&
851 rtl_str_compareIgnoreAsciiCase_WithLength( pFound->string, pFound->string_len, aEnt.string, aEnt.string_len) == 0 )
857 static const char*
const pFixed =
"/isFixedPitch";
858 const char* pFixedPos = std::search( pStream, pExecPos, pFixed, pFixed+13 );
859 if( pFixedPos != pExecPos )
862 while( pFixedPos < pExecPos-4 &&
863 ( *pFixedPos ==
' ' ||
864 *pFixedPos ==
'\t' ||
865 *pFixedPos ==
'\r' ||
866 *pFixedPos ==
'\n' ) )
871 if( rtl_str_compareIgnoreAsciiCase_WithLength( pFixedPos, 4,
"true", 4 ) == 0 )
874 o_rResult.
SetPitch( PITCH_VARIABLE );
884 if( ! identifyTrueTypeFont( i_pBuffer, i_nSize, aResult ) )
886 const char* pStream =
static_cast<const char*
>(i_pBuffer);
887 if( pStream && i_nSize > 100 &&
888 *pStream ==
'%' && pStream[1] ==
'!' )
890 identifyType1Font( pStream, i_nSize, aResult );
966 meCharSet( RTL_TEXTENCODING_DONTKNOW ),
970 mbConfigLookup( false ),
973 mbTransparent( true ),
979 mnCalculatedAverageFontWidth( 0 )
983 maFamilyName( rImplFont.maFamilyName ),
984 maStyleName( rImplFont.maStyleName ),
985 meWeight( rImplFont.meWeight ),
986 meFamily( rImplFont.meFamily ),
987 mePitch( rImplFont.mePitch ),
988 meWidthType( rImplFont.meWidthType ),
989 meItalic( rImplFont.meItalic ),
990 meAlign( rImplFont.meAlign ),
991 meUnderline( rImplFont.meUnderline ),
992 meOverline( rImplFont.meOverline ),
993 meStrikeout( rImplFont.meStrikeout ),
994 meRelief( rImplFont.meRelief ),
995 meEmphasisMark( rImplFont.meEmphasisMark ),
996 meKerning( rImplFont.meKerning ),
997 mnSpacing( rImplFont.mnSpacing ),
998 maAverageFontSize( rImplFont.maAverageFontSize ),
999 meCharSet( rImplFont.meCharSet ),
1001 maCJKLanguageTag( rImplFont.maCJKLanguageTag ),
1002 mbOutline( rImplFont.mbOutline ),
1003 mbConfigLookup( rImplFont.mbConfigLookup ),
1004 mbShadow( rImplFont.mbShadow ),
1005 mbVertical( rImplFont.mbVertical ),
1006 mbTransparent( rImplFont.mbTransparent ),
1009 mbWordLine( rImplFont.mbWordLine ),
1010 mnOrientation( rImplFont.mnOrientation ),
1011 mnQuality( rImplFont.mnQuality ),
1012 mnCalculatedAverageFontWidth( rImplFont.mnCalculatedAverageFontWidth )
1119 const utl::FontSubstConfiguration& rFontSubst = utl::FontSubstConfiguration::get();
1121 OUString aShortName;
1122 OUString aFamilyName;
1128 utl::FontSubstConfiguration::getMapName( aMapName,
1129 aShortName, aFamilyName, eWeight, eWidthType,
nType );
1135 if ( !pFontAttr && (aShortName != aMapName) )
1136 pFontAttr = rFontSubst.getSubstInfo( aShortName );
1143 if ( pFontAttr->
Type & ImplFontAttrs::Serif )
1145 else if ( pFontAttr->
Type & ImplFontAttrs::SansSerif )
1147 else if ( pFontAttr->
Type & ImplFontAttrs::Typewriter )
1149 else if ( pFontAttr->
Type & ImplFontAttrs::Italic )
1151 else if ( pFontAttr->
Type & ImplFontAttrs::Decorative )
1157 if ( pFontAttr->
Type & ImplFontAttrs::Fixed )
1165 if(
nType & ImplFontAttrs::Serif )
1167 else if(
nType & ImplFontAttrs::SansSerif )
1169 else if(
nType & ImplFontAttrs::Typewriter )
1171 else if(
nType & ImplFontAttrs::Italic )
1173 else if(
nType & ImplFontAttrs::Decorative )
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 SetMicrosoftSymbolEncoded(const bool)
void SetWeight(const FontWeight eWeight)
void SetStyleName(const OUString &sStyleName)
void SetWidthType(const FontWidth eWidthType)
void SetFamilyName(const OUString &sFamilyName)
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)
static bool isSimplifiedChinese(LanguageType nLang)
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
TOOLS_DLLPUBLIC size_t GetHashValue() const
constexpr tools::Long Width() const
SvStream & ReadCharAsBool(bool &rBool)
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & WriteBool(bool b)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & ReadUChar(unsigned char &rChar)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
sal_uInt16 GetVersion() const
FontKerning GetKerning() const
tools::Long GetFontHeight() const
void SetFontSize(const Size &)
void SetOrientation(Degree10 nLineOrientation)
o3tl::cow_wrapper< ImplFont > ImplType
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
void SetAverageFontWidth(tools::Long nWidth)
const LanguageTag & GetCJKContextLanguageTag() const
void SetWordLineMode(bool bWordLine)
void SetPitch(FontPitch ePitch)
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 SetFixKerning(const short nSpacing)
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)
bool IsFixKerning() const
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)
short GetFixKerning() const
Font & operator=(const Font &)
Degree10 GetOrientation() const
FontEmphasisMark GetEmphasisMarkStyle() 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)
void GetTTGlobalFontInfo(AbstractTrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
#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
OString family
family name
int width
value of WidthClass or 0 if can't be determined
int weight
value of WeightClass or 0 if can't be determined
OUString usubfamily
subfamily name UCS2
OUString ufamily
family name UCS2
int pitch
0: proportional font, otherwise: monospaced
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
OString subfamily
subfamily name
bool operator<(const wwFont &r1, const wwFont &r2)