Re: [XeTeX] AMS/CM fonts in OpenType/CFF format

2021-11-17 Thread Marcel Fabian Krüger
On Wed, Nov 17, 2021 at 10:29:09AM +, Philip Taylor (Hellenic Institute) 
wrote:
> Many thanks for your comments, Marcel, but I am still somewhat confused. 
> The XeTeX manual says :
> 
> > This distinction between file name lookups and system font name lookups
> > is crucial
> > to understanding XƎTEX’s behavior and to writing portable documents (in
> > short: don’t
> > use system fonts).
> >     System font name lookups use (except on Mac OS X) the fontconfig
> > library; running
> > fc-list should show you the font names available. E.g.,
> > 
> >     \font\1="Liberation Serif" /look for OS-installed font/
> 
> which suggested to me that it was the string quotes that were forcing XeTeX
> to look for an OS-installed (i.e., system) font. And when I try :

Looking at the code again I realized that the quotes actually *do* make
a difference: If the name is quoted XeTeX will first look for a system
font and use a TFM font only if no system font is found, if the name is
not quoted it will forst look for a TFM font.

If you want a IMO clearer syntax, you can use LuaTeX with luaotfload.
There we still emulate the XeTeX like syntax, but additionally allow you
explicitly state how the font should be looked up, e.g.

\font \cmr {name:cmr10} \cmr % Untested, LuaTeX with luaotfload only.
 % Quotes would work too.
 % So would omitting both in this case.

> 
> > \font \cmr = "cmr10:"
> > 
> > \cmr
> > 
> > The quick brown fox jumps right over the laxy dog's back.
> > 
> > \end
> > 
> 
> I am told :
> 
> > This is XeTeX, Version 3.141592653-2.6-0.93 (TeX Live 2021/W32TeX)
> > (preloaded format=xetex)
> > 
> > restricted \write18 enabled.
> > 
> > entering extended mode
> > 
> > (./untitled-5.tex
> > 
> > ! Font \cmr=cmr10: not loadable: Metric (TFM) file or installed font not
> > found.
> > 
> > 
> > 
> > \cmr
> > 
> > l.4 \cmr
> > 
> > ?
> > 
> 
> As reported earlier, Tom's "cmr10.otf" /is/ installed, but your suggested
> syntax appears not to find it.  And it is not found with "\font \cmr =
> "CMR10 Regular:", but /is/ found with \font \cmr = "CMR10:".  Curiouser and
> curiouser !

If you use name based lookup, you have to specify the actual font name.
According to otfinfo this is for cmr10.otf:

% otfinfo -i cmr10.otf
Family:  CMR10
Subfamily:   Regular
Full name:   CMR10
PostScript name: CMR10
Version: Version 1.000;hotconv 1.1.0;makeotfexe 2.6.0
Unique ID:   1.000;UKWN;CMR10
Vendor ID:   UKWN

As you can see, neither of the names is "CMR10 Regular" and also not
"cmr10". In luaotfload the lookup is case insensitive, but XeTeX uses
system libraries which will often be case sensitive.

> 
> Oh, and \font \cmr = "CMR9:" fails, so at least I have a way of forcing a
> system font to be used, even if I have to upper-case the name.  But I am
> still very concerned that \font \cmr = "CMR10.xyz:" finds the font and
> reports no error.

Well, if the same happens in luaotfload please write a bug report. If
you want someone to tell you that XeTeX's font lookup rules are nice,
consistent or intuitive you are talking with the wrong person...

Marcel


Re: [XeTeX] AMS/CM fonts in OpenType/CFF format

2021-11-17 Thread Marcel Fabian Krüger
On Tue, Nov 16, 2021 at 11:54:23AM +, Philip Taylor (Hellenic Institute) 
wrote:
> > % !TeX Program=XeTeX
> > 
> > 
> > \font \cmr = "cmr9"
> > 
> > \cmr
> > 
> > The quick brown fox jumps right over the laxy dog's back.
> > 
> > \end
> > 
> and found, to my complete surprise, that the text in cmr9 also scaled
> perfectly.  So my question is, "where is XeTeX finding a scaleable version
> of cmr9, when the only OTF file that I have installed from your suite is
> cmr10 ?".  "Start / Control Panel / Fonts" reveals that only "CMR 10
> Regular" (of your font set) is installed, and a search under
> "C:\TeX\Live\2021" finds only :
> 
> > cmr9.afm
> > cmr9.mf
> > cmr9.pfb
> > cmr9.pfm
> > cmr9.t3
> > cmr9.tfm
> 
> Is it possible that XeTeX is using the PFB version and ignoring the string
> quotes around "cmr9" that should force it to use a system font, and if so,
> must I write (/e.g.,/) \font \cmr = "[cmr10.otf]" to force XeTeX to use
> /only/ your OTF versions and to report "Font not found" if the relevant
> font(s) is/are not installed ?  TeX Live and XeTeX lists cc'd for comment.

The string quotes don't have any special meaning in XeTeX. The font name
is read using TeX's normal file scanning routine which (at least for TeX
Live) uses string quotes to allow embedding spaces in the name and then
discards them. Therefore they never reach the parts of XeTeX where the
decision between system fonts and classical fonts is made.

If you want to load the font by fontname, you can try to add a colon
instead to add an empy feature string. Then the TFM file isn't found. So
you would have e.g. `\font \cmr = "cmr10:"` (I haven't checked if the
font is actually found by that name, but if you have an OpenType font
with fontname cmr10 installed than this would work)

Marcel


Re: [XeTeX] AMS/CM fonts in OpenType/CFF format

2021-11-17 Thread Philip Taylor (Hellenic Institute)

On 17/11/2021 09:48, Marcel Fabian Krüger wrote:


The string quotes don't have any special meaning in XeTeX. The font name
is read using TeX's normal file scanning routine which (at least for TeX
Live) uses string quotes to allow embedding spaces in the name and then
discards them. Therefore they never reach the parts of XeTeX where the
decision between system fonts and classical fonts is made.

If you want to load the font by fontname, you can try to add a colon
instead to add an empy feature string. Then the TFM file isn't found. So
you would have e.g. `\font \cmr = "cmr10:"` (I haven't checked if the
font is actually found by that name, but if you have an OpenType font
with fontname cmr10 installed than this would work)


Many thanks for your comments, Marcel, but I am still somewhat 
confused.  The XeTeX manual says :


This distinction between file name lookups and system font name 
lookups is crucial
to understanding XƎTEX’s behavior and to writing portable documents 
(in short: don’t

use system fonts).
    System font name lookups use (except on Mac OS X) the fontconfig 
library; running

fc-list should show you the font names available. E.g.,

    \font\1="Liberation Serif" /look for OS-installed font/


which suggested to me that it was the string quotes that were forcing 
XeTeX to look for an OS-installed (i.e., system) font. And when I try :



\font \cmr = "cmr10:"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end



I am told :

This is XeTeX, Version 3.141592653-2.6-0.93 (TeX Live 2021/W32TeX) 
(preloaded format=xetex)


restricted \write18 enabled.

entering extended mode

(./untitled-5.tex

! Font \cmr=cmr10: not loadable: Metric (TFM) file or installed font 
not found.




\cmr

l.4 \cmr

?



As reported earlier, Tom's "cmr10.otf" /is/ installed, but your 
suggested syntax appears not to find it.  And it is not found with 
"\font \cmr = "CMR10 Regular:", but /is/ found with \font \cmr = 
"CMR10:".  Curiouser and curiouser !


Oh, and \font \cmr = "CMR9:" fails, so at least I have a way of forcing 
a system font to be used, even if I have to upper-case the name.  But I 
am still very concerned that \font \cmr = "CMR10.xyz:" finds the font 
and reports no error.


--
/Philip Taylor/



Re: [XeTeX] AMS/CM fonts in OpenType/CFF format

2021-11-16 Thread Philip Taylor (Hellenic Institute)

On 16/11/2021 11:54, Philip Taylor (Hellenic Institute) wrote:

[M]ust I write (/e.g.,/) \font \cmr = "[cmr10.otf]" to force XeTeX to 
use /only/ your OTF versions and to report "Font not found" if the 
relevant font(s) is/are not installed ?


Rather worryingly, the following reports no error and typesets scaleable 
text :



% !TeX Program=XeTeX


\font \cmr = "cmr9.otf"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end


as (even more worryingly) does


% !TeX Program=XeTeX


\font \cmr = "cmr9.xyz"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end


whilst


% !TeX Program=XeTeX


\font \cmr = "[cmr9.otf]"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end

reports an error as intended.  Is XeTeX behaving as intended/documented 
in interpreting \font \cmr = "cmr9.otf" (/or/ \font \cmr = "cmr9.xyz") 
as semantically identical to \font \cmr = "cmr9" ?


--
/Philip Taylor/



Re: [XeTeX] AMS/CM fonts in OpenType/CFF format

2021-11-16 Thread Philip Taylor (Hellenic Institute)
Tom — Seeking to test the results of your project to convert the AMS/CM 
fonts in Type 1 format to OpenType/CFF using Adobe's AFDKO, I downloaded 
the contents of your Github repository 
(https://github.com/tkacvins/CM_OTF/archive/refs/heads/master.zip), 
expanded the contents thereof and installed (under Windows) just 
"cmr10.otf".  I then asked XeTeX to process the following :



% !TeX Program=XeTeX


\font \cmr = "cmr10"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end

The TeXworks PDF previewer indicated that the resulting text scaled 
perfectly, so clearly the OTF file was being used (or so I thought).  I 
then amended the code to read :



% !TeX Program=XeTeX


\font \cmr = "cmr9"

\cmr

The quick brown fox jumps right over the laxy dog's back.

\end

and found, to my complete surprise, that the text in cmr9 also scaled 
perfectly.  So my question is, "where is XeTeX finding a scaleable 
version of cmr9, when the only OTF file that I have installed from your 
suite is cmr10 ?".  "Start / Control Panel / Fonts" reveals that only 
"CMR 10 Regular" (of your font set) is installed, and a search under 
"C:\TeX\Live\2021" finds only :



cmr9.afm
cmr9.mf
cmr9.pfb
cmr9.pfm
cmr9.t3
cmr9.tfm


Is it possible that XeTeX is using the PFB version and ignoring the 
string quotes around "cmr9" that should force it to use a system font, 
and if so, must I write (/e.g.,/) \font \cmr = "[cmr10.otf]" to force 
XeTeX to use /only/ your OTF versions and to report "Font not found" if 
the relevant font(s) is/are not installed ?  TeX Live and XeTeX lists 
cc'd for comment.


--
/Philip Taylor/





The public repository is here

https://github.com/tkacvins/CM_OTF

Feel free to add to it.  I can add contributors as necessary.

What is needed is testing, in particular if the fonts are OK
with the existing TFM files.
I am not quite sure how to get the TeX Live tools to use
OpenType fonts.  In addition,
there are some options/input files missing from my initial
creation of the fonts that will
be addressed later as I figure them out.

Enjoy!  And please feel free to open issues (as necessary) on
github and give feedback
as to whether I did anything bone headed.


Ooops, the license needs to be taken care of.  The AMS license
says all derivative works
need to have the AMS license/copyright removed.  I am hoping that
the AMS approves
the distribution of the OTF flavors of their fonts with their
copyright.  Thoughts?


Another thing that needs to be taken care of is Unicode mappings in 
the OTF.

makeotf is botching it when making the cmap table in the OTF fonts because
of the custom encodings of the amsfonts.  Things are not mapping properly.
There is a way around this using an optional file for makeotf that 
handles the

glyph to code mapping, but I have had some problems even with that.  Still
trying to work it out with the AFDKO folks.