svptext.cxx (75c24b65) svptext.cxx (248a599f)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 38 unchanged lines hidden (view full) ---

47// ===========================================================================
48
49class SvpGlyphPeer
50: public GlyphCachePeer
51{
52public:
53 SvpGlyphPeer() {}
54
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 38 unchanged lines hidden (view full) ---

47// ===========================================================================
48
49class SvpGlyphPeer
50: public GlyphCachePeer
51{
52public:
53 SvpGlyphPeer() {}
54
55 BitmapDeviceSharedPtr GetGlyphBmp( ServerFont&, int nGlyphIndex,
55 BitmapDeviceSharedPtr GetGlyphBmp( ServerFont&, sal_GlyphId,
56 sal_uInt32 nBmpFormat, B2IPoint& rTargetPos );
57
58protected:
59 virtual void RemovingFont( ServerFont& );
56 sal_uInt32 nBmpFormat, B2IPoint& rTargetPos );
57
58protected:
59 virtual void RemovingFont( ServerFont& );
60 virtual void RemovingGlyph( ServerFont&, GlyphData&, int nGlyphIndex );
60 virtual void RemovingGlyph( ServerFont&, GlyphData&, sal_GlyphId );
61
62 class SvpGcpHelper
63 {
64 public:
65 RawBitmap maRawBitmap;
66 BitmapDeviceSharedPtr maBitmapDev;
67 };
68};

--- 16 unchanged lines hidden (view full) ---

85 static SvpGlyphPeer aSvpGlyphPeer;
86 static SvpGlyphCache aGC( aSvpGlyphPeer );
87 return aGC;
88}
89
90// ===========================================================================
91
92BitmapDeviceSharedPtr SvpGlyphPeer::GetGlyphBmp( ServerFont& rServerFont,
61
62 class SvpGcpHelper
63 {
64 public:
65 RawBitmap maRawBitmap;
66 BitmapDeviceSharedPtr maBitmapDev;
67 };
68};

--- 16 unchanged lines hidden (view full) ---

85 static SvpGlyphPeer aSvpGlyphPeer;
86 static SvpGlyphCache aGC( aSvpGlyphPeer );
87 return aGC;
88}
89
90// ===========================================================================
91
92BitmapDeviceSharedPtr SvpGlyphPeer::GetGlyphBmp( ServerFont& rServerFont,
93 int nGlyphIndex, sal_uInt32 nBmpFormat, B2IPoint& rTargetPos )
93 sal_GlyphId aGlyphId, sal_uInt32 nBmpFormat, B2IPoint& rTargetPos )
94{
94{
95 GlyphData& rGlyphData = rServerFont.GetGlyphData( nGlyphIndex );
95 GlyphData& rGlyphData = rServerFont.GetGlyphData( aGlyphId );
96 SvpGcpHelper* pGcpHelper = (SvpGcpHelper*)rGlyphData.ExtDataRef().mpData;
97
98 // nothing to do if the GlyphPeer hasn't allocated resources for the glyph
99 if( rGlyphData.ExtDataRef().meInfo != sal::static_int_cast<int>(nBmpFormat) )
100 {
101 if( rGlyphData.ExtDataRef().meInfo == Format::NONE )
102 pGcpHelper = new SvpGcpHelper;
103 RawBitmap& rRawBitmap = pGcpHelper->maRawBitmap;
104
105 // get glyph bitmap in matching format
106 bool bFound = false;
107 switch( nBmpFormat )
108 {
109 case Format::ONE_BIT_LSB_GREY:
96 SvpGcpHelper* pGcpHelper = (SvpGcpHelper*)rGlyphData.ExtDataRef().mpData;
97
98 // nothing to do if the GlyphPeer hasn't allocated resources for the glyph
99 if( rGlyphData.ExtDataRef().meInfo != sal::static_int_cast<int>(nBmpFormat) )
100 {
101 if( rGlyphData.ExtDataRef().meInfo == Format::NONE )
102 pGcpHelper = new SvpGcpHelper;
103 RawBitmap& rRawBitmap = pGcpHelper->maRawBitmap;
104
105 // get glyph bitmap in matching format
106 bool bFound = false;
107 switch( nBmpFormat )
108 {
109 case Format::ONE_BIT_LSB_GREY:
110 bFound = rServerFont.GetGlyphBitmap1( nGlyphIndex, pGcpHelper->maRawBitmap );
110 bFound = rServerFont.GetGlyphBitmap1( aGlyphId, pGcpHelper->maRawBitmap );
111 break;
112 case Format::EIGHT_BIT_GREY:
111 break;
112 case Format::EIGHT_BIT_GREY:
113 bFound = rServerFont.GetGlyphBitmap8( nGlyphIndex, pGcpHelper->maRawBitmap );
113 bFound = rServerFont.GetGlyphBitmap8( aGlyphId, pGcpHelper->maRawBitmap );
114 break;
115 default:
116 DBG_ERROR( "SVP GCP::GetGlyphBmp(): illegal scanline format");
117 // fall back to black&white mask
118 nBmpFormat = Format::ONE_BIT_LSB_GREY;
119 bFound = false;
120 break;
121 }
122
123 // return .notdef glyph if needed
114 break;
115 default:
116 DBG_ERROR( "SVP GCP::GetGlyphBmp(): illegal scanline format");
117 // fall back to black&white mask
118 nBmpFormat = Format::ONE_BIT_LSB_GREY;
119 bFound = false;
120 break;
121 }
122
123 // return .notdef glyph if needed
124 if( !bFound && (nGlyphIndex != 0) )
124 if( !bFound && (aGlyphId != 0) )
125 {
126 delete pGcpHelper;
127 return GetGlyphBmp( rServerFont, 0, nBmpFormat, rTargetPos );
128 }
129
130 // construct alpha mask from raw bitmap
131 const B2IVector aSize( rRawBitmap.mnScanlineSize, rRawBitmap.mnHeight );
132 if( aSize.getX() && aSize.getY() )

--- 14 unchanged lines hidden (view full) ---

147
148void SvpGlyphPeer::RemovingFont( ServerFont& )
149{
150 // nothing to do: no font resources held in SvpGlyphPeer
151}
152
153//--------------------------------------------------------------------------
154
125 {
126 delete pGcpHelper;
127 return GetGlyphBmp( rServerFont, 0, nBmpFormat, rTargetPos );
128 }
129
130 // construct alpha mask from raw bitmap
131 const B2IVector aSize( rRawBitmap.mnScanlineSize, rRawBitmap.mnHeight );
132 if( aSize.getX() && aSize.getY() )

--- 14 unchanged lines hidden (view full) ---

147
148void SvpGlyphPeer::RemovingFont( ServerFont& )
149{
150 // nothing to do: no font resources held in SvpGlyphPeer
151}
152
153//--------------------------------------------------------------------------
154
155void SvpGlyphPeer::RemovingGlyph( ServerFont&, GlyphData& rGlyphData, int /*nGlyphIndex*/ )
155void SvpGlyphPeer::RemovingGlyph( ServerFont&, GlyphData& rGlyphData, sal_GlyphId /*aGlyphId*/ )
156{
157 if( rGlyphData.ExtDataRef().mpData != Format::NONE )
158 {
159 // release the glyph related resources
160 DBG_ASSERT( (rGlyphData.ExtDataRef().meInfo <= Format::MAX), "SVP::RG() invalid alpha format" );
161 SvpGcpHelper* pGcpHelper = (SvpGcpHelper*)rGlyphData.ExtDataRef().mpData;
162 delete[] pGcpHelper->maRawBitmap.mpBits;
163 delete pGcpHelper;

--- 169 unchanged lines hidden (view full) ---

333 return false;
334}
335
336// ---------------------------------------------------------------------------
337
338sal_Bool SvpSalGraphics::CreateFontSubset(
339 const rtl::OUString& rToFile,
340 const ImplFontData* pFont,
156{
157 if( rGlyphData.ExtDataRef().mpData != Format::NONE )
158 {
159 // release the glyph related resources
160 DBG_ASSERT( (rGlyphData.ExtDataRef().meInfo <= Format::MAX), "SVP::RG() invalid alpha format" );
161 SvpGcpHelper* pGcpHelper = (SvpGcpHelper*)rGlyphData.ExtDataRef().mpData;
162 delete[] pGcpHelper->maRawBitmap.mpBits;
163 delete pGcpHelper;

--- 169 unchanged lines hidden (view full) ---

333 return false;
334}
335
336// ---------------------------------------------------------------------------
337
338sal_Bool SvpSalGraphics::CreateFontSubset(
339 const rtl::OUString& rToFile,
340 const ImplFontData* pFont,
341 sal_Int32* pGlyphIDs,
341 sal_GlyphId* pGlyphIds,
342 sal_uInt8* pEncoding,
343 sal_Int32* pWidths,
344 int nGlyphCount,
345 FontSubsetInfo& rInfo
346 )
347{
348 // in this context the pFont->GetFontId() is a valid PSP
349 // font since they are the only ones left after the PDF
350 // export has filtered its list of subsettable fonts (for
351 // which this method was created). The correct way would
352 // be to have the GlyphCache search for the ImplFontData pFont
353 psp::fontID aFont = pFont->GetFontId();
354
355 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
356 bool bSuccess = rMgr.createFontSubset( rInfo,
357 aFont,
358 rToFile,
342 sal_uInt8* pEncoding,
343 sal_Int32* pWidths,
344 int nGlyphCount,
345 FontSubsetInfo& rInfo
346 )
347{
348 // in this context the pFont->GetFontId() is a valid PSP
349 // font since they are the only ones left after the PDF
350 // export has filtered its list of subsettable fonts (for
351 // which this method was created). The correct way would
352 // be to have the GlyphCache search for the ImplFontData pFont
353 psp::fontID aFont = pFont->GetFontId();
354
355 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
356 bool bSuccess = rMgr.createFontSubset( rInfo,
357 aFont,
358 rToFile,
359 pGlyphIDs,
359 pGlyphIds,
360 pEncoding,
361 pWidths,
362 nGlyphCount );
363 return bSuccess;
364}
365
366// ---------------------------------------------------------------------------
367

--- 45 unchanged lines hidden (view full) ---

413 // which this method was created). The correct way would
414 // be to have the GlyphCache search for the ImplFontData pFont
415 psp::fontID aFont = pFont->GetFontId();
416 PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
417}
418
419// ---------------------------------------------------------------------------
420
360 pEncoding,
361 pWidths,
362 nGlyphCount );
363 return bSuccess;
364}
365
366// ---------------------------------------------------------------------------
367

--- 45 unchanged lines hidden (view full) ---

413 // which this method was created). The correct way would
414 // be to have the GlyphCache search for the ImplFontData pFont
415 psp::fontID aFont = pFont->GetFontId();
416 PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
417}
418
419// ---------------------------------------------------------------------------
420
421sal_Bool SvpSalGraphics::GetGlyphBoundRect( long nGlyphIndex, Rectangle& rRect )
421bool SvpSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect )
422{
422{
423 int nLevel = nGlyphIndex >> GF_FONTSHIFT;
423 const int nLevel = aGlyphId >> GF_FONTSHIFT;
424 if( nLevel >= MAX_FALLBACK )
424 if( nLevel >= MAX_FALLBACK )
425 return sal_False;
425 return false;
426
427 ServerFont* pSF = m_pServerFont[ nLevel ];
428 if( !pSF )
426
427 ServerFont* pSF = m_pServerFont[ nLevel ];
428 if( !pSF )
429 return sal_False;
429 return false;
430
430
431 nGlyphIndex &= ~GF_FONTMASK;
432 const GlyphMetric& rGM = pSF->GetGlyphMetric( nGlyphIndex );
431 aGlyphId &= ~GF_FONTMASK;
432 const GlyphMetric& rGM = pSF->GetGlyphMetric( aGlyphId );
433 rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
433 rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
434 return sal_True;
434 return true;
435}
436
437// ---------------------------------------------------------------------------
438
435}
436
437// ---------------------------------------------------------------------------
438
439sal_Bool SvpSalGraphics::GetGlyphOutline( long nGlyphIndex, B2DPolyPolygon& rPolyPoly )
439bool SvpSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, B2DPolyPolygon& rPolyPoly )
440{
440{
441 int nLevel = nGlyphIndex >> GF_FONTSHIFT;
441 const int nLevel = aGlyphId >> GF_FONTSHIFT;
442 if( nLevel >= MAX_FALLBACK )
442 if( nLevel >= MAX_FALLBACK )
443 return sal_False;
443 return false;
444
445 const ServerFont* pSF = m_pServerFont[ nLevel ];
446 if( !pSF )
444
445 const ServerFont* pSF = m_pServerFont[ nLevel ];
446 if( !pSF )
447 return sal_False;
447 return false;
448
448
449 nGlyphIndex &= ~GF_FONTMASK;
450 if( pSF->GetGlyphOutline( nGlyphIndex, rPolyPoly ) )
451 return sal_True;
452
453 return sal_False;
449 aGlyphId &= ~GF_FONTMASK;
450 bool bOK = pSF->GetGlyphOutline( aGlyphId, rPolyPoly );
451 return bOK;
454}
455
456// ---------------------------------------------------------------------------
457
458SalLayout* SvpSalGraphics::GetTextLayout( ImplLayoutArgs&, int nFallbackLevel )
459{
460 GenericSalLayout* pLayout = NULL;
461

--- 4 unchanged lines hidden (view full) ---

466}
467
468// ---------------------------------------------------------------------------
469
470void SvpSalGraphics::DrawServerFontLayout( const ServerFontLayout& rSalLayout )
471{
472 // iterate over all glyphs in the layout
473 Point aPos;
452}
453
454// ---------------------------------------------------------------------------
455
456SalLayout* SvpSalGraphics::GetTextLayout( ImplLayoutArgs&, int nFallbackLevel )
457{
458 GenericSalLayout* pLayout = NULL;
459

--- 4 unchanged lines hidden (view full) ---

464}
465
466// ---------------------------------------------------------------------------
467
468void SvpSalGraphics::DrawServerFontLayout( const ServerFontLayout& rSalLayout )
469{
470 // iterate over all glyphs in the layout
471 Point aPos;
474 sal_GlyphId nGlyphIndex;
472 sal_GlyphId aGlyphId;
475 SvpGlyphPeer& rGlyphPeer = SvpGlyphCache::GetInstance().GetPeer();
473 SvpGlyphPeer& rGlyphPeer = SvpGlyphCache::GetInstance().GetPeer();
476 for( int nStart = 0; rSalLayout.GetNextGlyphs( 1, &nGlyphIndex, aPos, nStart ); )
474 for( int nStart = 0; rSalLayout.GetNextGlyphs( 1, &aGlyphId, aPos, nStart ); )
477 {
475 {
478 int nLevel = nGlyphIndex >> GF_FONTSHIFT;
476 int nLevel = aGlyphId >> GF_FONTSHIFT;
479 DBG_ASSERT( nLevel < MAX_FALLBACK, "SvpGDI: invalid glyph fallback level" );
480 ServerFont* pSF = m_pServerFont[ nLevel ];
481 if( !pSF )
482 continue;
483
484 // get the glyph's alpha mask and adjust the drawing position
477 DBG_ASSERT( nLevel < MAX_FALLBACK, "SvpGDI: invalid glyph fallback level" );
478 ServerFont* pSF = m_pServerFont[ nLevel ];
479 if( !pSF )
480 continue;
481
482 // get the glyph's alpha mask and adjust the drawing position
485 nGlyphIndex &= ~GF_FONTMASK;
483 aGlyphId &= ~GF_FONTMASK;
486 B2IPoint aDstPoint( aPos.X(), aPos.Y() );
487 BitmapDeviceSharedPtr aAlphaMask
484 B2IPoint aDstPoint( aPos.X(), aPos.Y() );
485 BitmapDeviceSharedPtr aAlphaMask
488 = rGlyphPeer.GetGlyphBmp( *pSF, nGlyphIndex, m_eTextFmt, aDstPoint );
486 = rGlyphPeer.GetGlyphBmp( *pSF, aGlyphId, m_eTextFmt, aDstPoint );
489 if( !aAlphaMask ) // ignore empty glyphs
490 continue;
491
492 // blend text color into target using the glyph's mask
493 const B2IRange aSrcRect( B2ITuple(0,0), aAlphaMask->getSize() );
494 m_aDevice->drawMaskedColor( m_aTextColor, aAlphaMask, aSrcRect, aDstPoint, m_aClipMap );
495 }
496}
497
498// ===========================================================================
487 if( !aAlphaMask ) // ignore empty glyphs
488 continue;
489
490 // blend text color into target using the glyph's mask
491 const B2IRange aSrcRect( B2ITuple(0,0), aAlphaMask->getSize() );
492 m_aDevice->drawMaskedColor( m_aTextColor, aAlphaMask, aSrcRect, aDstPoint, m_aClipMap );
493 }
494}
495
496// ===========================================================================