summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorJonathan Schultz <jonathan@imatix.com>2013-05-22 14:08:12 +0200
committerLászló Németh <nemeth@numbertext.org>2013-05-22 14:10:34 +0200
commit0b70e4ea4fcf0adccdfdf4886e5cc45d46479692 (patch)
tree45046466f899c707a2d83a2a59e98ba849c03aa9 /vcl/source
parent2dec489ebb75030ffaeaa6daf7d42472e23a5eb6 (diff)
fdo#62846 incorrect glyph to Unicode mappings in PDFs
Change-Id: Idebc7f69f95d8f72626373475d8611ea68f1483a
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx6
-rw-r--r--vcl/source/gdi/sallayout.cxx8
-rw-r--r--vcl/source/glyphs/graphite_layout.cxx20
3 files changed, 28 insertions, 6 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 3c7b186daec2..4e84f0711778 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7619,7 +7619,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const String& rText, bool bT
std::vector<sal_Ucs> aUnicodes;
aUnicodes.reserve( nMaxGlyphs );
sal_Int32 pUnicodesPerGlyph[nMaxGlyphs];
- int pCharPosAry[nMaxGlyphs];
+ int pCharPosAry[nMaxGlyphs+1];
sal_Int32 nAdvanceWidths[nMaxGlyphs];
const PhysicalFontFace* pFallbackFonts[nMaxGlyphs];
bool bVertical = m_aCurrentPDFState.m_aFont.IsVertical();
@@ -7768,14 +7768,14 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const String& rText, bool bT
aUnicodes.push_back( rText.GetChar( sal::static_int_cast<xub_StrLen>(pCharPosAry[i]) ) );
pUnicodesPerGlyph[i] = 1;
// try to handle ligatures and such
- if( i < nGlyphs-1 )
+ if( i < nGlyphs )
{
nChars = pCharPosAry[i+1] - pCharPosAry[i];
// #i115618# fix for simple RTL+CTL cases
// TODO: sanitize for RTL ligatures, more complex CTL, etc.
if( nChars < 0 )
nChars = -nChars;
- else if( nChars == 0 )
+ else if( nChars == 0 )
nChars = 1;
pUnicodesPerGlyph[i] = nChars;
for( int n = 1; n < nChars; n++ )
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 6955679350ad..705b8cc8c2e0 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1427,7 +1427,11 @@ int GenericSalLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos
nOldFlags = pG->mnGlyphIndex; // &GF_FLAGMASK not needed for test above
}
- aRelativePos.X() /= mnUnitsPerPixel;
+ // Calculate final pCharPosAry item
+ if( pCharPosAry )
+ *pCharPosAry = pG->mnCharPos;
+
+ aRelativePos.X() /= mnUnitsPerPixel;
aRelativePos.Y() /= mnUnitsPerPixel;
rPos = GetDrawPosition( aRelativePos );
@@ -1675,7 +1679,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
// prepare "merge sort"
int nStartOld[ MAX_FALLBACK ];
int nStartNew[ MAX_FALLBACK ];
- int nCharPos[ MAX_FALLBACK ];
+ int nCharPos[ MAX_FALLBACK+1 ];
sal_Int32 nGlyphAdv[ MAX_FALLBACK ];
int nValid[ MAX_FALLBACK ] = {0};
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index 3898ab1c7fdd..976ccc532983 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -294,7 +294,7 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
if (bCluster)
{
nBaseGlyphIndex = mvGlyphs.size();
- mvGlyph2Char[nBaseGlyphIndex] = iChar + mnSegCharOffset;
+ mvGlyph2Char[nBaseGlyphIndex] = firstChar + mnSegCharOffset;
nFirstCharInCluster = firstChar;
nLastCharInCluster = lastChar;
}
@@ -1295,6 +1295,24 @@ int GraphiteLayout::GetNextGlyphs( int length, sal_GlyphId * glyph_out,
if (glyph_itr->mnGlyphIndex == GF_DROPPED)
break;
}
+
+ // Calculate final pCharPosAry item
+ if (char_index)
+ {
+ if (glyph_slot >= (signed)mvGlyph2Char.size())
+ {
+ *char_index++ = mnMinCharPos + mvCharDxs.size();
+ }
+ else
+ {
+ assert(glyph_slot > -1);
+ if (mvGlyph2Char[glyph_slot] == -1)
+ *char_index++ = mnMinCharPos + mvCharDxs.size();
+ else
+ *char_index++ = mvGlyph2Char[glyph_slot];
+ }
+ }
+
int numGlyphs = glyph_slot - glyph_slot_begin;
// move the next glyph_slot to a glyph that hasn't been dropped
while (glyph_slot < static_cast<int>(mvGlyphs.size()) &&