svppspgraphics.cxx (5f27b83c) svppspgraphics.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

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

559
560 sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
561 if( bRightToLeft )
562 cChar = GetMirroredChar( cChar );
563 // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff
564 if( aFontEnc == RTL_TEXTENCODING_SYMBOL )
565 if( cChar < 256 )
566 cChar += 0xf000;
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

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

559
560 sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
561 if( bRightToLeft )
562 cChar = GetMirroredChar( cChar );
563 // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff
564 if( aFontEnc == RTL_TEXTENCODING_SYMBOL )
565 if( cChar < 256 )
566 cChar += 0xf000;
567 int nGlyphIndex = cChar; // printer glyphs = unicode
567 sal_GlyphId aGlyphId( cChar); // printer glyphs = unicode
568
569 // update fallback_runs if needed
570 psp::CharacterMetric aMetric;
571 mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical );
572 if( aMetric.width == -1 && aMetric.height == -1 )
573 rArgs.NeedFallback( nCharPos, bRightToLeft );
574
575 // apply pair kerning to prev glyph if requested
576 if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags )
577 {
578 if( nOldGlyphId > 0 )
579 {
580 const std::list< KernPair >& rKernPairs = mrPrinterGfx.getKernPairs(mbVertical);
581 for( std::list< KernPair >::const_iterator it = rKernPairs.begin();
582 it != rKernPairs.end(); ++it )
583 {
568
569 // update fallback_runs if needed
570 psp::CharacterMetric aMetric;
571 mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical );
572 if( aMetric.width == -1 && aMetric.height == -1 )
573 rArgs.NeedFallback( nCharPos, bRightToLeft );
574
575 // apply pair kerning to prev glyph if requested
576 if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags )
577 {
578 if( nOldGlyphId > 0 )
579 {
580 const std::list< KernPair >& rKernPairs = mrPrinterGfx.getKernPairs(mbVertical);
581 for( std::list< KernPair >::const_iterator it = rKernPairs.begin();
582 it != rKernPairs.end(); ++it )
583 {
584 if( it->first == nOldGlyphId && it->second == nGlyphIndex )
584 if( it->first == nOldGlyphId && it->second == aGlyphId )
585 {
586 int nTextScale = mrPrinterGfx.GetFontWidth();
587 if( ! nTextScale )
588 nTextScale = mrPrinterGfx.GetFontHeight();
589 int nKern = (mbVertical ? it->kern_y : it->kern_x) * nTextScale;
590 nGlyphWidth += nKern;
591 aPrevItem.mnNewWidth = nGlyphWidth;
592 break;
593 }
594 }
595 }
596 }
597
598 // finish previous glyph
599 if( nOldGlyphId >= 0 )
600 AppendGlyph( aPrevItem );
585 {
586 int nTextScale = mrPrinterGfx.GetFontWidth();
587 if( ! nTextScale )
588 nTextScale = mrPrinterGfx.GetFontHeight();
589 int nKern = (mbVertical ? it->kern_y : it->kern_x) * nTextScale;
590 nGlyphWidth += nKern;
591 aPrevItem.mnNewWidth = nGlyphWidth;
592 break;
593 }
594 }
595 }
596 }
597
598 // finish previous glyph
599 if( nOldGlyphId >= 0 )
600 AppendGlyph( aPrevItem );
601 nOldGlyphId = nGlyphIndex;
601 nOldGlyphId = aGlyphId;
602 aNewPos.X() += nGlyphWidth;
603
604 // prepare GlyphItem for appending it in next round
605 nUnitsPerPixel = mrPrinterGfx.GetCharWidth( cChar, cChar, &nGlyphWidth );
606 int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
602 aNewPos.X() += nGlyphWidth;
603
604 // prepare GlyphItem for appending it in next round
605 nUnitsPerPixel = mrPrinterGfx.GetCharWidth( cChar, cChar, &nGlyphWidth );
606 int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
607 nGlyphIndex |= GF_ISCHAR;
608 aPrevItem = GlyphItem( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
607 aGlyphId |= GF_ISCHAR;
608 aPrevItem = GlyphItem( nCharPos, aGlyphId, aNewPos, nGlyphFlags, nGlyphWidth );
609 }
610
611 // append last glyph item if any
612 if( nOldGlyphId >= 0 )
613 AppendGlyph( aPrevItem );
614
615 SetOrientation( mrPrinterGfx.GetFontAngle() );
616 SetUnitsPerPixel( nUnitsPerPixel );

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

680 if( !nGlyphCount )
681 break;
682
683 sal_Int32 nXOffset = 0;
684 for( int i = 0; i < nGlyphCount; ++i )
685 {
686 nXOffset += aWidthAry[ i ];
687 aIdxAry[ i ] = nXOffset / nUnitsPerPixel;
609 }
610
611 // append last glyph item if any
612 if( nOldGlyphId >= 0 )
613 AppendGlyph( aPrevItem );
614
615 SetOrientation( mrPrinterGfx.GetFontAngle() );
616 SetUnitsPerPixel( nUnitsPerPixel );

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

680 if( !nGlyphCount )
681 break;
682
683 sal_Int32 nXOffset = 0;
684 for( int i = 0; i < nGlyphCount; ++i )
685 {
686 nXOffset += aWidthAry[ i ];
687 aIdxAry[ i ] = nXOffset / nUnitsPerPixel;
688 sal_Int32 nGlyphIdx = aGlyphAry[i] & (GF_IDXMASK | GF_ROTMASK);
688 sal_GlyphId aGlyphId = aGlyphAry[i] & (GF_IDXMASK | GF_ROTMASK);
689 if( bIsPspServerFontLayout )
690 aUnicodes[i] = (aCharPosAry[i] >= nMinCharPos && aCharPosAry[i] <= nMaxCharPos) ? pText[ aCharPosAry[i] ] : 0;
691 else
689 if( bIsPspServerFontLayout )
690 aUnicodes[i] = (aCharPosAry[i] >= nMinCharPos && aCharPosAry[i] <= nMaxCharPos) ? pText[ aCharPosAry[i] ] : 0;
691 else
692 aUnicodes[i] = (aGlyphAry[i] & GF_ISCHAR) ? nGlyphIdx : 0;
693 aGlyphAry[i] = nGlyphIdx;
692 aUnicodes[i] = (aGlyphAry[i] & GF_ISCHAR) ? aGlyphId : 0;
693 aGlyphAry[i] = aGlyphId;
694 }
695
694 }
695
696 rGfx.DrawGlyphs( aPos, (sal_uInt32 *)aGlyphAry, aUnicodes, nGlyphCount, aIdxAry );
696 rGfx.DrawGlyphs( aPos, aGlyphAry, aUnicodes, nGlyphCount, aIdxAry );
697 }
698}
699
700//--------------------------------------------------------------------------
701
702void PspFontLayout::InitFont() const
703{
704 mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth,

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

869 pKernPairs[i].mnChar2 = it->second;
870 pKernPairs[i].mnKern = it->kern_x * nTextScale / 1000;
871 }
872
873 }
874 return nHavePairs;
875}
876
697 }
698}
699
700//--------------------------------------------------------------------------
701
702void PspFontLayout::InitFont() const
703{
704 mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth,

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

869 pKernPairs[i].mnChar2 = it->second;
870 pKernPairs[i].mnKern = it->kern_x * nTextScale / 1000;
871 }
872
873 }
874 return nHavePairs;
875}
876
877sal_Bool PspGraphics::GetGlyphBoundRect( long nGlyphIndex, Rectangle& rRect )
877bool PspGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect )
878{
878{
879 int nLevel = nGlyphIndex >> GF_FONTSHIFT;
879 const int nLevel = aGlyphId >> GF_FONTSHIFT;
880 if( nLevel >= MAX_FALLBACK )
880 if( nLevel >= MAX_FALLBACK )
881 return sal_False;
881 return false;
882
883 ServerFont* pSF = m_pServerFont[ nLevel ];
884 if( !pSF )
882
883 ServerFont* pSF = m_pServerFont[ nLevel ];
884 if( !pSF )
885 return sal_False;
885 return false;
886
886
887 nGlyphIndex &= ~GF_FONTMASK;
888 const GlyphMetric& rGM = pSF->GetGlyphMetric( nGlyphIndex );
887 aGlyphId &= ~GF_FONTMASK;
888 const GlyphMetric& rGM = pSF->GetGlyphMetric( aGlyphId );
889 rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
889 rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
890 return sal_True;
890 return true;
891}
892
891}
892
893sal_Bool PspGraphics::GetGlyphOutline( long nGlyphIndex,
893bool PspGraphics::GetGlyphOutline( sal_GlyphId aGlyphId,
894 ::basegfx::B2DPolyPolygon& rB2DPolyPoly )
895{
894 ::basegfx::B2DPolyPolygon& rB2DPolyPoly )
895{
896 int nLevel = nGlyphIndex >> GF_FONTSHIFT;
896 const int nLevel = aGlyphId >> GF_FONTSHIFT;
897 if( nLevel >= MAX_FALLBACK )
898 return sal_False;
899
900 ServerFont* pSF = m_pServerFont[ nLevel ];
901 if( !pSF )
902 return sal_False;
903
897 if( nLevel >= MAX_FALLBACK )
898 return sal_False;
899
900 ServerFont* pSF = m_pServerFont[ nLevel ];
901 if( !pSF )
902 return sal_False;
903
904 nGlyphIndex &= ~GF_FONTMASK;
905 if( pSF->GetGlyphOutline( nGlyphIndex, rB2DPolyPoly ) )
906 return sal_True;
907
908 return sal_False;
904 aGlyphId &= ~GF_FONTMASK;
905 bool bOK = pSF->GetGlyphOutline( aGlyphId, rB2DPolyPoly );
906 return bOK;
909}
910
911SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
912{
913 // workaround for printers not handling glyph indexing for non-TT fonts
914 int nFontId = m_pPrinterGfx->GetFontID();
915 if( psp::fonttype::TrueType != psp::PrintFontManager::get().getFontType( nFontId ) )
916 rArgs.mnFlags |= SAL_LAYOUT_DISABLE_GLYPH_PROCESSING;

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

928 return pLayout;
929}
930
931//--------------------------------------------------------------------------
932
933sal_Bool PspGraphics::CreateFontSubset(
934 const rtl::OUString& rToFile,
935 const ImplFontData* pFont,
907}
908
909SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
910{
911 // workaround for printers not handling glyph indexing for non-TT fonts
912 int nFontId = m_pPrinterGfx->GetFontID();
913 if( psp::fonttype::TrueType != psp::PrintFontManager::get().getFontType( nFontId ) )
914 rArgs.mnFlags |= SAL_LAYOUT_DISABLE_GLYPH_PROCESSING;

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

926 return pLayout;
927}
928
929//--------------------------------------------------------------------------
930
931sal_Bool PspGraphics::CreateFontSubset(
932 const rtl::OUString& rToFile,
933 const ImplFontData* pFont,
936 sal_Int32* pGlyphIDs,
934 sal_GlyphId* pGlyphIds,
937 sal_uInt8* pEncoding,
938 sal_Int32* pWidths,
939 int nGlyphCount,
940 FontSubsetInfo& rInfo
941 )
942{
943 // in this context the pFont->GetFontId() is a valid PSP
944 // font since they are the only ones left after the PDF
945 // export has filtered its list of subsettable fonts (for
946 // which this method was created). The correct way would
947 // be to have the GlyphCache search for the ImplFontData pFont
948 psp::fontID aFont = pFont->GetFontId();
949
950 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
951 bool bSuccess = rMgr.createFontSubset( rInfo,
952 aFont,
953 rToFile,
935 sal_uInt8* pEncoding,
936 sal_Int32* pWidths,
937 int nGlyphCount,
938 FontSubsetInfo& rInfo
939 )
940{
941 // in this context the pFont->GetFontId() is a valid PSP
942 // font since they are the only ones left after the PDF
943 // export has filtered its list of subsettable fonts (for
944 // which this method was created). The correct way would
945 // be to have the GlyphCache search for the ImplFontData pFont
946 psp::fontID aFont = pFont->GetFontId();
947
948 psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
949 bool bSuccess = rMgr.createFontSubset( rInfo,
950 aFont,
951 rToFile,
954 pGlyphIDs,
952 pGlyphIds,
955 pEncoding,
956 pWidths,
957 nGlyphCount );
958 return bSuccess;
959}
960
961//--------------------------------------------------------------------------
962

--- 438 unchanged lines hidden ---
953 pEncoding,
954 pWidths,
955 nGlyphCount );
956 return bSuccess;
957}
958
959//--------------------------------------------------------------------------
960

--- 438 unchanged lines hidden ---