summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-11-24 09:21:56 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-18 01:08:18 -0500
commit1b8c37b52eef96a4ad97234d1c0eeeb13a21361c (patch)
treec09f5ceba67439270ed8dcb4ea9d2fb49caf8385
parent81410c291a6d4de5093a5f8366f83a92ab02a7f2 (diff)
Kill PspFontLayout
It should never get used any way. CairoTextRender::GetTextLayout() returns nullptr for the unlikely even that there is no Freetypefont for the requested fallback level, so we do the same. Change-Id: Ib990eb89f9f0fd2bcd87990cbd76406c8d063f57 Reviewed-on: https://gerrit.libreoffice.org/31225 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> (cherry picked from commit 368de904974b18dc5a8d237e046c0ed005f7c85d) (cherry picked from commit 3da7104c775721e42da231664d3758da595215dd)
-rw-r--r--vcl/inc/unx/printergfx.hxx3
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx111
-rw-r--r--vcl/unx/generic/print/text_gfx.cxx22
3 files changed, 5 insertions, 131 deletions
diff --git a/vcl/inc/unx/printergfx.hxx b/vcl/inc/unx/printergfx.hxx
index f0bb53f34019..84c2e6be225e 100644
--- a/vcl/inc/unx/printergfx.hxx
+++ b/vcl/inc/unx/printergfx.hxx
@@ -365,8 +365,7 @@ public:
const sal_Int32* pDeltaArray);
void SetTextColor (PrinterColor& rTextColor)
{ maTextColor = rTextColor; }
- sal_Int32 GetCharWidth (sal_uInt16 nFrom, sal_uInt16 nTo,
- long *pWidthArray);
+
// for CTL
void DrawGlyphs( const Point& rPoint,
sal_GlyphId* pGlyphIds,
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index a266770c11cb..e88c52dbf3be 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -553,93 +553,6 @@ LogicalFontInstance* ImplPspFontData::CreateFontInstance( FontSelectPattern& rFS
return pEntry;
}
-class PspFontLayout : public GenericSalLayout
-{
-public:
- explicit PspFontLayout( ::psp::PrinterGfx& );
- virtual bool LayoutText( ImplLayoutArgs& ) override;
- virtual void InitFont() const override;
- virtual void DrawText( SalGraphics& ) const override;
-private:
- ::psp::PrinterGfx& mrPrinterGfx;
- sal_IntPtr mnFontID;
- int mnFontHeight;
- int mnFontWidth;
- bool mbVertical;
- bool mbArtItalic;
- bool mbArtBold;
-};
-
-PspFontLayout::PspFontLayout( ::psp::PrinterGfx& rGfx )
-: mrPrinterGfx( rGfx )
-{
- mnFontID = mrPrinterGfx.GetFontID();
- mnFontHeight = mrPrinterGfx.GetFontHeight();
- mnFontWidth = mrPrinterGfx.GetFontWidth();
- mbVertical = mrPrinterGfx.GetFontVertical();
- mbArtItalic = mrPrinterGfx.GetArtificialItalic();
- mbArtBold = mrPrinterGfx.GetArtificialBold();
-}
-
-bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs )
-{
- mbVertical = bool(rArgs.mnFlags & SalLayoutFlags::Vertical);
-
- long nUnitsPerPixel = 1;
- sal_GlyphId aOldGlyphId( GF_DROPPED);
- long nGlyphWidth = 0;
- int nCharPos = -1;
- Point aNewPos( 0, 0 );
- GlyphItem aPrevItem;
- rtl_TextEncoding aFontEnc = mrPrinterGfx.GetFontMgr().getFontEncoding( mnFontID );
- const int nLength = rArgs.mrStr.getLength();
- const sal_Unicode *pStr = rArgs.mrStr.getStr();
- Reserve(nLength);
-
- for(;;)
- {
- bool bRightToLeft;
- if( !rArgs.GetNextPos( &nCharPos, &bRightToLeft ) )
- break;
-
- sal_Unicode cChar = pStr[ nCharPos ];
- if( bRightToLeft )
- cChar = GetMirroredChar( cChar );
- // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff
- if( aFontEnc == RTL_TEXTENCODING_SYMBOL )
- if( cChar < 256 )
- cChar += 0xf000;
- sal_GlyphId aGlyphId( cChar); // printer glyphs = unicode
-
- // update fallback_runs if needed
- psp::CharacterMetric aMetric;
- // coverity[callee_ptr_arith]
- mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical );
- if( aMetric.width == -1 && aMetric.height == -1 )
- rArgs.NeedFallback( nCharPos, bRightToLeft );
-
- // finish previous glyph
- if( aOldGlyphId != GF_DROPPED )
- AppendGlyph( aPrevItem );
- aOldGlyphId = aGlyphId;
- aNewPos.X() += nGlyphWidth;
-
- // prepare GlyphItem for appending it in next round
- nUnitsPerPixel = mrPrinterGfx.GetCharWidth( cChar, cChar, &nGlyphWidth );
- int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
- aGlyphId |= GF_ISCHAR;
- aPrevItem = GlyphItem( nCharPos, aGlyphId, aNewPos, nGlyphFlags, nGlyphWidth );
- }
-
- // append last glyph item if any
- if( aOldGlyphId != GF_DROPPED )
- AppendGlyph( aPrevItem );
-
- SetOrientation( mrPrinterGfx.GetFontAngle() );
- SetUnitsPerPixel( nUnitsPerPixel );
- return (aOldGlyphId != GF_DROPPED);
-}
-
class PspCommonSalLayout : public CommonSalLayout
{
public:
@@ -676,7 +589,7 @@ void PspCommonSalLayout::InitFont() const
mnOrientation, mbVertical, mbArtItalic, mbArtBold);
}
-static void DrawPrinterLayout( const SalLayout& rLayout, ::psp::PrinterGfx& rGfx)
+void GenPspGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
{
const int nMaxGlyphs = 1;
sal_GlyphId aGlyphAry[ nMaxGlyphs ];
@@ -709,26 +622,10 @@ static void DrawPrinterLayout( const SalLayout& rLayout, ::psp::PrinterGfx& rGfx
aGlyphAry[i] = aGlyphId;
}
- rGfx.DrawGlyphs( aPos, aGlyphAry, aUnicodes, nGlyphCount, aIdxAry );
+ m_pPrinterGfx->DrawGlyphs( aPos, aGlyphAry, aUnicodes, nGlyphCount, aIdxAry );
}
}
-void PspFontLayout::InitFont() const
-{
- mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth,
- mnOrientation, mbVertical, mbArtItalic, mbArtBold );
-}
-
-void PspFontLayout::DrawText( SalGraphics& ) const
-{
- DrawPrinterLayout(*this, mrPrinterGfx);
-}
-
-void GenPspGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
-{
- DrawPrinterLayout(rLayout, *m_pPrinterGfx);
-}
-
const FontCharMapRef GenPspGraphics::GetFontCharMap() const
{
if( !m_pFreetypeFont[0] )
@@ -944,8 +841,8 @@ SalLayout* GenPspGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbac
{
if (m_pFreetypeFont[nFallbackLevel])
return new PspCommonSalLayout(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]);
- else
- return new PspFontLayout(*m_pPrinterGfx);
+
+ return nullptr;
}
bool GenPspGraphics::CreateFontSubset(
diff --git a/vcl/unx/generic/print/text_gfx.cxx b/vcl/unx/generic/print/text_gfx.cxx
index bf4d4a830520..12f23fd05956 100644
--- a/vcl/unx/generic/print/text_gfx.cxx
+++ b/vcl/unx/generic/print/text_gfx.cxx
@@ -594,28 +594,6 @@ PrinterGfx::getCharMetric (const Font2 &rFont, sal_Unicode n_char, CharacterMetr
return rFont.GetFont(0) != -1 ? rFont.GetFont(0) : rFont.GetFont(1);
}
-sal_Int32
-PrinterGfx::GetCharWidth (sal_uInt16 nFrom, sal_uInt16 nTo, long *pWidthArray)
-{
- Font2 aFont(*this);
- if (aFont.IsSymbolFont() && (nFrom < 256) && (nTo < 256))
- {
- nFrom += 0xF000;
- nTo += 0xF000;
- }
-
- for( int n = 0; n < (nTo - nFrom + 1); n++ )
- {
- CharacterMetric aBBox;
- // coverity[callee_ptr_arith]
- getCharMetric(aFont, n + nFrom, &aBBox);
- pWidthArray[n] = getCharWidth (mbTextVertical, n + nFrom, &aBBox);
- }
-
- // returned metrics have postscript precision
- return 1000;
-}
-
/*
* spool the converted truetype fonts to the page header after the page body is
* complete