diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2009-12-18 11:44:01 +0100 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2009-12-18 11:44:01 +0100 |
commit | f4ccd00d3626347be13ca5919a07bb39b58729c5 (patch) | |
tree | 4cda56a5753ed43a847f85f62014f2dd0bdd6880 | |
parent | d408e96e7eaf89202a4a2f866708149cb01e8e87 (diff) |
vcl108: #i107254# copy with arbitrary length ligatures
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 15 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 49 |
2 files changed, 50 insertions, 14 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 0564be3c1c1f..7db8325bfedd 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3669,7 +3669,7 @@ bool PDFWriterImpl::emitFonts() rtl_zeroMemory( pEncToUnicodeIndex, sizeof( pEncToUnicodeIndex ) ); for( FontEmitMapping::iterator fit = lit->m_aMapping.begin(); fit != lit->m_aMapping.end();++fit ) { - sal_uInt8 nEnc = fit->second.m_nSubsetGlyphID; + sal_uInt8 nEnc = fit->second.getGlyphId(); DBG_ASSERT( pGlyphIDs[nEnc] == 0 && pEncoding[nEnc] == 0, "duplicate glyph" ); DBG_ASSERT( nEnc <= lit->m_aMapping.size(), "invalid glyph encoding" ); @@ -3677,10 +3677,10 @@ bool PDFWriterImpl::emitFonts() pGlyphIDs[ nEnc ] = fit->first; pEncoding[ nEnc ] = nEnc; pEncToUnicodeIndex[ nEnc ] = static_cast<sal_Int32>(aUnicodes.size()); - pUnicodesPerGlyph[ nEnc ] = fit->second.m_nUnicodes; - for( sal_Int32 n = 0; n < fit->second.m_nUnicodes; n++ ) - aUnicodes.push_back( fit->second.m_aUnicodes[n] ); - if( fit->second.m_aUnicodes[0] ) + pUnicodesPerGlyph[ nEnc ] = fit->second.countCodes(); + for( sal_Int32 n = 0; n < pUnicodesPerGlyph[ nEnc ]; n++ ) + aUnicodes.push_back( fit->second.getCode( n ) ); + if( fit->second.getCode(0) ) nToUnicodeStream = 1; if( nGlyphs < 256 ) nGlyphs++; @@ -6459,10 +6459,9 @@ void PDFWriterImpl::registerGlyphs( int nGlyphs, // add new glyph to emitted font subset GlyphEmit& rNewGlyphEmit = rSubset.m_aSubsets.back().m_aMapping[ nFontGlyphId ]; - rNewGlyphEmit.m_nSubsetGlyphID = nNewId; - rNewGlyphEmit.m_nUnicodes = pUnicodesPerGlyph[i]; + rNewGlyphEmit.setGlyphId( nNewId ); for( sal_Int32 n = 0; n < pUnicodesPerGlyph[i]; n++ ) - rNewGlyphEmit.m_aUnicodes[n] = pCurUnicode[n]; + rNewGlyphEmit.addCode( pCurUnicode[n] ); // add new glyph to font mapping Glyph& rNewGlyph = rSubset.m_aMapping[ nFontGlyphId ]; diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c8b201a7bfb8..68cf8a808303 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -52,6 +52,8 @@ #include <hash_map> #include <list> +#include <boost/shared_array.hpp> + class ImplFontSelectData; class ImplFontMetricData; class FontSubsetInfo; @@ -270,17 +272,52 @@ public: }; // font subsets - struct GlyphEmit + class GlyphEmit { - static const int nMaxUnicodes = 8; // performance: actually this should probably a vector; - sal_Ucs m_aUnicodes[nMaxUnicodes]; - sal_Int32 m_nUnicodes; - sal_uInt8 m_nSubsetGlyphID; + sal_Ucs m_aBufferedUnicodes[3]; + sal_Int32 m_nUnicodes; + sal_Int32 m_nMaxUnicodes; + boost::shared_array<sal_Ucs> m_pUnicodes; + sal_uInt8 m_nSubsetGlyphID; + public: GlyphEmit() : m_nUnicodes(0), m_nSubsetGlyphID(0) { - rtl_zeroMemory( m_aUnicodes, sizeof( m_aUnicodes ) ); + rtl_zeroMemory( m_aBufferedUnicodes, sizeof( m_aBufferedUnicodes ) ); + m_nMaxUnicodes = sizeof(m_aBufferedUnicodes)/sizeof(m_aBufferedUnicodes[0]); + } + ~GlyphEmit() + { + } + + void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; } + sal_uInt8 getGlyphId() const { return m_nSubsetGlyphID; } + + void addCode( sal_Ucs i_cCode ) + { + if( m_nUnicodes == m_nMaxUnicodes ) + { + sal_Ucs* pNew = new sal_Ucs[ 2 * m_nMaxUnicodes]; + if( m_pUnicodes.get() ) + rtl_copyMemory( pNew, m_pUnicodes.get(), m_nMaxUnicodes * sizeof(sal_Ucs) ); + else + rtl_copyMemory( pNew, m_aBufferedUnicodes, m_nMaxUnicodes * sizeof(sal_Ucs) ); + m_pUnicodes.reset( pNew ); + m_nMaxUnicodes *= 2; + } + if( m_pUnicodes.get() ) + m_pUnicodes[ m_nUnicodes++ ] = i_cCode; + else + m_aBufferedUnicodes[ m_nUnicodes++ ] = i_cCode; + } + sal_Int32 countCodes() const { return m_nUnicodes; } + sal_Ucs getCode( sal_Int32 i_nIndex ) const + { + sal_Ucs nRet = 0; + if( i_nIndex < m_nUnicodes ) + nRet = m_pUnicodes.get() ? m_pUnicodes[ i_nIndex ] : m_aBufferedUnicodes[ i_nIndex ]; + return nRet; } }; typedef std::map< sal_GlyphId, GlyphEmit > FontEmitMapping; |