--- paragraph.c.good Tue Nov 12 13:20:06 2002 +++ paragraph.c Tue Nov 12 14:50:40 2002 @@ -940,7 +940,53 @@ return TOKEN_FUNCTION; } - +static Boolean a73GLChar(char ch) { + switch (ch) { + case '': + case '': + case '': + case '': + case '': + case '': + case '': + case '': + case '': + case '?': + case '': + return true; + default: + return false; + } +} + +static Boolean a73Char(Char ch) { + return (ch>='\xE0' && ch<='\xFF') || (ch=='\xA2') || (ch=='\xB3') || (ch=='\xB8'); +} + +static Boolean a73checkHyph(ParagraphContext* pContext,Char *startPosition) { + Char *curr; + Boolean gp,gc,gn; + + // chech hyphenation before pContext->position + curr=pContext->position; + // check for more one char before and more one char after + if ((startPosition+2 > curr) || (curr > pContext->last-2)) return false; + if (!a73Char(*(curr-2)) || !a73Char(*(curr-1))) return false; + if (!a73Char(*curr) || !a73Char(*(curr+1))) return false; + + gp=a73GLChar(*(curr-1)); + gc=a73GLChar(*(curr)); + gn=a73GLChar(*(curr+1)); + // oo + if (gp && gc) return true; + // opo + if (gp && !gc && gn) return true; + // opp + if (gp && !gc && !gn) return false; + // po + if (!gp && gc) return false; + return true; +} /* Return the number of characters that will fit in a line */ static void GetLineMetrics @@ -971,6 +1017,7 @@ Int16 lastInvisibleDash; Int16 invisibleWidth; Int16 marginAdjustment; + Boolean a73canHyph; startPosition = pContext->position; initialFontStyle = FntGetFont(); @@ -998,6 +1045,7 @@ TokenType nextTokenType; nextTokenType = GetNextToken( pContext, &nextToken ); + a73canHyph=false; if ( nextTokenType == TOKEN_PARAGRAPH_END ) { break; @@ -1046,6 +1094,7 @@ skipLeadingSpace = false; + a73canHyph=a73checkHyph(pContext,startPosition); /* Count the spaces, leading ones are skipped above */ if ( nextToken == ' ' ) { spaceCount++; @@ -1072,7 +1121,7 @@ */ } else if ( nextToken == '-' || nextToken == SOFT_HYPHEN || - nextToken == '\x96' || nextToken == '\x97' ) { + nextToken == '\x96' || nextToken == '\x97' || a73canHyph ) { adjacentDashes++; } else if ( adjacentDashes != 0 ) { @@ -1100,6 +1149,8 @@ charWidth = FntCharWidth( nextToken ); } + if (a73canHyph) + invisibleDash = tokenCount + 1; /* if the lastSpace position (the last place where we could validly break the line) is the same as the lastInvisibleDash position, @@ -1109,7 +1160,7 @@ hyphen character. */ if ( ( lastSpace == lastInvisibleDash ) || - ( nextToken == SOFT_HYPHEN ) ) { + ( nextToken == SOFT_HYPHEN ) || a73canHyph ) { invisibleWidth = FntCharWidth( '-' ); } else {