Can't set custom font for pdf for PdfContentByte - DroidText/iText library -
i'm trying use custom font, don't error doesn't take account.
rectangle pagesize = basepdf.getpagesize(i); pdfcontentbyte pdfcontentbyte = stamper.getovercontent(i); // use custom font if (!fontfactory.isregistered(futura_light)) { filehelper.copyfilefromassetstointernalstorage(mcontext, font_path_in_assets); fontfactory.register(mcontext.getfilesdir() + "/" + font_path_in_assets, futura_light); } font myfont = fontfactory.getfont(futura_light); basefont font = myfont.getbasefont(); pdfcontentbyte.savestate(); pdfcontentbyte.stroke(); pdfcontentbyte.restorestate(); // start add text pdfcontentbyte.begintext(); pdfcontentbyte.setfontandsize(font, 6); if (fontcolor != null) { pdfcontentbyte.setcolorfill(fontcolor); } pdfcontentbyte.showtextaligned(pdfcontentbyte.align_center, message, pagesize.getwidth() / 2, 40, 0); pdfcontentbyte.endtext();
i've checked , font indeed registered, doesn't apply pdf.
i found accident, trying display accents adding basefont.identity_h
here's line changed:
font myfont = fontfactory.getfont(futura_light, basefont.identity_h);
Comments
Post a Comment