Issue with printing Arabic text using ReadexPro Variable font - c#

I am having trouble printing Arabic text using the ReadexPro Varaible font. The text comes up as blank.
Note: I'm using iTextSharp, not iText7
Here's the code for creating the font
public static readonly BaseFont ReadexBaseFont = BaseFont.CreateFont(Path.Combine(WWWROOT_PATH, "ReadexPro-VariableFont_wght.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
public static readonly Font ReadexLightBlack = new(ReadexBaseFont,5f, Font.NORMAL, BaseColor.BLACK);
I have tried checking if the font supports Arabic characters and the character encoding of the file,but the issue still appears.

Related

Issue with "native" color for font symbols

I have an issue with an embbeded font in my iText7 program concerning the rendered color of the text. Let me show you:
Here is the font. When I use this font in word, I can do the following by entering "aaaddd":
So here is my code:
using iText.Kernel.Pdf;
using iText.Layout.Element;
using iText.Layout;
using ConsoleApp1.Properties;
using iText.IO.Font;
using iText.Kernel.Font;
var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test.pdf";
var symbol = PdfFontFactory.CreateFont(Resources.swsymbolsFRcolor_Regular, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED);
var writer = new PdfWriter(path);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
var paragraph1 = new Paragraph("aaaddd");
paragraph1.SetFont(symbol);
document.Add(paragraph1);
document.Close();
The problem is that the generated symbols are in black and white:
Using Word, sometimes, I found a similar behavior. I have to set the color to "auto" to restore the "native" color of the symbols:
But I can't find any "auto" or "native" color in the iText7 SDK.
There are several other fonts that do the same things, but none of those I tried worked.
PDF fonts are generally monochrome by definition as a vector with flag to fill so by default all are black, you can individually set a font fill colour different to the outer stroke (as shown below) for "ASDAaaaddd" but its "unexpected".
These characters were place as default black then the group edited, so for your example they would need to be two groups.
PDF was designed before SVG fonts WOOF or emojis so coloured characters are best added as html vectors then reprinted as pdf equivalent objects.
Don't forget to embed the font but that font did not embed in my test, however it does say its editable ?

openxml merge documents using altChunk and use destination paragraph format

I have a template.docx, doc1.docx, doc2.docx. I am trying to merge doc1.docx and doc2.docx into template.docx using altChunk. The 3 documents have different font size and font styles. I want the resulting document base on the style in template.docx. Any ideas how to achieve that?
For example:
all the heading1 font size is 24, font color is blue
List paragraph font size is 12, font family is Times New Roman

PDF created by DynamicPDF renders korean text as blank

I am using DynamicPDF to generate a PDF file with some Korean text. I'm using the PDF system fonts for CJK characters and am not getting the dreaded squares, I'm just getting... blankness.
The characters take up space and adding latin characters afterwards do show up in the position you'd expect them. Selecting the blank space and right clicking or copying it shows the proper expected characters so they exist.
My system does render Korean text, showing it in a HTML page in chrome works while the PDF in chrome doesn't.
Here is a minimal sample with (working) Japanese text to compare.
ceTe.DynamicPDF.Document document = new ceTe.DynamicPDF.Document();
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);
// Create a Label to add to the page
var testString = "Korean: 안녕하세요 세계 </korean>";
page.Elements.Add(new Label(testString, 0, 0, 504, 100, Font.SinoTypeSongLight, 18, TextAlign.Center));
page.Elements.Add(new Label(testString, 0, 100, 504, 100, Font.HanyangSystemsGothicMedium, 18, TextAlign.Center));
page.Elements.Add(new Label(testString, 0, 200, 504, 100, Font.HanyangSystemsShinMyeongJoMedium, 18, TextAlign.Center));
testString = "Japan: こんにちは世界 </japan>";
page.Elements.Add(new Label(testString, 0, 300, 504, 100, Font.SinoTypeSongLight, 18, TextAlign.Center));
// Add page to document
document.Pages.Add(page);
// Outputs the document to the current web page
document.Draw("D:/HelloWorld.pdf");
Please refer to the DynamicPDF documentation on CJK fonts.
SinoTypeSongLight font you are using to add Korean characters actually supports simplified Chinese language characters. There is no support for Korean character in that font so blank space is expected for the first line in the PDF.
In the second and third lines you are actually using the correct fonts (HanyangSystemsGothicMedium & HanyangSystemsShinMyeongJoMedium) that support Korean characters. However, according to the documentation link above you should have the Asian Font Pack installed on the machine where you are viewing this PDF. I am not sure what PDF viewer plugin your Chrome browser uses but PDF viewers like Adobe Reader provide Asian Font Pack as an add-on. Please see the screenshot that shows the PDF generated with your code in Adobe Reader DC with Asian Font Pack.
Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.

Why won't this font come out in a textbox?

I installed this font
http://www.bibleplaces.com/paleo_hebrew_fonts/
http://www.bibleplaces.com/wp-content/uploads/2015/08/PaleoHebrew.zip
I installed it
It works in Ms Word, this is where it is and what it looks like / should look like. (And this is when in my taskbar it's set to EN - english - rather than hebrew). (If set to hebrew I get the standard hebrew script which is blocky, not paleo hebrew which is stick like). So setting the language bar to EN in the taskbar is correct.
But when I try it in visual studio, with a textbox I can't get the font to display
I can set the textbox to Wingdings so I know the code for setting the font is correct.
TextBox tb1 = new TextBox();
string fontname = "Wingdings"; // works
fontname = "PaleoHebrew"; // doesn't work
fontname = "Paleo-Hebrew"; // doesn't work
fontname = "Paleo Hebrew Regular"; // doesn't work
tb1.Font = new System.Drawing.Font(fontname, 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
The TTF file is PaleoHebrew.TTF, the fonts window shows it as "Paleo Hebrew Regular"
The textbox just displays english
or if I set the language to (HE) in the taskbar then I get the regular hebrew script, rather than paleo hebrew script. Though that happens in word too. So maybe that's normal.
I can't get the textbox in the winforms application written in C# in visual studio C#, display the stick like characters of the paleo hebrew font, though MS word can display them no problem.
I tried
System.Drawing.FontStyle.Regular
instead of
System.Drawing.FontStyle.Bold
But it's still not working.

iTextSharp - C# - Make a font bold as well as underlined

This is the code which I am trying to make a bold and underlined text.
Font header = new Font(Font.FontFamily.TIMES_ROMAN, 15f, Font.BOLD, BaseColor.BLACK);
header.SetStyle(Font.UNDERLINE);
But all I get is underline and not bold. Is there any way I can get both underline and bold font ?
Try the following:
Font header = new Font(Font.FontFamily.TIMES_ROMAN, 15f, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK);
As an alternative to using the Font to underline text, you can also use the setUnderline() method that is available for the Chunk class. When you use the solution explained in the answer by Joachim Isaksson, you can choose the line width of the line, nor the distance from the baseline of the text. The setUnderline() method gives you all that freedom.
Read my answer to the question How to strike through text using iText? for more info.
Take a look at these examples:
Chunk chunk1 = new Chunk("0123456789");
chunk1.SetUnderline(2, -3);
document.Add(new Phrase(chunk1));
Chunk chunk2 = new Chunk("0123456789");
chunk2.SetUnderline(2, 3);
document.Add(new Phrase(chunk2));
In both cases, the line that is drawn will be 2 user units thick instead of the default 1 user unit. In chunk1 the line will be drawn 3 user units under the text (this is underline functionality). In chunk2, the line will be drawn above the baseline (this is strikethrough functionality).
I have used like this:
Dim font8Underline As Font = FontFactory.GetFont("ARIAL", 8, Font.BOLD)
font8Underline.SetStyle(Font.UNDERLINE)
Bold
Font1.SetStyle(1)
Italic
Font1.SetStyle(2)
Bold and Italic
Font1.SetStyle(3)
Underline
Font1.SetStyle(4)
Bold and Italic and Underline
Font1.SetStyle(7)
1+2+4=7

Categories