Set the font size using AppendMath

Hello,

You previously answered my question about changing the font of an equation where you essentially iterated through all of the characters in order to set the font. To set the font size of the equation, is a similar process required or is there a more direct method I can call to set the font size when using paragraph.AppendMath(...)?


Thanks. 


8 Replies 1 reply marked as answer

AA Akash Arul Syncfusion Team January 8, 2024 11:18 AM UTC

Hi Natalie,

There is no direct method to set the font size for the equation. In order to set the font size, it is necessary to iterate through the equation and set it individually for each character.

Regards,
Akash.



NW Natalie Westphal January 9, 2024 03:08 AM UTC

Thanks for your reply. Is there any plan to add an option to change the font size of an equation with a singular method? 



LB Lokesh Baskar Syncfusion Team January 9, 2024 07:55 AM UTC

Hi Natalie, we are currently checking the feasibility of your requirements and will provide further details on January 11, 2024.



SB Sneha Biju Syncfusion Team January 11, 2024 05:23 PM UTC

Currently Syncfusion DocIO doesn’t has an API to set font name and size for a math. So, we consider the requirement of "Provide an API to set font name and font size for a math" as feature request in our database. We don’t have any immediate plans to implement this feature.

The status of the feature can be tracked through link: https://www.syncfusion.com/feedback/49926/provide-an-api-to-set-font-name-and-font-size-for-a-math


Marked as answer

NW Natalie Westphal January 26, 2024 08:25 PM UTC

Hello, 

I am using the code provided to set the font and font size of equations and it seems to be working. But I have found one case where the font and font size are not being set on the parentheses but are being set on the other characters in the equation. Please see the attached code and advise if there is a workaround for this.  


Attachment: LatexEquation_4251db7a_(1)_f1f31b47.zip


AA Akash Arul Syncfusion Team January 29, 2024 01:30 PM UTC

Natalie, on analyzing the code and the output document, we could find that the parentheses have the font that we set using the code (“Times New Roman”). And we checked the code on our end. We have set the font name and the font size to every element of the equation. So, there is no issue in it. Please refer to the below screenshot.


We suspect that you placed your cursor like the below screenshot.

The above screenshot doesn’t show the font name of the parentheses. It shows the equation container’s font name. We can’t change the equation container’s font. As it is the Microsoft Word’s behaviour that the equation is will be inserted as the Cambria Math and the font of the equation container can’t be changed. And there will be no wrong preservations in the output.

As a conclusion, we can only change the font name or size of the elements of the equation and we can't change the font of the equation container.



NW Natalie Westphal January 29, 2024 04:48 PM UTC

Actually, when I place my cursor next to the parentheses before the b, it shows the font name as Cambria Math and the font size is 12. I have attached a screenshot. Also, just by inspecting the equation visually in the screenshots you provided, you can see that the parentheses around "b_red t_ft" are larger than the other parentheses and are not proportional to the rest of the equation. 

Thanks. 


Attachment: Output_font_267ea09d.zip


AA Akash Arul Syncfusion Team January 30, 2024 02:07 PM UTC

Natalie, please find the details below.

Regarding my cursor next to the parentheses before the b, it shows the font name as Cambria Math and the font size is 12:

It is not feasible to set custom font name and font size for all the characters in the mathematical equation in Microsoft Word application itself. For example: If you select entire equation and set font name and font size in Microsoft Word application itself, it doesn’t applied properly.

But, we can apply for some characters in the file level. DocIO is non-UI component and able to access all file level properties programmatically. So, we prepared the sample to set font name and size for applicable characters for the equations in Word document.

To view the font name and size difference in Microsoft Word, it is need to select the particular content alone and see the font name and size.

For example:

  1. If you set cursor at the start of equation, it denotes the container only. So, it not shown the font name and size which we set in file level.

  2. If you select the text “A”, you can see font name and size are as per what we set in DocIO.

  3. If you set cursor before to the “b”, it denotes the container only. So, it not shown the font name and size properly.


The overall behavior is, Microsoft Word doesn’t change font name and size for entire equation, instead it change for applicable text content in equations only. The same behavior we can see in the document generated from DocIO. So, it is not an issue.


Regarding the parentheses around "b_red t_ft" are larger than the other parentheses:

The parentheses near A is the parentheses that is typed using keyboard (shift + 9). But the parentheses near b is delimiter symbol (that means, begin character symbol) in equation.

Usually, Microsoft Word document consider some characters as symbols in file level, which means they are not treated like normal text content and not feasible to set text properties like font name, font size. Here, parentheses near b is also a symbol. The size of symbol depends on the content inside the equation when viewing in Microsoft Word application and those size information are not available in file level. Also, it is not feasible to strict the size of those symbols by setting any font size.

Thus, the parenthesis near b is different when compare to parentheses near A (this is normal text).



Loader.
Up arrow icon