I think this question has popped up before, but I couldn't find it. When I try to typeset any LaTeX document with the default T1 fonts, I get the following error: ! Font \T1/cmr/m/n/10=ecrm1000 at 10pt not loadable: metric data not found or bad. LuaTeX finds the file (as kpse.find_file shows) and in fact it should find it, because I have a copy in the local directory. If I switch to another font (ae, mathmazo, etc.) it works fine and I was able to typeset several documents by using the process_input_buffer to convert the 8-bit input to a pseudo utf8 text which can be applied inputenc to (ie, with active characters). Just a dirty trick, of course, but it worked. Another question. Has someone attempted to make LuaTeX/LaTeX compatible with existing T1 and the like fonts? (without using active characters, I mean). After reading the manual for 0.29 I've inferred this part is still under development. I'm reading the lua files from ConTeXt, so I presume I'll have more questions soon. Any further pointers? I'm interested mainly in LaTeX (LuaLaTeX?). Thanks Javier ------------------------- http://www.tex-tipografia.com
Hello, unfortunately I cannot help you with the error you're getting, but:
Another question. Has someone attempted to make LuaTeX/LaTeX compatible with existing T1 and the like fonts? (without using active characters, I mean). After reading the manual for 0.29 I've inferred this part is still under development.
I would think you would have to create a "define_font"-callback to do the following: 1. Read the TFM file manually into a Lua table. 2. Re-map the glyphs according to the font's encoding (T1 ...) to Unicode. 3. Return the new table. Then, when typesetting Unicode characters, these will be mapped onto the correct glyphs in the font. You could even create an artificial font (see the manual) to create glyphs missing in the font (but existing as characters in Unicode) from existing ones.
I'm reading the lua files from ConTeXt, so I presume I'll have more questions soon. Any further pointers? I'm interested mainly in LaTeX (LuaLaTeX?).
I found this document quite interesting (not LaTeX, though): http://pragma-ade.com/general/manuals/mk.pdf
Thanks Javier
HTH, Jonathan
Thank you, Jonathan:
I would think you would have to create a "define_font"-callback to do the following:
1. Read the TFM file manually into a Lua table. 2. Re-map the glyphs according to the font's encoding (T1 ...) to Unicode. 3. Return the new table.
Actually, point 1 should read "TFM fileS", because in LaTeX a font is in fact two tfm's. For example, a text in Latin script uses T1 (letters) and TS1 (symbols). This is the way to go, it seems. But just for not reinventing the wheel, has someone worked on that?
I'm reading the lua files from ConTeXt, so I presume I'll have more questions soon. Any further pointers? I'm interested mainly in LaTeX (LuaLaTeX?).
I found this document quite interesting (not LaTeX, though): http://pragma-ade.com/general/manuals/mk.pdf
This document is very useful, indeed. I'm reading font-def.lua too. Very likely many techniques are format independent. In fact, this is one of the aims stated in luatools.lua: -- Although this script is part of the ConTeXt distribution it is -- relatively indepent of ConTeXt. The same is true for some of -- the luat files. We may may make them even less dependent in -- the future. (Thank you for this, Hans.) Javier
Hello,
I would think you would have to create a "define_font"-callback to do the following:
1. Read the TFM file manually into a Lua table. 2. Re-map the glyphs according to the font's encoding (T1 ...) to Unicode. 3. Return the new table.
Actually, point 1 should read "TFM fileS", because in LaTeX a font is in fact two tfm's. For example, a text in Latin script uses T1 (letters) and TS1 (symbols).
Well, that depends on the text ;-) Generally speaking, since font encodings are a workaround for the 256 glyph limitation of tfm files, most likely you will indeed combine several tfm files with different encodings into a single font. Not just T1 and TS1, but also other encodings.
This is the way to go, it seems. But just for not reinventing the wheel, has someone worked on that?
Context has some tfm font loading code. I only use OpenType fonts. Maybe you can use code from the LuaTeX wiki as a start: http://luatex.bluwiki.com/
Javier
Jonathan
Below is my first attempt, which reencodes a T1 font to Unicode (still a hack for testing). Accents are misplaced and there is an error: Error in processing VF font (ptmr8t.vf): invalid character code, virtual font will be ignored but I have no idea what's wrong. At least, kerns and ligatures seem to be right. (With 0.29 for Windows.) Javier =================================== \documentclass{book} \pdfoutput=1 % \nonstopmode \directlua0{\unexpanded{ dofile('context/l-table.lua') fonts = fonts or {} fonts.encodings = fonts.encodings or {} fonts.encodings["T1"] = { [0] = 0x0300, 0x0301, 0x0302, 0x0303, 0x0308, 0x030B, 0x030A, 0x030C, 0x0306, 0x0304, 0x0307, 0x0327, 0x0328, 0x201A, 0x2039, 0x203A, 0x201C, 0x201D, 0x201E, 0x00AB, 0x00BB, 0x2013, 0x2014, 0xFFFE, 0xFFFE, 0x0131, 0x0237, 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04, 0x2423, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2019, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x2018, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2010, 0x0102, 0x0104, 0x0106, 0x010C, 0x010E, 0x011A, 0x0118, 0x011E, 0x0139, 0x013D, 0x0141, 0x0143, 0x0147, 0x014A, 0x0150, 0x0154, 0x0158, 0x015A, 0x0160, 0x015E, 0x0164, 0x0162, 0x0170, 0x016E, 0x0178, 0x0179, 0x017D, 0x017B, 0x0132, 0x0130, 0xFFFE, 0x00A7, 0x0103, 0x0105, 0x0107, 0x010D, 0x010F, 0x011B, 0x0119, 0x011F, 0x013A, 0x013E, 0x0142, 0x0144, 0x0148, 0x014B, 0x0151, 0x0155, 0x0159, 0x015B, 0x0161, 0x015F, 0xFFFE, 0x0163, 0x0171, 0x016F, 0x00FF, 0x017A, 0x017E, 0x017C, 0x0133, 0x00A1, 0x00BF, 0x00A3, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0152, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0xFFFE, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0153, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00DF } function fonts.tounicode(name, size) texio.write_nl('Reencoding ' .. name) local f = font.read_tfm('ptmr8t', size) local vf = font.read_vf('ptmr8t', size) local u = {} u.name = name u.encodingbytes = 2 u.type = 'virtual' u.fonts = table.copy(vf.fonts) for k, v in pairs(f) do texio.write_nl(k) if k == 'characters' then enc = fonts.encodings['T1'] u.characters = {} for char_k, char_v in pairs(v) do char_uni = enc[char_k] u.characters[char_uni] = table.copy(v[char_k]) u.characters[char_uni].commands = table.copy(vf.characters[char_k].commands) if char_v.kerns then bk = {} for kern_k, kern_v in pairs(char_v.kerns) do bk[enc[kern_k]] = kern_v end u.characters[char_uni].kerns = table.copy(bk) end if char_v.ligatures then bl = {} for lig_k, lig_v in pairs(char_v.ligatures) do bl[enc[lig_k]] = {} bl[enc[lig_k]].char = enc[lig_v.char] bl[enc[lig_k]].type = lig_v.type end u.characters[char_uni].ligatures = table.copy(bl) end end elseif type(v) == 'table' then u[k] = table.copy(v) else u[k] = v end end return u end callback.register('define_font', function (name, size) if name == 'ptmr0u' then f = fonts.tounicode(name, size) else f = font.read_tfm(name, size) end % show_font(f) return f end) function show_font(f) for n, c in pairs(f.characters) do texio.write_nl('pos: ' .. n) for ck, cv in pairs(c) do if ck == 'kerns' then texio.write_nl(' kerns:') for kk, kv in pairs(cv) do texio.write_nl(' ' .. kk .. ': ' .. kv) end elseif ck == 'commands' then texio.write_nl(' commands:') for kk, kv in pairs(cv) do texio.write_nl(' ' .. kk .. ': ' .. kv[1] .. ',' .. (kv[2] or ''))% end elseif ck == 'ligatures' then texio.write_nl(' ligatures:') for lk, lv in pairs(cv) do texio.write_nl(' ' .. lk .. ':') for lck, lcv in pairs(lv) do texio.write(' ' .. lck .. ': ' .. lcv) end end elseif type(cv) == 'string' or type(cv) == 'number' then texio.write_nl(' ' .. ck .. ': ' .. cv) end end end end }} \begin{document} \font\nf=ptmr0u \nf Hola æo AV uU fl office AVa ß - \end{document}
Javier Bezos wrote:
Below is my first attempt, which reencodes a T1 font to Unicode (still a hack for testing). Accents are misplaced and there is an error:
Error in processing VF font (ptmr8t.vf): invalid character code, virtual font will be ignored
but I have no idea what's wrong. At least, kerns and ligatures seem to be right. (With 0.29 for Windows.)
You are copying the value of f.type into u.type before returning the table (in the the for loop) so the font is never registered as 'virtual' and consequently luatex tries to do vf resolving on its own. But because you have already reencoded the base font, the values in the vf no longer make sense. This is harmless for the 'type', but bad for 'encodingbytes'. You should move
u.encodingbytes = 2 u.type = 'virtual'
to the end of the tounicode function Best wishes, Taco
Javier Bezos wrote:
I think this question has popped up before, but I couldn't find it. When I try to typeset any LaTeX document with the default T1 fonts, I get the following error:
! Font \T1/cmr/m/n/10=ecrm1000 at 10pt not loadable: metric data not found or bad.
LuaTeX finds the file (as kpse.find_file shows) and in fact it should find it, because I have a copy in the local directory.
This is simply a bug in the TFM reader, somehow ecrm100.tfm confuses it. I have to investigate further, but it should definately run just like it used to in (pdf)tex. Last night I got back from TUG2008 in Cork and I need to time to get back up to speed with my email; answers to the rest of your questions and the other emails will follow over the next few days. Best wishes, Taco
LuaTeX finds the file (as kpse.find_file shows) and in fact it should find it, because I have a copy in the local directory.
This is simply a bug in the TFM reader, somehow ecrm100.tfm confuses it. I have to investigate further, but it should definately run just like it used to in (pdf)tex.
Thank you, Tako. I'm just got a copy of Beginning Lua (Wrox) and having a lot of fun. Javier
Javier Bezos wrote:
I think this question has popped up before, but I couldn't find it. When I try to typeset any LaTeX document with the default T1 fonts, I get the following error:
! Font \T1/cmr/m/n/10=ecrm1000 at 10pt not loadable: metric data not found or bad.
It turns out that luatex should ignore trailing junk in tfm files, because that is what TeX itself does. There is a luatex fix in svn (or you could run tftopl + pltotf on the ec fonts). Best wishes, Taco
participants (3)
-
Javier Bezos
-
Jonathan Sauer
-
Taco Hoekwater