-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unicode bug in version 1.0.5-SNAPSHOT #588
Comments
Hi @vipcxj, I was not able to reproduce. Specifically, I got the public static void main(String... args) throws FontFormatException, IOException {
String html = "<span style=\"font-family:'Wingdings 2',serif;font-size:60px\">☒</span>";
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode();
builder.withHtmlContent(html, null);
builder.toStream(new FileOutputStream("C:\\Users\\dan\Desktop\\desk.pdf"));
builder.useFont(new File("C:\\Users\\dan\\Desktop\\fonts\\Wingdings2.ttf"), "Wingdings 2");
builder.run();
Font fnt = Font.createFont(Font.TRUETYPE_FONT, new File("C:\\Users\\dan\\Desktop\\fonts\\Wingdings2.ttf"));
System.out.println(fnt.canDisplay('\u2612'));
} The result of that test, on both versions, was also the The method you mention runs characters through this method: /**
* 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 method claims that |
EDIT: The charater you pasted is |
EDIT 2: Yes, Wingdings 2 is using this character. POO! We'll have to rethink our approach in filtering characters, probably to one that just filters a couple of problematic characters such as soft hyphens. Thanks for finding this before release! |
openhtmltopdf/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxFastOutputDevice.java
Line 400 in f14e3b8
This line will cause some unicde font not visible. Such as ''. It is not printable in genernal fonts but printable when using Wingdings 2.
Here is the test case, Please change the version of openhtmltopdf in pom from 1.0.4 to 1.0.5-SNAPSHOT
The text was updated successfully, but these errors were encountered: