summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-06-14 11:10:32 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-06-16 15:47:36 +0000
commit67aa2ec2133bb5ba681c9a9339f362a5829f903d (patch)
tree75511c27c244b06e611a46a7ea0d7db35678340a
parent84b8e86223a3867479f8fd39ce902def59be393a (diff)
Get rid of SalLayout::GetFallbackFontData()
This is only used in conjunction with SalLayout::GetNextGlyphs() in vcl/source/gdi/pdfwriter_impl.cxx to retrieve the fallback font, if any, used to layout the given glyph, but it is a very convoluted way to do a straight forward thing, and hard to adapt for new SalLayout implementations. So now I just pass a fallback fonts array, when requested, in GetNextGlyphs() itself. Change-Id: I24e7931f64867a4fb4e7b728c65faa6198e24aba Reviewed-on: https://gerrit.libreoffice.org/4300 Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> Tested-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r--vcl/aqua/source/gdi/atsui/salatslayout.cxx22
-rw-r--r--vcl/coretext/ctlayout.cxx32
-rw-r--r--vcl/inc/graphite_layout.hxx3
-rw-r--r--vcl/inc/graphite_serverfont.hxx5
-rw-r--r--vcl/inc/sallayout.hxx13
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx6
-rw-r--r--vcl/source/gdi/sallayout.cxx25
-rw-r--r--vcl/source/glyphs/graphite_layout.cxx3
-rw-r--r--vcl/win/source/gdi/winlayout.cxx20
9 files changed, 49 insertions, 80 deletions
diff --git a/vcl/aqua/source/gdi/atsui/salatslayout.cxx b/vcl/aqua/source/gdi/atsui/salatslayout.cxx
index 1b9776e8c195..fd080f6d9976 100644
--- a/vcl/aqua/source/gdi/atsui/salatslayout.cxx
+++ b/vcl/aqua/source/gdi/atsui/salatslayout.cxx
@@ -56,8 +56,6 @@ public:
virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
- const PhysicalFontFace* GetFallbackFontData( sal_GlyphId ) const;
-
virtual void InitFont() const;
virtual void MoveGlyph( int nStart, long nNewXPos );
virtual void DropGlyph( int nStart );
@@ -505,7 +503,8 @@ void ATSLayout::DrawText( SalGraphics& rGraphics ) const
* @return : number of glyph details that were provided
**/
int ATSLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const
+ sal_Int32* pGlyphAdvances, int* pCharIndexes,
+ const PhysicalFontFace** pFallbackFonts ) const
{
if( nStart < 0 ) // first glyph requested?
nStart = 0;
@@ -582,6 +581,9 @@ int ATSLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int
const int nLevel = mpFallbackInfo->AddFallback( nFallbackFontID );
// update sal_GlyphId with fallback level
nGlyphId |= (nLevel << GF_FONTSHIFT);
+
+ if( pFallbackFonts )
+ *(pFallbackFonts++) = mpFallbackInfo->GetFallbackFontData( nLevel );
}
// update resulting glyphid array
@@ -1184,20 +1186,6 @@ void ATSLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
void ATSLayout::DropGlyph( int /*nStart*/ ) {}
void ATSLayout::Simplify( bool /*bIsBase*/ ) {}
-// get the PhysicalFontFace for a glyph fallback font
-// for a glyphid that was returned by ATSLayout::GetNextGlyphs()
-const PhysicalFontFace* ATSLayout::GetFallbackFontData( sal_GlyphId nGlyphId ) const
-{
- // check if any fallback fonts were needed
- if( !mpFallbackInfo )
- return NULL;
- // check if the current glyph needs a fallback font
- int nFallbackLevel = (nGlyphId & GF_FONTMASK) >> GF_FONTSHIFT;
- if( !nFallbackLevel )
- return NULL;
- return mpFallbackInfo->GetFallbackFontData( nFallbackLevel );
-}
-
// =======================================================================
int FallbackInfo::AddFallback( ATSUFontID nFontId )
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index e2b44c1445bd..0334cffe8a4b 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -34,7 +34,8 @@ public:
virtual void DrawText( SalGraphics& ) const;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
+ sal_Int32* pGlyphAdvances, int* pCharIndexes,
+ const PhysicalFontFace** pFallbackFonts ) const;
virtual long GetTextWidth() const;
virtual long FillDXArray( sal_Int32* pDXArray ) const;
@@ -43,8 +44,6 @@ public:
virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
- const PhysicalFontFace* GetFallbackFontData( sal_GlyphId ) const;
-
virtual void InitFont( void) const;
virtual void MoveGlyph( int nStart, long nNewXPos );
virtual void DropGlyph( int nStart );
@@ -223,7 +222,8 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
// -----------------------------------------------------------------------
int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const
+ sal_Int32* pGlyphAdvances, int* pCharIndexes,
+ const PhysicalFontFace** pFallbackFonts ) const
{
if( !mpCTLine )
return 0;
@@ -292,6 +292,8 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
}
}
+ const PhysicalFontFace* pFallbackFont = NULL;
+
// get the details for each interesting glyph
// TODO: handle nLen>1
for(; (--nLen >= 0) && (nSubIndex < nGlyphsInRun); ++nSubIndex, ++nStart )
@@ -302,6 +304,8 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
*(pGlyphAdvances++) = pCGGlyphAdvs[ nSubIndex ].width;
if( pCharIndexes )
*(pCharIndexes++) = pCGGlyphStrIdx[ nSubIndex] + mnMinCharPos;
+ if( pFallbackFonts )
+ *(pFallbackFonts++) = pFallbackFont;
if( !nCount++ ) {
const CGPoint& rCurPos = pCGGlyphPos[ nSubIndex ];
rPos = GetDrawPosition( Point( mfFontScale * rCurPos.x, mfFontScale * rCurPos.y) );
@@ -441,26 +445,6 @@ void CTLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
void CTLayout::DropGlyph( int /*nStart*/ ) {}
void CTLayout::Simplify( bool /*bIsBase*/ ) {}
-// get the PhysicalFontFace for a glyph fallback font
-// for a glyphid that was returned by CTLayout::GetNextGlyphs()
-const PhysicalFontFace* CTLayout::GetFallbackFontData( sal_GlyphId /*nGlyphId*/ ) const
-{
-#if 0
- // check if any fallback fonts were needed
- if( !mpFallbackInfo )
- return NULL;
- // check if the current glyph needs a fallback font
- int nFallbackLevel = (nGlyphId & GF_FONTMASK) >> GF_FONTSHIFT;
- if( !nFallbackLevel )
- return NULL;
- pFallbackFont = mpFallbackInfo->GetFallbackFontData( nFallbackLevel );
-#else
- // let CoreText's font cascading handle glyph fallback
- const PhysicalFontFace* pFallbackFont = NULL;
-#endif
- return pFallbackFont;
-}
-
// =======================================================================
SalLayout* CTTextStyle::GetTextLayout( void ) const
diff --git a/vcl/inc/graphite_layout.hxx b/vcl/inc/graphite_layout.hxx
index bbf6f15b2fe5..b81083458e1a 100644
--- a/vcl/inc/graphite_layout.hxx
+++ b/vcl/inc/graphite_layout.hxx
@@ -127,7 +127,8 @@ public:
// methods using glyph indexing
virtual int GetNextGlyphs(int nLen, sal_GlyphId* pGlyphIdxAry, ::Point & rPos, int&,
- sal_Int32* pGlyphAdvAry = 0, int* pCharPosAry = 0 ) const;
+ sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const;
// used by glyph+font+script fallback
virtual void MoveGlyph( int nStart, long nNewXPos );
diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx
index a0a3890af686..cfd2cd679079 100644
--- a/vcl/inc/graphite_serverfont.hxx
+++ b/vcl/inc/graphite_serverfont.hxx
@@ -73,11 +73,12 @@ public:
// used by display layers
virtual int GetNextGlyphs( int l, sal_GlyphId* gia, Point& p, int& s,
- sal_Int32* gaa = NULL, int* cpa = NULL ) const
+ sal_Int32* gaa = NULL, int* cpa = NULL,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const
{
maImpl.DrawBase() = maDrawBase;
maImpl.DrawOffset() = maDrawOffset;
- return maImpl.GetNextGlyphs(l, gia, p, s, gaa, cpa);
+ return maImpl.GetNextGlyphs(l, gia, p, s, gaa, cpa, pFallbackFonts);
}
virtual void MoveGlyph( int nStart, long nNewXPos ) { maImpl.MoveGlyph(nStart, nNewXPos); };
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 6b25f5bae386..491db056cee6 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -203,8 +203,6 @@ public:
int GetUnitsPerPixel() const { return mnUnitsPerPixel; }
int GetOrientation() const { return mnOrientation; }
- virtual const PhysicalFontFace* GetFallbackFontData( sal_GlyphId ) const;
-
// methods using string indexing
virtual int GetTextBreak( long nMaxWidth, long nCharExtra=0, int nFactor=1 ) const = 0;
virtual long FillDXArray( sal_Int32* pDXArray ) const = 0;
@@ -214,7 +212,8 @@ public:
// methods using glyph indexing
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdAry, Point& rPos, int&,
- sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL ) const = 0;
+ sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const = 0;
virtual bool GetOutline( SalGraphics&, ::basegfx::B2DPolyPolygonVector& ) const;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
@@ -267,7 +266,8 @@ public:
virtual long FillDXArray( sal_Int32* pDXArray ) const;
virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos,
- int&, sal_Int32* pGlyphAdvAry, int* pCharPosAry ) const;
+ int&, sal_Int32* pGlyphAdvAry, int* pCharPosAry,
+ const PhysicalFontFace** pFallbackFonts ) const;
virtual bool GetOutline( SalGraphics&, ::basegfx::B2DPolyPolygonVector& ) const;
// used only by OutputDevice::ImplLayout, TODO: make friend
@@ -279,8 +279,6 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& );
virtual void InitFont() const;
- virtual const PhysicalFontFace* GetFallbackFontData( sal_GlyphId ) const;
-
void SetInComplete(bool bInComplete = true);
protected:
@@ -365,7 +363,8 @@ public:
// used by display layers
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos, int&,
- sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL ) const;
+ sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const;
protected:
GenericSalLayout();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 3c7b186daec2..b8bd0bcb7b5c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7621,7 +7621,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const String& rText, bool bT
sal_Int32 pUnicodesPerGlyph[nMaxGlyphs];
int pCharPosAry[nMaxGlyphs];
sal_Int32 nAdvanceWidths[nMaxGlyphs];
- const PhysicalFontFace* pFallbackFonts[nMaxGlyphs];
+ const PhysicalFontFace* pFallbackFonts[nMaxGlyphs] = { NULL };
bool bVertical = m_aCurrentPDFState.m_aFont.IsVertical();
int nGlyphs;
int nIndex = 0;
@@ -7749,13 +7749,11 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const String& rText, bool bT
aGlyphs.reserve( nTmpMaxGlyphs );
// first get all the glyphs and register them; coordinates still in Pixel
Point aGNGlyphPos;
- while( (nGlyphs = rLayout.GetNextGlyphs( nTmpMaxGlyphs, pGlyphs, aGNGlyphPos, nIndex, nAdvanceWidths, pCharPosAry )) != 0 )
+ while( (nGlyphs = rLayout.GetNextGlyphs( nTmpMaxGlyphs, pGlyphs, aGNGlyphPos, nIndex, nAdvanceWidths, pCharPosAry, pFallbackFonts )) != 0 )
{
aUnicodes.clear();
for( int i = 0; i < nGlyphs; i++ )
{
- pFallbackFonts[i] = rLayout.GetFallbackFontData( pGlyphs[i] );
-
// default case: 1 glyph is one unicode
pUnicodesPerGlyph[i] = 1;
if( (pGlyphs[i] & GF_ISCHAR) )
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index bd7a326ef673..2340502abc55 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -866,13 +866,6 @@ bool SalLayout::IsSpacingGlyph( sal_GlyphId nGlyph ) const
return bRet;
}
-// -----------------------------------------------------------------------
-
-const PhysicalFontFace* SalLayout::GetFallbackFontData( sal_GlyphId /*nGlyphId*/ ) const
-{
- return NULL;
-}
-
// =======================================================================
GenericSalLayout::GenericSalLayout()
@@ -1353,7 +1346,8 @@ int GenericSalLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor
// -----------------------------------------------------------------------
int GenericSalLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos,
- int& nStart, sal_Int32* pGlyphAdvAry, int* pCharPosAry ) const
+ int& nStart, sal_Int32* pGlyphAdvAry, int* pCharPosAry,
+ const PhysicalFontFace** /*pFallbackFonts*/ ) const
{
GlyphVector::const_iterator pG = m_GlyphItems.begin();
GlyphVector::const_iterator pGEnd = m_GlyphItems.end();
@@ -1964,14 +1958,6 @@ void MultiSalLayout::InitFont() const
// -----------------------------------------------------------------------
-const PhysicalFontFace* MultiSalLayout::GetFallbackFontData( sal_GlyphId nGlyphId ) const
-{
- int nFallbackLevel = (nGlyphId & GF_FONTMASK) >> GF_FONTSHIFT;
- return mpFallbackFonts[ nFallbackLevel ];
-}
-
-// -----------------------------------------------------------------------
-
void MultiSalLayout::DrawText( SalGraphics& rGraphics ) const
{
for( int i = mnLevel; --i >= 0; )
@@ -2103,7 +2089,8 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray )
// -----------------------------------------------------------------------
int MultiSalLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos,
- int& nStart, sal_Int32* pGlyphAdvAry, int* pCharPosAry ) const
+ int& nStart, sal_Int32* pGlyphAdvAry, int* pCharPosAry,
+ const PhysicalFontFace** pFallbackFonts ) const
{
// for multi-level fallback only single glyphs should be used
if( mnLevel > 1 && nLen > 1 )
@@ -2133,6 +2120,10 @@ int MultiSalLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& r
pGlyphAdvAry[i] = w;
}
pGlyphIdxAry[ i ] |= nFontTag;
+ if( pFallbackFonts )
+ {
+ pFallbackFonts[ i ] = mpFallbackFonts[ nLevel ];
+ }
}
rPos += maDrawBase;
rPos += maDrawOffset;
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index 3898ab1c7fdd..034842afdd21 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -1209,7 +1209,8 @@ void GraphiteLayout::GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray
// The logic in this method must match that expected in MultiSalLayout which
// is used when glyph fallback is in operation.
int GraphiteLayout::GetNextGlyphs( int length, sal_GlyphId * glyph_out,
- ::Point & aPosOut, int &glyph_slot, sal_Int32 * glyph_adv, int *char_index) const
+ ::Point & aPosOut, int &glyph_slot, sal_Int32 * glyph_adv, int *char_index,
+ const PhysicalFontFace** /*pFallbackFonts*/ ) const
{
// Sanity check on the slot index.
if (glyph_slot >= signed(mvGlyphs.size()))
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 41271b02c954..174539c2ec99 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -154,7 +154,8 @@ public:
virtual void DrawText( SalGraphics& ) const;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
+ sal_Int32* pGlyphAdvances, int* pCharIndexes,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual long FillDXArray( long* pDXArray ) const;
virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
@@ -532,7 +533,8 @@ bool SimpleWinLayout::LayoutText( ImplLayoutArgs& rArgs )
// -----------------------------------------------------------------------
int SimpleWinLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int& nStart,
- long* pGlyphAdvances, int* pCharIndexes ) const
+ long* pGlyphAdvances, int* pCharIndexes,
+ const PhysicalFontFace** /*pFallbackFonts*/ ) const
{
// return zero if no more glyph found
if( nStart >= mnGlyphCount )
@@ -1004,7 +1006,8 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& );
virtual void DrawText( SalGraphics& ) const;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
- sal_Int32* pGlyphAdvances, int* pCharPosAry ) const;
+ sal_Int32* pGlyphAdvances, int* pCharPosAry,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual long FillDXArray( long* pDXArray ) const;
virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
@@ -1631,7 +1634,8 @@ bool UniscribeLayout::GetItemSubrange( const VisualItem& rVisualItem,
// -----------------------------------------------------------------------
int UniscribeLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos,
- int& nStartx8, sal_Int32* pGlyphAdvances, int* pCharPosAry ) const
+ int& nStartx8, sal_Int32* pGlyphAdvances, int* pCharPosAry,
+ const PhysicalFontFace** /*pFallbackFonts*/ ) const
{
// HACK to allow fake-glyph insertion (e.g. for kashidas)
// TODO: use iterator idiom instead of GetNextGlyphs(...)
@@ -2713,7 +2717,8 @@ public:
// methods using glyph indexing
virtual int GetNextGlyphs(int nLen, sal_GlyphId* pGlyphIdxAry, ::Point & rPos, int&,
- long* pGlyphAdvAry = 0, int* pCharPosAry = 0 ) const;
+ long* pGlyphAdvAry = NULL, int* pCharPosAry = NULL,
+ const PhysicalFontFace** pFallbackFonts = NULL ) const;
// used by glyph+font+script fallback
virtual void MoveGlyph( int nStart, long nNewXPos );
@@ -2858,11 +2863,12 @@ void GraphiteWinLayout::GetCaretPositions( int nArraySize, long* pCaretXArray )
}
int GraphiteWinLayout::GetNextGlyphs( int length, sal_GlyphId* glyph_out,
- ::Point & pos_out, int &glyph_slot, long * glyph_adv, int *char_index) const
+ ::Point & pos_out, int &glyph_slot, long * glyph_adv, int *char_index,
+ const PhysicalFontFace** pFallbackFonts ) const
{
maImpl.DrawBase() = WinLayout::maDrawBase;
maImpl.DrawOffset() = WinLayout::maDrawOffset;
- return maImpl.GetNextGlyphs(length, glyph_out, pos_out, glyph_slot, glyph_adv, char_index);
+ return maImpl.GetNextGlyphs(length, glyph_out, pos_out, glyph_slot, glyph_adv, char_index, pFallbackFonts);
}
void GraphiteWinLayout::MoveGlyph( int glyph_idx, long new_x_pos )