23#include <officecfg/Office/Common.hxx>
36#include <com/sun/star/uno/Sequence.hxx>
53 mnHangingBaseline( 0 ),
54 mbFullstopCentered( false )
102 if( Font::operator!=(r) )
109 if( !Font::EqualIgnoreColor(r) )
137 , mnOrientation( static_cast<short>(rFontSelData.mnOrientation) )
144 , mnHangingBaseline( 0 )
145 , mbFullstopCentered( false )
146 , mnBulletOffset( 0 )
147 , mnUnderlineSize( 0 )
148 , mnUnderlineOffset( 0 )
149 , mnBUnderlineSize( 0 )
150 , mnBUnderlineOffset( 0 )
151 , mnDUnderlineSize( 0 )
152 , mnDUnderlineOffset1( 0 )
153 , mnDUnderlineOffset2( 0 )
154 , mnWUnderlineSize( 0 )
155 , mnWUnderlineOffset( 0 )
156 , mnAboveUnderlineSize( 0 )
157 , mnAboveUnderlineOffset( 0 )
158 , mnAboveBUnderlineSize( 0 )
159 , mnAboveBUnderlineOffset( 0 )
160 , mnAboveDUnderlineSize( 0 )
161 , mnAboveDUnderlineOffset1( 0 )
162 , mnAboveDUnderlineOffset2( 0 )
163 , mnAboveWUnderlineSize( 0 )
164 , mnAboveWUnderlineOffset( 0 )
165 , mnStrikeoutSize( 0 )
166 , mnStrikeoutOffset( 0 )
167 , mnBStrikeoutSize( 0 )
168 , mnBStrikeoutOffset( 0 )
169 , mnDStrikeoutSize( 0 )
170 , mnDStrikeoutOffset1( 0 )
171 , mnDStrikeoutOffset2( 0 )
174 sal_Int32 nTokenPos = 0;
184 css::uno::Sequence<OUString> rNoUnderlineMetricsList(
185 officecfg::Office::Common::Misc::FontsDontUseUnderlineMetrics::get());
201 hb_position_t nUnderlineSize;
202 if (!hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &nUnderlineSize))
204 hb_position_t nUnderlineOffset;
205 if (!hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &nUnderlineOffset))
207 hb_position_t nStrikeoutSize;
208 if (!hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &nStrikeoutSize))
210 hb_position_t nStrikeoutOffset;
211 if (!hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &nStrikeoutOffset))
217 double nOffset = -nUnderlineOffset * fScale;
218 double nSize = nUnderlineSize * fScale;
219 double nSize2 = nSize / 2.;
220 double nBSize = nSize * 2.;
221 double n2Size = nBSize / 3.;
236 nOffset = -nStrikeoutOffset * fScale;
237 nSize = nStrikeoutSize * fScale;
240 n2Size = nBSize / 3.;
276 tools::Long nLineHeight = ((nDescent*25)+50) / 100;
283 tools::Long nBLineHeight = ((nDescent*50)+50) / 100;
284 if ( nBLineHeight == nLineHeight )
287 if ( !nBLineHeight2 )
290 tools::Long n2LineHeight = ((nDescent*16)+50) / 100;
298 if ( n2LineDY < nMin2LineDY )
299 n2LineDY = nMin2LineDY;
320 if ( nWCalcSize < 6 )
322 if ( (nWCalcSize == 1) || (nWCalcSize == 2) )
355 if ( nIntLeading <= 0 )
381 bool bCentered =
true;
387 const auto nB = aRect.
Left();
390 bCentered = nB > (((nH >> 1)+nH)>>3);
396 int nTypoDescent,
int nWinAscent,
397 int nWinDescent)
const
402 OUString aFontIdentifier(
404 + OUString::number(nAscent) +
"," + OUString::number(nDescent) +
","
405 + OUString::number(nTypoAscent) +
"," + OUString::number(nTypoDescent) +
","
406 + OUString::number(nWinAscent) +
"," + OUString::number(nWinDescent));
408 css::uno::Sequence<OUString> rWinMetricFontList(
409 officecfg::Office::Common::Misc::FontsUseWinMetrics::get());
412 SAL_INFO(
"vcl.gdi.fontmetric",
"Using win metrics for: " << aFontIdentifier);
421constexpr auto ASCENT_OS2 =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'O',
'a',
's',
'c'));
422constexpr auto DESCENT_OS2 =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'O',
'd',
's',
'c'));
423constexpr auto LINEGAP_OS2 =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'O',
'l',
'g',
'p'));
424constexpr auto ASCENT_HHEA =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'H',
'a',
's',
'c'));
425constexpr auto DESCENT_HHEA =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'H',
'd',
's',
'c'));
426constexpr auto LINEGAP_HHEA =
static_cast<hb_ot_metrics_tag_t
>(HB_TAG(
'H',
'l',
'g',
'p'));
432 auto* pHbFont = pFontInstance->
GetHbFont();
435 pFontInstance->
GetScale(
nullptr, &fScale);
436 double fAscent = 0, fDescent = 0, fExtLeading = 0;
438 auto aFvar(pFace->GetRawFontData(HB_TAG(
'f',
'v',
'a',
'r')));
443 hb_position_t nAscent, nDescent, nLineGap;
444 if (hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, &nAscent)
445 && hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER,
447 && hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP,
450 fAscent = nAscent * fScale;
451 fDescent = -nDescent * fScale;
452 fExtLeading = nLineGap * fScale;
476 hb_position_t nAscent = 0, nDescent = 0, nLineGap = 0;
477 if (hb_ot_metrics_get_position(pHbFont,
ASCENT_HHEA, &nAscent)
478 && hb_ot_metrics_get_position(pHbFont,
DESCENT_HHEA, &nDescent)
479 && hb_ot_metrics_get_position(pHbFont,
LINEGAP_HHEA, &nLineGap))
483 if (nAscent >= 0 && nDescent <= 0)
485 fAscent = nAscent * fScale;
486 fDescent = -nDescent * fScale;
487 fExtLeading = nLineGap * fScale;
492 hb_position_t nTypoAscent, nTypoDescent, nTypoLineGap, nWinAscent, nWinDescent;
493 if (hb_ot_metrics_get_position(pHbFont,
ASCENT_OS2, &nTypoAscent)
494 && hb_ot_metrics_get_position(pHbFont,
DESCENT_OS2, &nTypoDescent)
495 && hb_ot_metrics_get_position(pHbFont,
LINEGAP_OS2, &nTypoLineGap)
496 && hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT,
498 && hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_DESCENT,
501 if ((fAscent == 0.0 && fDescent == 0.0)
505 fAscent = nWinAscent * fScale;
506 fDescent = nWinDescent * fScale;
510 bool bUseTypoMetrics =
false;
514 sal_uInt16 fsSelection = 0;
515 auto aOS2(pFace->GetRawFontData(HB_TAG(
'O',
'S',
'/',
'2')));
516 SvMemoryStream aStream(
const_cast<uint8_t*
>(aOS2.data()), aOS2.size(),
522 bUseTypoMetrics = fsSelection & (1 << 7);
524 if (bUseTypoMetrics && nTypoAscent >= 0 && nTypoDescent <= 0)
526 fAscent = nTypoAscent * fScale;
527 fDescent = -nTypoDescent * fScale;
528 fExtLeading = nTypoLineGap * fScale;
543 hb_font_t* pHbFont = pFontInstance->
GetHbFont();
545 pFontInstance->
GetScale(
nullptr, &fScale);
546 hb_position_t nBaseline = 0;
548 if (hb_ot_layout_get_baseline(pHbFont,
549 HB_OT_LAYOUT_BASELINE_TAG_HANGING,
550 HB_DIRECTION_INVALID,
bool IsMicrosoftSymbolEncoded() const
FontFamily GetFamilyType() const
FontItalic GetItalic() const
FontWeight GetWeight() const
void SetStyleName(const OUString &sStyleName)
const OUString & GetFamilyName() const
void SetFamilyName(const OUString &sFamilyName)
FontPitch GetPitch() const
const OUString & GetStyleName() const
FontWidth GetWidthType() const
void ImplInitTextLineSize(const OutputDevice *pDev)
tools::Long mnDUnderlineSize
tools::Long mnAboveUnderlineSize
tools::Long mnUnderlineSize
tools::Long mnAboveDUnderlineSize
tools::Long mnStrikeoutSize
bool ImplInitTextLineSizeHarfBuzz(LogicalFontInstance *pFontInstance)
tools::Long mnWUnderlineSize
tools::Long mnBUnderlineOffset
tools::Long mnAboveUnderlineOffset
tools::Long mnAboveBUnderlineOffset
bool ShouldNotUseUnderlineMetrics() const
tools::Long mnAboveDUnderlineOffset2
tools::Long mnDStrikeoutOffset1
void SetFullstopCenteredFlag(bool bFullstopCentered)
tools::Long mnBulletOffset
tools::Long mnAboveWUnderlineSize
tools::Long mnBStrikeoutSize
tools::Long mnDStrikeoutSize
tools::Long mnBUnderlineSize
void ImplInitAboveTextLineSize(const OutputDevice *pDev)
tools::Long mnAboveWUnderlineOffset
void ImplInitFlags(const OutputDevice *pDev)
void ImplInitBaselines(LogicalFontInstance *pFontInstance)
tools::Long mnWUnderlineOffset
tools::Long mnDStrikeoutOffset2
tools::Long mnDUnderlineOffset1
tools::Long mnStrikeoutOffset
tools::Long mnAboveDUnderlineOffset1
tools::Long mnBStrikeoutOffset
tools::Long mnHangingBaseline
FontMetricData(const vcl::font::FontSelectPattern &)
tools::Long mnUnderlineOffset
bool ShouldUseWinMetrics(int, int, int, int, int, int) const
tools::Long mnAboveBUnderlineSize
void ImplCalcLineSpacing(LogicalFontInstance *pFontInstance)
tools::Long mnDUnderlineOffset2
FontMetric & operator=(const FontMetric &rMetric)
size_t GetHashValueNoBase() const
bool operator==(const FontMetric &rMetric) const
size_t GetHashValueIgnoreColor() const
bool EqualIgnoreColor(const FontMetric &) const
bool EqualNoBase(const FontMetric &) const
void GetScale(double *nXScale, double *nYScale) const
const vcl::font::PhysicalFontFace * GetFontFace() const
static bool isCJK(LanguageType nLang)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
LogicalFontInstance const * GetFontInstance() const
const vcl::Font & GetFont() const
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
Return the exact bounding rectangle of rStr.
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
constexpr tools::Long Height() const
void SetEndian(SvStreamEndian SvStreamEndian)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
void SetWidthType(FontWidth)
void SetStyleName(const OUString &rStyleName)
void SetPitch(FontPitch ePitch)
void SetItalic(FontItalic)
void SetWeight(FontWeight)
void SetFamily(FontFamily)
void SetCharSet(rtl_TextEncoding)
const Size & GetFontSize() const
LanguageType GetLanguage() const
void SetAlignment(TextAlign)
void SetFamilyName(const OUString &rFamilyName)
abstract base class for physical font faces
UNOTOOLS_DLLPUBLIC std::u16string_view GetNextFontToken(std::u16string_view rTokenStr, sal_Int32 &rIndex)
constexpr auto ASCENT_OS2
constexpr auto LINEGAP_HHEA
constexpr auto ASCENT_HHEA
constexpr auto DESCENT_OS2
constexpr auto LINEGAP_OS2
constexpr auto DESCENT_HHEA
#define SAL_INFO(area, stream)
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
constexpr int OS2_fsSelection_offset