summaryrefslogtreecommitdiff
path: root/vcl/source/glyphs
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-02-16 09:03:54 +0000
committerOliver Bolte <obo@openoffice.org>2009-02-16 09:03:54 +0000
commit1b52154648707fd93d6c0147d243b803a1f25711 (patch)
treefb64e717cb9b743dd53f3357ded08a6bf3650392 /vcl/source/glyphs
parent3b697a6aba0e0f33910a71b95f98d7ef724ff3a2 (diff)
CWS-TOOLING: integrate CWS kashidafix02
2009-01-27 13:52:43 +0100 hdu r266989 : #i98522# fix position of fallback glyph in RTL-contexts 2009-01-27 11:22:08 +0100 hdu r266969 : minor source layout 2009-01-27 11:18:36 +0100 hdu r266968 : #i98453# prevent kashida-injection for blank-justified text 2009-01-26 11:12:01 +0100 hdu r266911 : #i98454# simplified lcl_ConnectToPrev(), fixed spurious chars in source 2009-01-26 10:53:58 +0100 hdu r266910 : #i98453# handle arabic justification when no valid kashida positions are available 2009-01-26 10:44:30 +0100 hdu r266909 : #i98410# prevent kashida-expansion at ZWNJ 2009-01-23 16:08:17 +0100 hdu r266832 : #i93210# in RTL-contexts the trailing-spaces can be leftmost-spaces 2009-01-23 14:00:24 +0100 hdu r266814 : #i98399# add FARSI support for digit conversion 2009-01-21 15:35:03 +0100 hdu r266675 : #i97108# sub-portion adjustment of RTL-text is not needed yet 2009-01-21 13:40:21 +0100 hdu r266663 : no workaround needed for newer versions of ICU bidi 2009-01-20 09:32:11 +0100 hdu r266553 : #i85089# better cluster detection for UniscribeLayout 2009-01-19 12:39:08 +0100 hdu r266490 : silence escaped fprintf to stderr 2009-01-19 12:23:45 +0100 hdu r266488 : #i85074# improve cluster handling for justified CTL-text on UNX 2009-01-19 10:14:43 +0100 fme r266478 : #i97108# hennerdrewes: Writer's kashida justification has problems with vocalized text
Diffstat (limited to 'vcl/source/glyphs')
-rw-r--r--vcl/source/glyphs/gcach_ftyp.cxx11
-rwxr-xr-xvcl/source/glyphs/gcach_layout.cxx67
2 files changed, 63 insertions, 15 deletions
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
index f6d93963540b..3fe2f7cd0ec2 100644
--- a/vcl/source/glyphs/gcach_ftyp.cxx
+++ b/vcl/source/glyphs/gcach_ftyp.cxx
@@ -1031,6 +1031,17 @@ void FreetypeServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor
rTo.mnDescent += nOtherHalfTmpExtLeading;
}
}
+
+ // initialize kashida width
+ // TODO: what if there are different versions of this glyph available
+ rTo.mnMinKashida = rTo.mnAscent / 4; // a reasonable default
+ const int nKashidaGlyphId = GetRawGlyphIndex( 0x0640 );
+ if( nKashidaGlyphId )
+ {
+ GlyphData aGlyphData;
+ InitGlyphData( nKashidaGlyphId, aGlyphData );
+ rTo.mnMinKashida = aGlyphData.GetMetric().GetCharWidth();
+ }
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/glyphs/gcach_layout.cxx b/vcl/source/glyphs/gcach_layout.cxx
index bdd2444013c0..1e2f83f5f128 100755
--- a/vcl/source/glyphs/gcach_layout.cxx
+++ b/vcl/source/glyphs/gcach_layout.cxx
@@ -60,8 +60,6 @@ void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
rSalGraphics.DrawServerFontLayout( *this );
}
-//--------------------------------------------------------------------------
-
// -----------------------------------------------------------------------
bool ServerFontLayout::LayoutText( ImplLayoutArgs& rArgs )
@@ -481,6 +479,9 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
// layout bidi/script runs and export them to a ServerFontLayout
// convert results to GlyphItems
int nLastCharPos = -1;
+ int nClusterMinPos = -1;
+ int nClusterMaxPos = -1;
+ bool bClusterStart = true;
int nFilteredRunGlyphCount = 0;
const IcuPosition* pPos = pGlyphPositions;
for( int i = 0; i < nRawRunGlyphCount; ++i, ++pPos )
@@ -518,14 +519,6 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
continue;
}
- // if ICU feeds us a character index sequence like [1,0,1] (which
- // is completely valid), smooth out the sequence so that our cluster
- // detection routines work better. The best knowledge where the
- // cluster boundaries are should be provided by the layout engine...
- if( nLastCharPos != -1 )
- if( (nCharPos < nLastCharPos) ^ bRightToLeft )
- nCharPos = nLastCharPos;
-
// apply vertical flags, etc.
if( nCharPos >= 0 )
{
@@ -549,25 +542,68 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
int nGlyphWidth = rGM.GetCharWidth();
- // heuristic to detect group clusters using "smoothed" char positions
+ // heuristic to detect glyph clusters
+ bool bInCluster = true;
+ if( nLastCharPos == -1 )
+ {
+ nClusterMinPos = nClusterMaxPos = nCharPos;
+ bInCluster = false;
+ }
+ else if( !bRightToLeft )
+ {
+ // left-to-right case
+ if( nClusterMinPos > nCharPos )
+ nClusterMinPos = nCharPos; // extend cluster
+ else if( nCharPos <= nClusterMaxPos )
+ /*NOTHING*/; // inside cluster
+ else if( nGlyphWidth <= 0 )
+ nClusterMaxPos = nCharPos; // add diacritic to cluster
+ else {
+ nClusterMinPos = nClusterMaxPos = nCharPos; // new cluster
+ bInCluster = false;
+ }
+ }
+ else
+ {
+ // right-to-left case
+ if( nClusterMaxPos < nCharPos )
+ nClusterMaxPos = nCharPos; // extend cluster
+ else if( nCharPos >= nClusterMinPos )
+ /*NOTHING*/; // inside cluster
+ else if( nGlyphWidth <= 0 )
+ {
+ nClusterMinPos = nCharPos; // ICU often has [diacritic* baseglyph*]
+ if( bClusterStart ) {
+ nClusterMaxPos = nCharPos;
+ bInCluster = false;
+ }
+ }
+ else
+ {
+ nClusterMinPos = nClusterMaxPos = nCharPos; // new cluster
+ bInCluster = !bClusterStart;
+ }
+ }
+
long nGlyphFlags = 0;
- if( nLastCharPos != -1 )
- if( (nCharPos == nLastCharPos) || (nGlyphWidth <= 0) )
- nGlyphFlags = GlyphItem::IS_IN_CLUSTER;
+ if( bInCluster )
+ nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
if( bRightToLeft )
nGlyphFlags |= GlyphItem::IS_RTL_GLYPH;
// add resulting glyph item to layout
- GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
+ const GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
rLayout.AppendGlyph( aGI );
++nFilteredRunGlyphCount;
nLastCharPos = nCharPos;
+ bClusterStart = !aGI.IsDiacritic(); // TODO: only needed in RTL-codepath
}
aNewPos = Point( (int)(pPos->fX+0.5), (int)(pPos->fY+0.5) );
nGlyphCount += nFilteredRunGlyphCount;
}
// sort glyphs in visual order
+ // and then in logical order (e.g. diacritics after cluster start)
rLayout.SortGlyphItems();
// determine need for kashida justification
@@ -594,3 +630,4 @@ ServerFontLayoutEngine* FreetypeServerFont::GetLayoutEngine()
}
// =======================================================================
+