-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The dangers of copy and pasting code! Our string width and string replacement routines had drifted out of sync.
- Loading branch information
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/OpenUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.openhtmltopdf.util; | ||
|
||
public class OpenUtil { | ||
|
||
private OpenUtil() {} | ||
|
||
/** | ||
* Checks if a code point is printable. If false, it can be safely discarded at the | ||
* rendering stage, else it should be replaced with the replacement character, | ||
* if a suitable glyph can not be found. | ||
* @param codePoint | ||
* @return whether codePoint is printable | ||
*/ | ||
public static boolean isCodePointPrintable(int codePoint) { | ||
if (Character.isISOControl(codePoint)) | ||
return false; | ||
|
||
int category = Character.getType(codePoint); | ||
|
||
return !(category == Character.CONTROL || | ||
category == Character.FORMAT || | ||
category == Character.UNASSIGNED || | ||
category == Character.PRIVATE_USE || | ||
category == Character.SURROGATE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters