- Home /
unity local language integration problem
Hello all I am having problem at displaying the characters of a language (Kannada Language in particular) the characters are printed properly on other applications like whatsapp, kik etc.. but in the unity the characters are displayed in improper way
Example as shown in the figure when those two characters are added it should printed as shown in the First Sequence but when it comes to unity its printed as shown in second which is improper
Whats the reason for this? and how can i overcome this problem. i Have tried with using different fonts, still the result is same. i am using unity UI system Text field and Unity 5.2.3 version
Hi RJR, We are also facing the issue with kannada font. we have used thunga & Nirmala fonts. when the code is converted from cshmtl to pdf, the kannada fonts are not displaying correctly.
using ($$anonymous$$emoryStream stream = new System.IO.$$anonymous$$emoryStream()) { TextReader sr = new StringReader(""); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream); Font font = null;
font = FontFactory.GetFont(Server.$$anonymous$$apPath("/TTF/Nirmala.ttf"), BaseFont.IDENTITY_H, 10f, Font.NOR$$anonymous$$AL);
pdfDoc.Open();
Paragraph p = new Paragraph(new Chunk(GridHtml, font));
pdfDoc.Add(p);
X$$anonymous$$LWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
pdfDoc.Close();
return File(stream.ToArray(), "application/pdf", "Gridtest.pdf");
}
}
Answer by rjr · Dec 29, 2015 at 12:35 PM
Well i found a solution to overcome this problem, if anyone facing the same issues... post here, i shall explain in detail
Answer by csgpm · Nov 30, 2019 at 07:44 AM
HI, I am facing same problem with kannada fonts, can you share your solution. so that i can use that in my code. @rjr @rjr
public void pdfExport(string GridHtml) { StringReader sr = new StringReader(GridHtml.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
using (MemoryStream memoryStream = new MemoryStream()) { Font font = null;
font = FontFactory.GetFont(Server.MapPath("/TTF/Tunga_Regular.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12f, Font.NORMAL, BaseColor.BLACK);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
pdfDoc.Open();
Paragraph p = new Paragraph(new Chunk(GridHtml, font));
pdfDoc.Add(p);
htmlparser.Parse(sr);
pdfDoc.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=Invoice.pdf");
Response.Charset = "UTF-8";
//Response.ContentEncoding=PdfEncodings.
Response.Buffer = true;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
Response.End();
Response.Close();
}
}