[ 
https://issues.apache.org/jira/browse/PDFBOX-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16428546#comment-16428546
 ] 

Tilman Hausherr edited comment on PDFBOX-4183 at 4/6/18 4:33 PM:
-----------------------------------------------------------------

I don't see a need for this in PDFBox. We're on a low level, itext is on a high 
level. We don't detect languages. We don't support complex scripts so we can't 
output thai correctly anyway.


was (Author: tilman):
I don't see a need for this in PDFBox. We're on a low level, itext is on a high 
level. We don't detect languages. We don't support complex scripts so we can't 
output thai correctly.

> To support multi-lingual paragraphs without switching Font objects
> ------------------------------------------------------------------
>
>                 Key: PDFBOX-4183
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4183
>             Project: PDFBox
>          Issue Type: New Feature
>          Components: FontBox
>            Reporter: vikas kumar jagga
>            Priority: Major
>
> Problem :- If a single paragraph has fonts of different languages we need to 
> detect the language and load the appropriate PDType0Font font file object 
> (holding ttf file) supporting that language fonts.
> PDFbox library should provide a class with addFont() method that can hold 
> multiple PDType0Font objects (holding different ttf files) so that this 
> object holding multiple font files could be loaded in document object. It 
> will reduce the overhead to detect the language and then loading that ttf 
> file object.
> iText provide this feature with FontSelector class. Below is the sample code 
> usage.
> {color:#14892c}import java.awt.Color;{color}
> {color:#14892c}import org.apache.log4j.Logger;{color}
> {color:#14892c}import com.lowagie.text.Font;{color}
> {color:#14892c}import com.lowagie.text.pdf.BaseFont;{color}
> {color:#14892c}import com.lowagie.text.pdf.FontSelector;{color}
> {color:#14892c}public class Fonts {{color}
> {color:#14892c}public static final int STYLE_BOLD = Font.BOLD;{color}
> {color:#14892c} public static final int STYLE_BOLDITALIC = 
> Font.BOLDITALIC;{color}
> {color:#14892c} public static final int STYLE_ITALIC = Font.ITALIC;{color}
> {color:#14892c} public static final int STYLE_NORMAL = Font.NORMAL;{color}
> {color:#14892c} public static final int STYLE_STRIKETHROUGH = 
> Font.STRIKETHRU;{color}
> {color:#14892c} public static final int STYLE_UNDERLINE = 
> Font.UNDERLINE;{color}
> {color:#14892c} public static final BaseFont FONT_NOTO_SANS;{color}
> {color:#14892c} public static final BaseFont FONT_NOTO_SANS_AR; // 
> Arabic{color}
> {color:#14892c} public static final BaseFont FONT_NOTO_SANS_TH; // Thai{color}
> {color:#14892c} public static final BaseFont FONT_NOTO_SANS_CJK; // Chinese, 
> Japanese and Korean{color}
> {color:#14892c}static {{color}
> {color:#14892c}try {{color}
> {color:#14892c} tmpNOTOSANS = 
> BaseFont.createFont("/fonts/NotoSans-Regular.ttf", BaseFont.IDENTITY_H, 
> BaseFont.EMBEDDED);{color}
> {color:#14892c} }{color}
> {color:#14892c} catch (Exception ex) {{color}
>  
> {color:#14892c} }{color}
> {color:#14892c}try {{color}
> {color:#14892c} tmpNOTOSANS_AR = 
> BaseFont.createFont("/fonts/NotoKufiArabic-Regular.ttf", BaseFont.IDENTITY_H, 
> BaseFont.EMBEDDED);{color}
> {color:#14892c} }{color}
> {color:#14892c} catch (Exception ex) {{color}
>  
> {color:#14892c} }{color}
> {color:#14892c}try {{color}
> {color:#14892c} tmpNOTOSANS_TH = 
> BaseFont.createFont("/fonts/NotoSansThai-Regular.ttf", BaseFont.IDENTITY_H, 
> BaseFont.EMBEDDED);{color}
> {color:#14892c} }{color}
> {color:#14892c} catch (Exception ex) {{color}
>  
> {color:#14892c} }{color}
> {color:#14892c}try {{color}
> {color:#14892c} tmpNOTOSANS_CJK = 
> BaseFont.createFont("/fonts/NotoSansCJK-Regular.ttf", BaseFont.IDENTITY_H, 
> BaseFont.NOT_EMBEDDED);{color}
> {color:#14892c} }{color}
> {color:#14892c} catch (Exception ex) {{color}
>  
> {color:#14892c} }{color}
>  
> {color:#14892c} FONT_NOTO_SANS = tmpNOTOSANS;{color}
> {color:#14892c} FONT_NOTO_SANS_AR = tmpNOTOSANS_AR;{color}
> {color:#14892c} FONT_NOTO_SANS_TH = tmpNOTOSANS_TH;{color}
> {color:#14892c} FONT_NOTO_SANS_CJK = tmpNOTOSANS_CJK;{color}
> {color:#14892c} }{color}
> {color:#14892c}public static FontSelector returnFontSelector(float size, int 
> style) {{color}
> {color:#14892c} return returnFontSelector(size, style, null);{color}
> {color:#14892c} }{color}
> {color:#14892c}public static FontSelector returnFontSelector(float size, int 
> style, Color color) {{color}
> {color:#14892c} FontSelector multiFonts = new FontSelector();{color}
>  
> {color:#14892c} multiFonts.addFont(new Font(Fonts.FONT_NOTO_SANS, size, 
> style, color));{color}
> {color:#14892c} multiFonts.addFont(new Font(Fonts.FONT_NOTO_SANS_AR, size, 
> style, color));{color}
> {color:#14892c} multiFonts.addFont(new Font(Fonts.FONT_NOTO_SANS_TH, size, 
> style, color));{color}
> {color:#14892c} multiFonts.addFont(new Font(Fonts.FONT_NOTO_SANS_CJK, size, 
> style, color));{color}
>  
> {color:#14892c} return multiFonts;{color}
> {color:#14892c} }{color}
> {color:#14892c}}{color}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to