2

So here is the problem I have: I am using fontspec and a number of my fonts have lining figure only in the small caps font. So my question is how can I tell XeLaTeX that when it comes to numbers (section numbering, footnotes, ...) to get it from those files? Rather than the regular font file it uses for everything else? Is there a command like \setfigurefont?

Hesam
  • 1,971
  • Can you give a Minimal Working Example? Your question is tagged as opentype but the fonts you are describing sound more like traditionally arranged type 1 fonts with a separate "expert" font - except that the oldstyle figures are often the ones in that font. (There is a straightforward solution for such cases in regular LaTeX, at least, though maybe not XeLaTeX.) In any case, an example will help people play around with ideas. – cfr Dec 24 '13 at 00:50
  • Some fonts, (Scala & Eureka for example), have separate .otf files for small caps and the lining figures only appear in those. The .otf file for the regular font, has only old style numbers in it. So for example '1' produces an old style number while '{\sc 1}' produces a lining version of it. – Hesam Dec 24 '13 at 04:58
  • As for an example, it depends on the font, so I don't know what I should post. Fonts with better structured .otf files (for example they have separate fontLF.otf files for the version with lining figures) don't have this problem. Essentially I am asking whether XeLaTeX or fontspec have some tool that I can use to overcome the way .otf files are set. – Hesam Dec 24 '13 at 05:02
  • Well FF Eureka opentype fonts seem to include the small-caps and alternate figure styles in the same font as the standard upper and lower case. – cfr Dec 24 '13 at 23:30
  • Yes, that is my problem! The regular figure style only appears in the small caps .otf file. – Hesam Dec 25 '13 at 20:46
  • Well, no. The FF Eureka opentype fonts do not have this problem because everything is in one file. So you can switch to e.g. lining figures using the normal methods. (At least, I assume the font has this feature - I'd have to buy the fonts to check so I can't be certain.) But the lining figures are in the same .otf as the regular upper and lower case (as are the small caps). Either you have a different font with the same name or an older or converted version. Note that without a free font demonstrating the issue it will be hard for people to investigate solutions. – cfr Dec 25 '13 at 21:16
  • We need a minimal working example with details about exactly which Eureka and Scala versions you have: OT Std? OT Pro? Offc Std? Offc Pro? Web Std? Web Pro? App+ Std? App+ Pro? What’s possible will depend on the version. But generally, for footnotes, you should use realscripts. – Thérèse Dec 25 '13 at 21:36
  • @cfr: I don't have a single .otf file, I have a bunch. I am using fontspec and basically what I want to accomplish with XeLaTeX is whenever it sees a number to use the appropriate small caps version. – Hesam Dec 26 '13 at 02:56
  • You can do this in LaTeX (with type 1 fonts) or pdfLaTeX (with truetype or type 1 fonts) but I just don't think this is possible with Xe(La)TeX. However, more details about your setup might suggest some sort of workaround. Certainly you could use a command to produce the numbers e.g. by typing \textlf{8,9076) or something you could get lining figures and you could use this for page numbers, footnote markers etc. automatically. But I don't think there is an easy way to type "The 56 quick brown foxes" in regular case and get lining figures if you wish to use XeTeX. – cfr Dec 26 '13 at 03:32
  • The only way to do what you want automatically (apart from editing the fonts in a font editor) is to make the numbers active characters and make them switch to different font, but this is likely to break all sorts of things. – خالد حسني Jan 01 '14 at 11:52

2 Answers2

1

It’s probably better to patch the commands that output numbers (alongside punctuation and maybe uppercase letters). It might become tedious to list them all, though, so perhaps you should go for \arabic directly:

\newfontfamily\myLFfont[Numbers=Lining]{fontLF.otf} 
\let\arabicnumber\arabic
\def\arabic{\myLFfont\arabicnumber}
Crissov
  • 1,866
  • I doubt you need Numbers=Lining and I doubt it will have any effect. Would it work without that? – cfr Jan 01 '14 at 23:30
  • I actually agree this is a better idea although it means that typing 0123456789 in your document will require typing {\myLFfont 0123456789) or whatever. But if what you want is to just be able to make your choice once and forget about it, you have to do something much more elaborate. (Unless I've really misunderstood your suggestion.) And I took it that the OP was not content with the idea of having a command to get lining figures which I suggested would be pretty straightforward in a comment on the original question. – cfr Jan 01 '14 at 23:56
  • Sure, this only deals with the examples the OP gave (“section numbering, footnotes, …”). If Hesam is using siunitx some more numbers can be dealt with, because that package lets users choose different fonts for number and unit, e.g. \sisetup{number-text-rm = \myLFfont, …, unit-math-rm = \myfont, …}. Alas, the question lacks details in this regard. – Crissov Jan 02 '14 at 09:51
0

Posting this here so I can include code.

Does this question (especially the second answer) help at all? If you have a setup for LaTeX, it looks like you might be able to combine that with fontspec using something like the code suggested here:

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\unicodefont{Lucida Grande}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\begin{document}
A legacy \TeX\ font. {\unicodefont A unicode font.}
\end{document}

If the licence allows it, converting the fonts to type1 format and generating support files for LaTeX or pdfLaTeX would likely be easiest since there are no real advantages to using the opentype fonts and XeLaTeX in this situation and doing so just complicates things.

Whether you can convert the fonts themselves to type1 or not, you could do the following:

  1. Generate .afm files for the fonts. This will give you something which e.g. fontinst knows how to deal with.
  2. Use the instructions in Philipp Lehman's Font Installation Guide but create virtual fonts which take the lining (rather than oldstyle) figures from the small-caps fonts since that's how your files are organised. Tutorial 3 explains how to do this though you will need to read through the earlier tutorials if you are not familiar with fontinst.
  3. This will allow you to create the files you need to use virtual fonts containing the lining figures and you can then simply use the appropriate families when typesetting your document.
  4. You will want to install the fonts properly for TeX although for testing you can just have everything in your working directory and it should work.

I assume that if you are using XeLaTeX this will let you utilise the lining figures from the opentype sc font together with the regular upper and lower case from the standard upright opentype font. If you are permitted to convert them, creating type1 fonts will give you greater flexibility since you'll be able to use them with regular LaTeX as well.

I understand LuaTeX can create virtual fonts on the fly so you might also look into that possibility although I don't know how that works or if it would offer you an easier solution in this particular case.

You will lose access to any opentype features of the fonts you have. However, from your description of the fonts I suspect that this will lose you little if anything. It doesn't sound as if the fonts have been configured to make use of the features opentype offers and you can't use features the fonts don't have in any case. (If they were constructed with opentype in mind, I'd expect the different styles of figures to be included in the same font and enabled as opentype features. That would make things much easier but is not, unfortunately, what you actually have.)

cfr
  • 198,882
  • XeTeX can use any type of fonts. There can be some problems when output font encodings are involved, because fontspec expects EU1. – egreg Jan 01 '14 at 10:19
  • If you are taking the trouble to modify the font, then why not just generate an OpenType fonts instead of going backwards are writing tens of support files in arcane formats? – خالد حسني Jan 01 '14 at 23:02
  • @KhaledHosny You are not modifying the fonts themselves. It is likely that the licence of these fonts prohibits modifying them. However, it is usually permitted to generate AFM/TFM files and VF fonts provided you don't interfere with the original type1/truetype/opentype fonts themselves. Not necessarily, of course. But often this is the case. This is why it is OK to install commercial fonts bringing characters from expert-encoded type1 together with those from the regular font in a virtual font even though it would be illegal to actually create a type1 font with the characters you need. – cfr Jan 01 '14 at 23:23
  • @KhaledHosny IF the licence permits modification of the original fonts, obviously you could instead combine characters from the two fonts to create a new font containing regular lower and upper case with lining figures. But these are not free fonts and it is likely that their licence is somewhat restrictive. Now it might be that the fonts allow modification for personal use. But that would be unusual - I've never seen a font licence of that sort for commercial, shareware or even freeware fonts. Moreover, you can probably share the generated TFM and VF files legally. – cfr Jan 01 '14 at 23:25
  • Converting from CFF-OTF (or TrueType) to Type1 is modification, so there is no difference unless the license permits this but not other types of modification (which is unlikely). BTW, Adobe license usually permits modifying their fonts for internal use (i.e. as long as you don’t distribute it to others, including other licensees). – خالد حسني Jan 02 '14 at 11:14
  • @KhaledHosny I was assuming you could use the opentype fonts via the virtual fonts i.e. not actually convert the fonts themselves at all. Usually generating afm/tfm files is not considered modification. If xetex can't use virtual fonts with opentype, though, you couldn't do it this way (unless the licence does permit modification but then, as you say, you could modify the font itself - not what I'd do because it would be easier for me to do it this way but that might well be untrue for the OP). – cfr Jan 02 '14 at 14:17
  • I did not try using OpenType fonts with virtual fonts in XeTeX, to be honest, but I guess it might work if you treat the OpenType font as just a big Type1 font and prepare TFM files, encodings, map files etc, xdvipdfmx might be able to include them in the PDF (but you lose all OpenType capabilities of course). – خالد حسني Jan 02 '14 at 14:29
  • @KhaledHosny Yes and that would usually be a big disadvantage. In this case, as I say in the answer, it might not be because it does not sound as if these fonts were prepared to use the features of opentype in the first place. But, of course, we don't know enough about the fonts to be sure. – cfr Jan 02 '14 at 15:33