vcl: No need to get font face from GetNextGlyphs()

We can take it from the font instance.

Change-Id: I54c507d498c58e271c479b0a615b165345a1c33b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140788
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
This commit is contained in:
Khaled Hosny 2022-09-30 09:55:52 +02:00 committed by خالد حسني
parent a091ae213e
commit e6a46b2359
4 changed files with 10 additions and 19 deletions

View File

@ -102,8 +102,7 @@ public:
// methods using glyph indexing // methods using glyph indexing
virtual bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart, virtual bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
const LogicalFontInstance** ppGlyphFont = nullptr, const LogicalFontInstance** ppGlyphFont = nullptr) const = 0;
const vcl::font::PhysicalFontFace** pFallbackFont = nullptr) const = 0;
virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const; virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const;
bool GetBoundRect(tools::Rectangle&) const; bool GetBoundRect(tools::Rectangle&) const;

View File

@ -65,8 +65,7 @@ public:
DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const override; DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const override;
void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const override; void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const override;
bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart, bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
const LogicalFontInstance** ppGlyphFont = nullptr, const LogicalFontInstance** ppGlyphFont = nullptr) const override;
const vcl::font::PhysicalFontFace** pFallbackFont = nullptr) const override;
bool GetOutline(basegfx::B2DPolyPolygonVector&) const override; bool GetOutline(basegfx::B2DPolyPolygonVector&) const override;
bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override; bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override;
SalLayoutGlyphs GetGlyphs() const final override; SalLayoutGlyphs GetGlyphs() const final override;
@ -129,8 +128,7 @@ public:
{ return *m_GlyphItems.GetFont(); } { return *m_GlyphItems.GetFont(); }
bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart, bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
const LogicalFontInstance** ppGlyphFont = nullptr, const LogicalFontInstance** ppGlyphFont = nullptr) const override;
const vcl::font::PhysicalFontFace** pFallbackFont = nullptr) const override;
const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; } const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; }

View File

@ -6580,7 +6580,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
FontMetric aRefDevFontMetric = GetFontMetric(); FontMetric aRefDevFontMetric = GetFontMetric();
const vcl::font::PhysicalFontFace* pDevFont = GetFontInstance()->GetFontFace(); const vcl::font::PhysicalFontFace* pDevFont = GetFontInstance()->GetFontFace();
const GlyphItem* pGlyph = nullptr; const GlyphItem* pGlyph = nullptr;
const vcl::font::PhysicalFontFace* pFallbackFont = nullptr;
const LogicalFontInstance* pGlyphFont = nullptr; const LogicalFontInstance* pGlyphFont = nullptr;
// collect the glyphs into a single array // collect the glyphs into a single array
@ -6588,9 +6587,9 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
aGlyphs.reserve( nMaxGlyphs ); aGlyphs.reserve( nMaxGlyphs );
// first get all the glyphs and register them; coordinates still in Pixel // first get all the glyphs and register them; coordinates still in Pixel
DevicePoint aPos; DevicePoint aPos;
while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex, &pGlyphFont, &pFallbackFont)) while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex, &pGlyphFont))
{ {
const auto* pFont = pFallbackFont ? pFallbackFont : pDevFont; const auto* pFace = pGlyphFont->GetFontFace();
aCodeUnits.clear(); aCodeUnits.clear();
@ -6633,7 +6632,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
// instead. // instead.
if (!aCodeUnits.empty() && !bUseActualText) if (!aCodeUnits.empty() && !bUseActualText)
{ {
for (const auto& rSubset : m_aSubsets[pFont].m_aSubsets) for (const auto& rSubset : m_aSubsets[pFace].m_aSubsets)
{ {
const auto& it = rSubset.m_aMapping.find(nGlyphId); const auto& it = rSubset.m_aMapping.find(nGlyphId);
if (it != rSubset.m_aMapping.cend() && it->second.codes() != aCodeUnits) if (it != rSubset.m_aMapping.cend() && it->second.codes() != aCodeUnits)
@ -6650,7 +6649,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
sal_uInt8 nMappedGlyph; sal_uInt8 nMappedGlyph;
sal_Int32 nMappedFontObject; sal_Int32 nMappedFontObject;
registerGlyph(nGlyphId, pFont, aCodeUnits, nGlyphWidth, nMappedGlyph, nMappedFontObject, pDevFont->IsColorFont()); registerGlyph(nGlyphId, pFace, aCodeUnits, nGlyphWidth, nMappedGlyph, nMappedFontObject, pDevFont->IsColorFont());
int nCharPos = -1; int nCharPos = -1;
if (bUseActualText || pGlyph->IsInCluster()) if (bUseActualText || pGlyph->IsInCluster())
@ -6658,7 +6657,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
aGlyphs.emplace_back(aPos, aGlyphs.emplace_back(aPos,
pGlyph, pGlyph,
XUnits(pFont->UnitsPerEm(), nGlyphWidth), XUnits(pFace->UnitsPerEm(), nGlyphWidth),
nMappedFontObject, nMappedFontObject,
nMappedGlyph, nMappedGlyph,
nCharPos); nCharPos);

View File

@ -520,8 +520,7 @@ sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoor
bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
DevicePoint& rPos, int& nStart, DevicePoint& rPos, int& nStart,
const LogicalFontInstance** ppGlyphFont, const LogicalFontInstance** ppGlyphFont) const
const vcl::font::PhysicalFontFace**) const
{ {
std::vector<GlyphItem>::const_iterator pGlyphIter = m_GlyphItems.begin(); std::vector<GlyphItem>::const_iterator pGlyphIter = m_GlyphItems.begin();
std::vector<GlyphItem>::const_iterator pGlyphIterEnd = m_GlyphItems.end(); std::vector<GlyphItem>::const_iterator pGlyphIterEnd = m_GlyphItems.end();
@ -1145,8 +1144,7 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray )
bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph, bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
DevicePoint& rPos, int& nStart, DevicePoint& rPos, int& nStart,
const LogicalFontInstance** ppGlyphFont, const LogicalFontInstance** ppGlyphFont) const
const vcl::font::PhysicalFontFace** pFallbackFont) const
{ {
// NOTE: nStart is tagged with current font index // NOTE: nStart is tagged with current font index
int nLevel = static_cast<unsigned>(nStart) >> GF_FONTSHIFT; int nLevel = static_cast<unsigned>(nStart) >> GF_FONTSHIFT;
@ -1155,13 +1153,10 @@ bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
{ {
GenericSalLayout& rLayout = *mpLayouts[ nLevel ]; GenericSalLayout& rLayout = *mpLayouts[ nLevel ];
rLayout.InitFont(); rLayout.InitFont();
const vcl::font::PhysicalFontFace* pFontFace = rLayout.GetFont().GetFontFace();
if (rLayout.GetNextGlyph(pGlyph, rPos, nStart, ppGlyphFont)) if (rLayout.GetNextGlyph(pGlyph, rPos, nStart, ppGlyphFont))
{ {
int nFontTag = nLevel << GF_FONTSHIFT; int nFontTag = nLevel << GF_FONTSHIFT;
nStart |= nFontTag; nStart |= nFontTag;
if (pFallbackFont)
*pFallbackFont = pFontFace;
rPos.adjustX(maDrawBase.getX() + maDrawOffset.X()); rPos.adjustX(maDrawBase.getX() + maDrawOffset.X());
rPos.adjustY(maDrawBase.getY() + maDrawOffset.Y()); rPos.adjustY(maDrawBase.getY() + maDrawOffset.Y());
return true; return true;