Colored emoji support

Đang mở
#1,109 2 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
28/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

The issue includes a Flying Saucer example, font registrations, and simplified XHTML, but names no OpenPDF source files or tests. Start by tracing how OpenPDF handles embedded emoji font color data when rendering PDF text; then identify the relevant tests. Done means colored emoji render in color in the generated PDF, rather than black and white.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Is your feature request related to a problem? Please describe.
We use openpdf through flying saucer and we would like to be able to render UTF-8 colored emoji. Until now we are juste able to render them in black and white (or the unique color chosen for the font).

We tried with :

  • Roboto One Color -> nothing is rendered
  • Roboto One B&W -> rendered in b&w (normal)
  • Emoji One Color -> rendered in b&w

I assume that currently openpdf don't take into account the color info in the emoji font. Is it right or am I just doing something wrong ?

Here is the code used to create the pdf from the html

final var processedHtml = templateProcessor.process(templateName, parameters);
try (var os = new ByteArrayOutputStream()) {
    final var renderer = new ITextRenderer();
    renderer.setDocumentFromString(addTagWhenDetectingEmoji(processedHtml.replaceAll(xml10pattern, "")));
    renderer.getFontResolver().addFont("templates/fonts/Roboto-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    renderer.getFontResolver().addFont("templates/fonts/EmojiOneColor.otf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    renderer.layout();
    renderer.createPDF(os, true);
    renderer.finishPDF();
    return os.toByteArray();
} catch (IOException e) {
    throw new PDFGenerationException("Cannot open FileOutputStream", e);
}

A simplified html given as input

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title>Bulletins</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
    <table class="w100">
    	<tr>
    		<td class="smallerBottomTableBorder"><h2>Avis du conseil de classe</h2></td>
        </tr>
        <tr>
        	<td class="text-justify line-return"><span >salut <span style="font-family: 'EmojiOne', sans-serif;">😃</span></span></td>
        </tr>
    </table>
</body>
</html>

Describe the solution you'd like
Adding the ability to render UTF-8 colored emoji in openpdf

Describe alternatives you've considered
Keeping the emoji in black and white

Additional context
/

Ngôn ngữ chính
Java
Star
4.4k
Fork
714
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của LibrePDF/OpenPDF

Tất cả issue của LibrePDF/OpenPDF

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.