opencollab / jlatexmath

A Java API to render LaTeX
Other
513 stars 109 forks source link

How to generate metric xml file from ttf file #98

Open mhao1999 opened 2 years ago

mhao1999 commented 2 years ago

I've read this issue, and issue below command to generate .pl file successfully, however, the result cannot be matched to the values from jlm_msbm10.xml, not only decimal place, but also the value itself, could you please kindly help me out? thanks. PS C:\Program Files\MiKTeX\miktex\bin\x64> .\ttf2tfm.exe D:\tem\jlm_msbm10.ttf d:\tem\jlm_msbm10.tfm PS C:\Program Files\MiKTeX\miktex\bin\x64> .\tftopl.exe D:\tem\jlm_msbm10.tfm D:\tem\jlm_msbm10.pl

the result are like: (CHARACTER O 2 (CHARWD R 0.777) (CHARHT R 0.646) (CHARDP R 0.249) ) (CHARACTER O 3 (CHARWD R 0.777) (CHARHT R 0.836) (CHARDP R 0.327) ) (CHARACTER O 4 (CHARWD R 0.777) (CHARHT R 0.836) (CHARDP R 0.327) )

but in the original file they are like (focus on values):

   <Char code="33" width="0.777781" height="0.635971" depth="0.135971" />
   <Char code="34" width="0.777781" height="0.757257" depth="0.251422" />
   <Char code="35" width="0.777781" height="0.757257" depth="0.251422" />
calixteman commented 2 years ago

It shouldn't be that hard to write a python script in using ttx from fonttools to generate such data.

mhao1999 commented 2 years ago

thank you, calixteman, do you mean write a program to convert format? my question is: e.g. the code "33", height is "0.635971", I search through the generated .pl file, and cannot find any number close to "0.635xxx" (or "0.636xxx"). Or using ttx from fonttools can adjust the number itself? thanks!

ForNeVeR commented 2 years ago

Hey, thanks for your answer.

I am a maintainer of another JMathTeX successor project, WPF-Math. And I've asked the same question several years ago: https://github.com/opencollab/jlatexmath/issues/7.

Unfortunately, we've got no definitive answer so far. FYI, I don't think that TTF files include all the required information, so perhaps we'll have to work with the original TFM files provided as the font source, to gather all the details.

Also, some progress has been made by WPF-Math collaborators in comments to this issue: https://github.com/ForNeVeR/wpf-math/issues/109.

calixteman commented 2 years ago

You're right, the old font file are still using tfm for metrics. About jlm_msbm10.xml, the metrics have likely been found in http://mirrors.ctan.org/fonts/amsfonts/tfm/msbm10.tfm Thx to tftopl, you should be able to get the metrics.

murkle commented 2 years ago

@ForNeVeR You might be interested in https://github.com/opencollab/jlatexmath/tree/experimental - we've removed all the XML files (data moved to Enums etc) for smaller code / faster loading

Also the code is structured to allow easy porting to other platforms (see desktop / share / web) so it may be possible to port with eg https://www.tangiblesoftwaresolutions.com/product_details/java_to_csharp_converter.html

ForNeVeR commented 2 years ago

@murkle, thanks, I've taken a look at the branch.

It doesn't still answer the question about how exactly the data was generated: it seems it was just moved from XML to Java files, and I wasn't able to find the script (or was there a script?) which may be used to extract the data from the .tfm files.