From 454ffe8707ea8f85fc489c5f538aa73499af4cde Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Sat, 27 Jan 2018 16:51:49 +0700 Subject: [PATCH] Add information about DefaultTexFont.xml (#70) --- README.md | 6 ++++ docs/prepare-font.md | 84 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 561e455a..a6679440 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ For a more detailed sample, check out the [example project][example]. It shows t ![Screenshot of example project](docs/example-screenshot.png) +Documentation +------------- + +- [How to prepare `DefaultTexFont.xml` from the font file][docs-prepare-font] + History ------- @@ -30,6 +35,7 @@ The project code is licensed under the terms of [MIT license][license]. The orig The [fonts][] `cmex10.ttf`, `cmmi10.ttf`, `cmr10.ttf`, and `cmsy10.ttf` and `cmtt10.ttf` are under the [Knuth License][knuth-license]. +[docs-prepare-font]: docs/prepare-font.md [example]: WpfMath.Example/ [fonts]: src/WpfMath/Fonts/ [gpl]: docs/JMathTeX-license.txt diff --git a/docs/prepare-font.md b/docs/prepare-font.md index b16fc38a..24dd38c1 100644 --- a/docs/prepare-font.md +++ b/docs/prepare-font.md @@ -1,5 +1,17 @@ -How to prepare XML from TTF -=========================== +How to prepare `DefaultTexFont.xml` from the font file +====================================================== + +This document describes the correspondence between the font files we use and +data in `DefaultTexFont.xml`. The conrete approach (e.g. script files to +regenerate XML data) wasn't reproduced yet, although we were able to get nearly +all the required information. + +Data in our XML files is often inaccurate and/or seemlingly generated from other +TTF files than the files in the repository. Be prepared for that. When in doubt, +refer to [the original tfm files][tfm] (they seem to correspond to our data +better than the TFM files generated from our TTF files). + +There're two helpful tool sets to work with our TTF files: 1. To gather font metrics: ```console @@ -11,13 +23,77 @@ How to prepare XML from TTF `ttf2tfm` and `tftopl` are parts of the standard TeX distribution (at least TeX Live). -2. May be helpful: +2. It may be helpful to use [ttx][] utility to get some additional information + about the font (e.g. mapping from characters to codes in the font file): ```console $ ttx filename.ttf ``` That will generate `filename.ttx` (XML). - [ttx][] +For example, there's the following in `DefaultTexFont.xml`: + +```xml + + + + + +``` + +To get these values from the `cmmi10.tpl` file, search for the following: + +``` +(FONTDIMEN + (SLANT R 0.25) + (SPACE R 0.0) + (STRETCH R 0.0) + (SHRINK R 0.0) + (XHEIGHT R 0.430555) + (QUAD R 1.000003) + ) + +… + +(CHARACTER C A + (CHARWD R 0.750002) + (CHARHT R 0.683332) + (COMMENT + (KRN O 177 R 0.138893) + ) + ) +``` + +Here, `CHARWD` corresponds to `width`, `CHARHT` corresponds to `height`, +`CHARDP` corresponds to `depth`, and `CHARIC` corresponds to `italic`. Any of +them could be ommited. + +Kerning section could also be reconstructed from the `*.tpl` file. + +How to know that `O 177` is the same as `code="196"`? To do that, first look +into `cmmi10.vpl` file: there's the following entry: + +``` +(CHARACTER O 177 (comment dieresis) + (CHARWD R 583) + (CHARHT R 705) + (CHARIC R 118) + (MAP + (SETCHAR O 151) + ) + ) +``` + +That means that `O 177` is named `dieresis`. Then, open [Adobe Glyph +List][glyphlist] and search for the `dieresis` name: + +``` +dieresis;00A8 +``` + +It means that `O 177` should be character `0xa8` or `168`, not `196`. The reason +for that contradiction is currently unknown. +[glyphlist]: https://github.com/adobe-type-tools/agl-aglfn/blob/5de337bfa018e480bf15b77973e27ccdbada8e56/glyphlist.txt +[tfm]: https://ctan.org/texarchive/fonts/cm/tfm [ttx]: https://github.com/fonttools/fonttools