Difference between revisions of "Russian"
Line 1: | Line 1: | ||
== Russian (Cyrillic) fonts and UTF == | == Russian (Cyrillic) fonts and UTF == | ||
− | It is now possible (from ConTeXt version 2005-01-27 or 2005-01-31) to type Russian (cyrillic) letters directly in your .tex file using UTF-8 encoding. I have only tested this on TeXLive 2004, but I guess it would work on any distribution as long as you have the cm-super fonts installed (On TeXLive you had to generate the tfm files needed using the <tt>afm2tfm</tt> application, or by using the fonts in LaTeX). Here is a minimal(?) working file. | + | It is now possible (from ConTeXt version 2005-01-27 or 2005-01-31) to type Russian (cyrillic) letters directly in your .tex file using UTF-8 encoding. I have only tested this on TeXLive 2004, but I guess it would work on any distribution as long as you have the cm-super fonts installed (On TeXLive you had to generate the tfm files needed using the <tt>afm2tfm</tt> application (see furhter down on this page for a small python script that enables you to create all tfm files), or by using the fonts in LaTeX). Here is a minimal(?) working file. |
<texcode> | <texcode> | ||
Line 14: | Line 14: | ||
Мама и Папа % Some Russian characters | Мама и Папа % Some Russian characters | ||
\stoptext | \stoptext | ||
+ | </texcode> | ||
+ | |||
+ | == Russian (Cyrillic) fonts and Windows 1251 == | ||
+ | |||
+ | The following example should work if you save your file in the Windows 1251 encoding: | ||
+ | |||
+ | <texcode> | ||
+ | \definetypeface [russian] | ||
+ | [rm] [serif] [computer-modern] [default] [encoding=t2a] | ||
+ | |||
+ | \definetypeface [swedish] | ||
+ | [rm] [serif] [latin-modern] [default] [encoding=texnansi] | ||
+ | \setupbodyfont[russian] | ||
+ | |||
+ | \starttext | ||
+ | Some russian text: | ||
+ | Там можно бстретить медбедей. | ||
+ | |||
+ | Some swedish text: | ||
+ | {\switchtobodyfont[swedish]D\"ar kan man m\"ota bj\"ornar.} | ||
+ | |||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
+ | At least it works here with TeXLive 2004. | ||
+ | |||
+ | == Russian (Cyrillic) fonts and koi8-r (koi8r) == | ||
+ | This is not done yet. Will be updated when it works. | ||
+ | |||
+ | == The python script == | ||
+ | Ok, I am not a programmer, so this could probably be done in a cleaner way. However, it works for me. | ||
+ | |||
+ | <texcode> | ||
+ | #!/usr/bin/python | ||
+ | import os, string | ||
+ | |||
+ | # Set these paths to what they should be in your case | ||
+ | mapfile="/home/texlive2004/texmf-dist/fonts/map/dvips/cm-super/cm-super-t2a.map" | ||
+ | encfile="cm-super-t2a.enc" | ||
+ | tfmoutdir="/home/texlive2004/texmf-dist/fonts/tfm/public/cm-super/" | ||
+ | |||
+ | f=open(mapfile, 'r') | ||
+ | |||
+ | # First read a line that is a comment. | ||
+ | a=f.readline() | ||
+ | print a | ||
+ | |||
+ | # Loop over the rest of the lines | ||
+ | rest=f.readlines() | ||
+ | for currentline in rest: | ||
+ | splitspace=string.split(currentline," ") | ||
+ | tfmname=splitspace[0] | ||
+ | afmname=string.lower(splitspace[1]) | ||
+ | commandtorun="afm2tfm " + afmname + ".afm -T " + encfile + " " + tfmoutdir + tfmname + ".tfm" | ||
+ | print "Running: " + commandtorun | ||
+ | os.popen(commandtorun) | ||
+ | |||
+ | f.close() | ||
</texcode> | </texcode> |
Revision as of 10:12, 13 February 2005
Contents
Russian (Cyrillic) fonts and UTF
It is now possible (from ConTeXt version 2005-01-27 or 2005-01-31) to type Russian (cyrillic) letters directly in your .tex file using UTF-8 encoding. I have only tested this on TeXLive 2004, but I guess it would work on any distribution as long as you have the cm-super fonts installed (On TeXLive you had to generate the tfm files needed using the afm2tfm application (see furhter down on this page for a small python script that enables you to create all tfm files), or by using the fonts in LaTeX). Here is a minimal(?) working file.
\enableregime[utf] \useencoding[cyr] \definetypeface [russian] [rm] [serif] [computer-modern] [default] [encoding=t2a] \setupbodyfont[russian] \starttext Мама и Папа % Some Russian characters \stoptext
Russian (Cyrillic) fonts and Windows 1251
The following example should work if you save your file in the Windows 1251 encoding:
\definetypeface [russian] [rm] [serif] [computer-modern] [default] [encoding=t2a] \definetypeface [swedish] [rm] [serif] [latin-modern] [default] [encoding=texnansi] \setupbodyfont[russian] \starttext Some russian text: Там можно бстретить медбедей. Some swedish text: {\switchtobodyfont[swedish]D\"ar kan man m\"ota bj\"ornar.} \stoptext
At least it works here with TeXLive 2004.
Russian (Cyrillic) fonts and koi8-r (koi8r)
This is not done yet. Will be updated when it works.
The python script
Ok, I am not a programmer, so this could probably be done in a cleaner way. However, it works for me.
#!/usr/bin/python import os, string # Set these paths to what they should be in your case mapfile="/home/texlive2004/texmf-dist/fonts/map/dvips/cm-super/cm-super-t2a.map" encfile="cm-super-t2a.enc" tfmoutdir="/home/texlive2004/texmf-dist/fonts/tfm/public/cm-super/" f=open(mapfile, 'r') # First read a line that is a comment. a=f.readline() print a # Loop over the rest of the lines rest=f.readlines() for currentline in rest: splitspace=string.split(currentline," ") tfmname=splitspace[0] afmname=string.lower(splitspace[1]) commandtorun="afm2tfm " + afmname + ".afm -T " + encfile + " " + tfmoutdir + tfmname + ".tfm" print "Running: " + commandtorun os.popen(commandtorun) f.close()