Script to automatically generate typescripts
Hi all, after spending many hours on a typescript only to accidentally delete it, I thought that there should be a better way to write them. Hence I wrote a python script to do just that. It started out as a private project, but I thought that since it might be useful to others, I'd make it available publicly. You can get hold of it here: http://github.com/murphy-md/otftsmrk Note that it currently only works on Adobe .otf fonts (and this likely won't change), and that you need to be using LuaTeX with MkIV, since I don't do any of the encoding stuff. Please send me bug reports / feature requests if you use it! -- Michael Murphy
On Thu, Jun 3, 2010 at 6:51 PM, Michael Murphywrote: > Hi all, > > after spending many hours on a typescript only to accidentally delete it, I > thought that there should be a better way to write them. Hence I wrote a > python script to do just that. Two notes 1) is it different from simplefonts (cfr. http://modules.contextgarden.net/simplefonts) ? 2) why python ? We have lua in luatex; mkiv has a lot of lua code about fonts. Please consider that I don't want to discourage anyone about anything (I know is always hard to write programs). -- luigi
On Fri, Jun 4, 2010 at 09:32, luigi scarso wrote:
2) why python ? We have lua in luatex; mkiv has a lot of lua code about fonts.
Hmmm ... the guy who spent most of his time in community trying to make python work with ConTeXt is now complaining about the programming language? Come on ... :) Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason. But if the script proves to be useful, it's still short enough that anyone could convert it to Lua to get rid of dependencies on yet another language. Mojca
On Fri, Jun 4, 2010 at 10:03 AM, Mojca Miklavec
On Fri, Jun 4, 2010 at 09:32, luigi scarso wrote:
2) why python ? We have lua in luatex; mkiv has a lot of lua code about fonts.
Hmmm ... the guy who spent most of his time in community trying to make python work with ConTeXt is now complaining about the programming language? Come on ... :) I'm not say that it's wrong. It's the same as if I write a lua script to do "XYZ" for Plone: why ? There are a lot of python code in Plone that probably can be used to do "XYZ".
Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason. But if the script proves to be useful, it's still short enough that anyone could convert it to Lua to get rid of dependencies on yet another language.
A python's programmer has no problem to write a lua version
(and a javascript programmer too, as Mathias Nater showed to me)
The key point here is the dependency on another language:
for luatex it's almost useless
to use a scripting/dynamic language other than lua
(I hope one day we will end without ruby and perl for mkiv too, if reasonable) .
Of course perl, ruby. python,
On 4-6-2010 10:23, luigi scarso wrote:
(I hope one day we will end without ruby and perl for mkiv too, if reasonable) .
not much perl used in context tools nowadays and not that much ruby either in mkiv related tools
Of course perl, ruby. python,
are all goods programming languages but mixing them together not always make a good pie .
italian restaurants in NL have quite some choices in pizza .. any combination possible -) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 4-6-2010 10:03, Mojca Miklavec wrote:
On Fri, Jun 4, 2010 at 09:32, luigi scarso wrote:
2) why python ? We have lua in luatex; mkiv has a lot of lua code about fonts.
Hmmm ... the guy who spent most of his time in community trying to make python work with ConTeXt is now complaining about the programming language? Come on ... :)
Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason. But if the script proves to be useful, it's still short enough that anyone could convert it to Lua to get rid of dependencies on yet another language.
indeed; th ecore programs with context are on lua as it makes us independent of other installed programs but additional tools can be in any language (perl, ruby, python etc) in that sense i think that Michael's script is for otf what texfont.rb is/was for type 1 so it's a nice addition i'm not sure if a binary is needed as most users can simply install python Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Jun 4, 2010 at 10:37 AM, Hans Hagen
On 4-6-2010 10:03, Mojca Miklavec wrote:
Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason. But if the script proves to be useful, it's still short enough that anyone could convert it to Lua to get rid of dependencies on yet another language. sorry, but you can not program PIC controller with bash just because you know bash better than assembly
indeed; th ecore programs with context are on lua as it makes us independent of other installed programs but additional tools can be in any language (perl, ruby, python etc) Other languages are fine of course, but in this context lua is best choice. Lua is all we need.
-- luigi
On 04/06/2010 10:50, luigi scarso wrote:
On Fri, Jun 4, 2010 at 10:37 AM, Hans Hagen
wrote: On 4-6-2010 10:03, Mojca Miklavec wrote:
Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason.
As I said, it started out as a private project, but just wanted to see if others found it useful. It is not at all like the 'simplefonts' module, since it has absolutely no integration with ConTeXt. It simply reads in .otf files and spits out typescripts, which can then be used in ConTeXt. I will try to get an .exe out in the next few days. I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font, rather than trying to work it out from the filename. This might mean being able to use fonts other than those from Adobe, which would be nice. -- Michael Murphy
On Fri, Jun 4, 2010 at 12:00 PM, Mojca Miklavec
On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font
Just note: you can get an enormous amount of font information with luatex. Just a note x you : where is showttf ?
-- luigi
On 04/06/2010 12:00, Mojca Miklavec wrote:
On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font
Just note: you can get an enormous amount of font information with luatex.
If you can get so much information out of LuaTeX, why do we need typescripts in the first place? -- Michael Murphy
On Fri, Jun 4, 2010 at 18:08, Michael Murphy wrote:
On 04/06/2010 12:00, Mojca Miklavec wrote:
Just note: you can get an enormous amount of font information with luatex.
If you can get so much information out of LuaTeX, why do we need typescripts in the first place?
1.) The typescripts have been written long before LuaTeX existed. 2.) The typescripts still work is almost exactly the same way as they did before 3.) Your can read a lot of information about a specific font (which features are available, which glyphs exist etc. etc. etc.), but that still doesn't give you any information about which fonts you want to combine together and which features you want to use. Take Antykwa Półtawskiego. It comes as regular/italic, in 4 weights (light, normal, medium, bold), in 5 widths (extended, semi-extended, normal, semi-condensed, condensed), about 5 encodings for MKII. You need to tell to ConTeXt somehow whether you want to combine light and medium or normal weight and bold, or maybe normal with semi-extended bold, you may want the size to adapt automatically when you change font size. There is also no reliable way to determine which fonts belong together. You still need to assign a font with a variant somehow. Reading info about a font doesn't really solve the problem of "being able to automatically assign rm, bf, bi etc.", but I admit that there *IS* room for improvement for font handling mechanism in a more user-friendly way (and lua can be of enormous help of course). Mojca
On 4-6-2010 6:08, Michael Murphy wrote:
On 04/06/2010 12:00, Mojca Miklavec wrote:
On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font
Just note: you can get an enormous amount of font information with luatex.
If you can get so much information out of LuaTeX, why do we need typescripts in the first place?
because it's the only watertight way; other approaches use heuristics it all depends on the situation Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Jun 4, 2010 at 11:52 AM, Michael Murphy
I will try to get an .exe out in the next few days. I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font, rather than trying to work it out from the filename. This might mean being able to use fonts other than those from Adobe, which would be nice. You can also see ttx: is written in python http://sourceforge.net/projects/fonttools/
-- luigi
On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
As I said, it started out as a private project, but just wanted to see if others found it useful.
What about presenting your work at the ConTeXt conference and in MAPS magazine? You'll be able to meet the biggest ConTeXt gurus there, learn a lot from them, Luigi will give you a short lesson on "Why I switched from Python to Lua" and "The first few steps in Lua for font lovers" and you should be able to work the author of "simplefonts" module face-to-face to join the best of his and your work ... We might even have an official discussion on the schedule about typescripts and how to simplify and/or improve them. And of course the delicious Czech beer ... http://meeting.contextgarden.net/ Mojca
On 4-6-2010 12:21, Mojca Miklavec wrote:
We might even have an official discussion on the schedule about typescripts and how to simplify and/or improve them.
.. and how those hugs polish font collections spoil any systematic approach -) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Jun 4, 2010 at 12:21 PM, Mojca Miklavec
On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
As I said, it started out as a private project, but just wanted to see if others found it useful.
What about presenting your work at the ConTeXt conference and in MAPS magazine?
You'll be able to meet the biggest ConTeXt gurus there, learn a lot from them, Luigi will give you a short lesson on "Why I switched from Python to Lua" "Because it's better That's all folks -- free time now"
The best presentation ever, even better than Taco's one at last eurotex meeting. I switched from python to Lua x context, this is true; I'm still using it for other tasks, particularly Plone, and sometimes sagemath. It's not a bad language at all. -- luigi
On Fri, Jun 04, 2010 at 12:29:32PM +0200, luigi scarso wrote:
On Fri, Jun 4, 2010 at 12:21 PM, Mojca Miklavec
wrote: On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
As I said, it started out as a private project, but just wanted to see if others found it useful.
What about presenting your work at the ConTeXt conference and in MAPS magazine?
You'll be able to meet the biggest ConTeXt gurus there, learn a lot from them, Luigi will give you a short lesson on "Why I switched from Python to Lua" "Because it's better That's all folks -- free time now"
The best presentation ever, even better than Taco's one at last eurotex meeting.
I switched from python to Lua x context, this is true; I'm still using it for other tasks, particularly Plone, and sometimes sagemath. It's not a bad language at all.
When it comes to writing non-luatex code, I'll pick python anytime of the day, a light language with almost no standard library is not what one always need. -- Khaled Hosny Arabic localiser and member of Arabeyes.org team Free font developer
On 04/06/2010 13:16, Khaled Hosny wrote:
On Fri, Jun 04, 2010 at 12:29:32PM +0200, luigi scarso wrote:
On Fri, Jun 4, 2010 at 12:21 PM, Mojca Miklavec
wrote: On Fri, Jun 4, 2010 at 11:52, Michael Murphy wrote:
As I said, it started out as a private project, but just wanted to see if others found it useful.
What about presenting your work at the ConTeXt conference and in MAPS magazine?
You'll be able to meet the biggest ConTeXt gurus there, learn a lot from them, Luigi will give you a short lesson on "Why I switched from Python to Lua" "Because it's better That's all folks -- free time now"
The best presentation ever, even better than Taco's one at last eurotex meeting.
I switched from python to Lua x context, this is true; I'm still using it for other tasks, particularly Plone, and sometimes sagemath. It's not a bad language at all.
When it comes to writing non-luatex code, I'll pick python anytime of the day, a light language with almost no standard library is not what one always need.
Oh God, I really didn't want to generate all this fuss, it's really a _very_ primitive script. If I have more time, I'll certainly look into Lua, but I chose Python because: a. it handles complicated string operations, io, regex, etc right out of the box, all of which were needed. b. I'm slightly above noob level with python, as opposed to almost every other language (except Fortran, which was not exactly a front-runner) c. I'm rather more than ignorant about almost every other font tool out there I just reckoned that there has got to be a good way of automatically writing those long, complicated typescripts. I did start such a thing in emacs, but then realised that its not a very portable solution (although I do have a whole bunch of macros for converting LaTeX and AMSmath code into ConTeXt if anyone is interested). -- Michael Murphy
On Fri, Jun 4, 2010 at 11:52, Michael Murphy
On 04/06/2010 10:50, luigi scarso wrote:
On Fri, Jun 4, 2010 at 10:37 AM, Hans Hagen
wrote: On 4-6-2010 10:03, Mojca Miklavec wrote:
Whenever I write something I use the language I master most (even if it's not the most suitable language for that task), so I guess that must be the reason.
As I said, it started out as a private project, but just wanted to see if others found it useful. It is not at all like the 'simplefonts' module, since it has absolutely no integration with ConTeXt. It simply reads in .otf files and spits out typescripts, which can then be used in ConTeXt.
I will try to get an .exe out in the next few days. I'm also starting to think that it might be possible to use otfinfo from the lcdf typetools to get information about a font, rather than trying to work it out from the filename. This might mean being able to use fonts other than those from Adobe, which would be nice.
Although a Perl user, I like your Python script, Michael ! Thanks
Michael Murphy <> wrote on Thursday, June 03, 2010 6:52 PM:
Please send me bug reports / feature requests if you use it!
Thank you for this script. I'm sure I'll have good use of it! I just did a quick test with Myriad Pro, and it works nicely. Some minor suggestions for usability: 1. If there is no 'typescripts' directory, the typescript and test-file should be created just in the same directory as the oftsmkr file (so it's easier to use it anywhere outside the texmf-tree). 2. In the test-file, I had to replace '\start' and '\stop' with '\starttext' and '\stoptext' (otherwise it doesn't work on my sytem). 3. The line '\usetypescriptfile [<nameofthetypescriptfile>]' should be included in the test-file. So the test-file will use the typescript file if it is in the same directory as the test-file. 4. All the '\definefontalternative' definitions which you print in the terminal output could be included in the test-file. So the test-file would work out-of-the-box. Thanks for sharing your script! Best wishes Thomas
participants (7)
-
Hans Hagen
-
Khaled Hosny
-
luigi scarso
-
Michael Murphy
-
Mojca Miklavec
-
Thomas Floeren
-
Vnpenguin