Skip to content

Commit

Permalink
resolve ticket 72 - incorrect kerning when ATT enabled font has no GP…
Browse files Browse the repository at this point in the history
…OS, but has standard kerning
  • Loading branch information
skynavga committed Nov 18, 2011
1 parent c765141 commit c456c08
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1,327 deletions.
43 changes: 42 additions & 1 deletion src/java/org/apache/fop/fonts/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,30 @@ public int getKernValue(char ch1, char ch2) {
return 0;
}

/**
* Returns the amount of kerning between two characters.
*
* The value returned measures in pt. So it is already adjusted for font size.
*
* @param ch1 first character
* @param ch2 second character
* @return the distance to adjust for kerning, 0 if there's no kerning
*/
public int getKernValue(int ch1, int ch2) {
// TODO !BMP
if ( ch1 > 0x10000 ) {
return 0;
} else if ( ( ch1 >= 0xD800 ) && ( ch1 <= 0xE000 ) ) {
return 0;
} else if ( ch2 > 0x10000 ) {
return 0;
} else if ( ( ch2 >= 0xD800 ) && ( ch2 <= 0xE000 ) ) {
return 0;
} else {
return getKernValue ( (char) ch1, (char) ch2 );
}
}

/**
* Returns the width of a character
* @param charnum character to look up
Expand Down Expand Up @@ -269,7 +293,7 @@ public String toString() {
* This also performs some guessing on widths on various
* versions of space that might not exists in the font.
* @param c character to inspect
* @return the width of the character
* @return the width of the character or -1 if no width available
*/
public int getCharWidth(char c) {
int width;
Expand Down Expand Up @@ -333,6 +357,23 @@ public int getCharWidth(char c) {
return width;
}

/**
* Helper method for getting the width of a unicode char
* from the current fontstate.
* This also performs some guessing on widths on various
* versions of space that might not exists in the font.
* @param c character to inspect
* @return the width of the character or -1 if no width available
*/
public int getCharWidth(int c) {
if ( c < 0x10000 ) {
return getCharWidth ( (char) c );
} else {
// TODO !BMP
return -1;
}
}

/**
* Calculates the word width.
* @param word text to get width for
Expand Down
Loading

0 comments on commit c456c08

Please sign in to comment.