summaryrefslogtreecommitdiff
path: root/vcl/unx/source/printergfx
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2009-12-04 14:24:57 +0000
committerPhilipp Lohmann <pl@openoffice.org>2009-12-04 14:24:57 +0000
commitf7b51af1397309b611c3f98f26bdbfed0271095e (patch)
tree96140d3a1527bdca9a677ccac10843f98413c78d /vcl/unx/source/printergfx
parentf8ada8f2a93659e27928f3b5244c813de2c3847b (diff)
#i106833# fix subset font encoding
Diffstat (limited to 'vcl/unx/source/printergfx')
-rw-r--r--vcl/unx/source/printergfx/glyphset.cxx38
1 files changed, 31 insertions, 7 deletions
diff --git a/vcl/unx/source/printergfx/glyphset.cxx b/vcl/unx/source/printergfx/glyphset.cxx
index 156517d98220..5adff6683267 100644
--- a/vcl/unx/source/printergfx/glyphset.cxx
+++ b/vcl/unx/source/printergfx/glyphset.cxx
@@ -46,6 +46,7 @@
#include <set>
#include <map>
+#include <algorithm>
using namespace vcl;
using namespace psp;
@@ -785,6 +786,17 @@ GlyphSet::PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx)
return sal_True;
}
+struct EncEntry
+{
+ sal_uChar aEnc;
+ long aGID;
+
+ EncEntry() : aEnc( 0 ), aGID( 0 ) {}
+
+ bool operator<( const EncEntry& rRight ) const
+ { return aEnc < rRight.aEnc; }
+};
+
static void CreatePSUploadableFont( TrueTypeFont* pSrcFont, FILE* pTmpFile,
const char* pGlyphSetName, int nGlyphCount,
/*const*/ sal_uInt16* pRequestedGlyphs, /*const*/ sal_uChar* pEncoding,
@@ -796,17 +808,29 @@ static void CreatePSUploadableFont( TrueTypeFont* pSrcFont, FILE* pTmpFile,
if( bAllowType42 )
nTargetMask |= FontSubsetInfo::TYPE42_FONT;
+ std::vector< EncEntry > aSorted( nGlyphCount, EncEntry() );
+ for( int i = 0; i < nGlyphCount; i++ )
+ {
+ aSorted[i].aEnc = pEncoding[i];
+ aSorted[i].aGID = pRequestedGlyphs[i];
+ }
+
+ std::stable_sort( aSorted.begin(), aSorted.end() );
+
+ std::vector< sal_uChar > aEncoding( nGlyphCount );
+ std::vector< long > aRequestedGlyphs( nGlyphCount );
+
+ for( int i = 0; i < nGlyphCount; i++ )
+ {
+ aEncoding[i] = aSorted[i].aEnc;
+ aRequestedGlyphs[i] = aSorted[i].aGID;
+ }
+
FontSubsetInfo aInfo;
aInfo.LoadFont( pSrcFont );
-#if 1 // TODO: remove 16bit->long conversion when input args has been changed
- long aRequestedGlyphs[256];
- for( int i = 0; i < nGlyphCount; ++i )
- aRequestedGlyphs[i] = pRequestedGlyphs[i];
-#endif
-
aInfo.CreateFontSubset( nTargetMask, pTmpFile, pGlyphSetName,
- aRequestedGlyphs, pEncoding, nGlyphCount, NULL );
+ &aRequestedGlyphs[0], &aEncoding[0], nGlyphCount, NULL );
}
sal_Bool