jlatexmath icon indicating copy to clipboard operation
jlatexmath copied to clipboard

How to generate metric xml file from ttf file

Open mhao1999 opened this issue 2 years ago • 6 comments

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" />

mhao1999 avatar May 25 '22 08:05 mhao1999

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

calixteman avatar May 25 '22 08:05 calixteman

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!

mhao1999 avatar May 25 '22 13:05 mhao1999

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.

ForNeVeR avatar May 30 '22 16:05 ForNeVeR

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.

calixteman avatar May 30 '22 16:05 calixteman

@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

murkle avatar Jun 01 '22 10:06 murkle

@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.

ForNeVeR avatar Jun 01 '22 15:06 ForNeVeR