Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to allow font fallback in ContainerNodes that have a parent Diagram (Read 1627 times)
Randall S
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jan 1st, 2020
How to allow font fallback in ContainerNodes that have a parent Diagram
Jan 1st, 2020 at 6:05pm
Print Post  
Hi all, happy New Year.

I am having trouble with some behavior in ContainerNodes that seems a bit odd.

If you take the Anchors.zip official example project (the forum prevents me from providing a link, but if you Google "mindfusion anchors sample" it should be the first result).

And you delete all the code in the Form1_Load() function and replace it with this:

Code
Select All
private void Form1_Load(object sender, EventArgs e)
{
            var container = new ContainerNode();
            container.Font = new Font("Segoe UI", 10);
            container.Caption = "テスト";
            container.Bounds = new RectangleF(0, 0, 20, 20);
            diagram.Nodes.Add(container);
}
 



This looks fine when you run it (see attachment: 1.png). Even though "Segoe UI" font doesn't support Japanese characters, the renderer apparently falls back to some other font and displays the text, as is common for WinForms controls.

However if I pass in a Diagram to the ToolContainer constructor, it seems that this breaks the fallback behavior, and the text is rendered as boxes (see attachment: 2.png). That code is like this:

Code
Select All
private void Form1_Load(object sender, EventArgs e)
{
            var container = new ContainerNode(new Diagram());
            container.Font = new Font("Segoe UI", 10);
            container.Caption = "テスト";
            container.Bounds = new RectangleF(0, 0, 20, 20);
            diagram.Nodes.Add(container);
}
 



I have to explicitly set a Japanese font, like MS Gothic, instead of Segoe UI, for the text to render correctly (on the 4th line there).

So my question is, how can I give the ToolContainer a parent Diagram while still maintaining font fallback ability?

Thanks in advance.
  

1_001.png ( 2 KB | 146 Downloads )
1_001.png
2_002.png ( 3 KB | 159 Downloads )
2_002.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: How to allow font fallback in ContainerNodes that have a parent Diagram
Reply #1 - Jan 2nd, 2020 at 4:55am
Print Post  
Hi and happy 2020,

There is the NoFontFallback flag in TextFormat.FormatFlags which the second constructor overload probably copies from the diagram. Try disabling the flag either in diagram's or container's instance.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Randall S
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jan 1st, 2020
Re: How to allow font fallback in ContainerNodes that have a parent Diagram
Reply #2 - Jan 2nd, 2020 at 6:22pm
Print Post  
Thanks Slavcho, happy 2020 to you too.

You are right, I am able to enable font fallback by modifying the TextFormat.FormatFlags like you suggested. It looks like Diagram has TextFormat.FormatFlags == StringFormatFlags.NoFontFallback by default.

For anyone else reading, the solution looks like this:

Code
Select All
diagram.TextFormat.FormatFlags &= ~StringFormatFlags.NoFontFallback;
var container = new ContainerNode(diagram);
 



Thanks,
Randall
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint