[B-Greek] Font converter

Patrick Narkinsky patrick at narkinsky.com
Thu May 27 19:29:16 EDT 2004


On May 27, 2004, at 6:02 PM, Kenneth Litwak wrote:

>   I wonder if someone might be able to give me osme
> help, probably off-list.  I need to be able to convert
> all the occurrences of Greek in a very large document
> from Bibleworks Greek to SPIonic.  I could use some
> hwelp in writing something that oucld find all the
> occurrences of Greek and then convert them to SPIonic.
> Thanks for yourh elp. While I program fora living,
> word processing macros and font maniuplation aren't in
> my background.

(Apologies if I should've replied to this off-list.  It is my 
perception that this topic is of general interest.)

As a programmer who has done a lot of converting of Greek texts, I 
wouldn't try to do this in a word processor.  I'd dump it to an html 
file and manipulate the file using python or perl.  Regular expressions 
make this kind of exercise trivially easy to complete.  You could 
detect the Greek text in HTML by looking for whatever tag the word 
process uses to change the font.  You could then reimport the file into 
a word processor, having changed the fonts and the encoded text.

Unfortunately, I don't have a translator already written for Spionic or 
Bibleworks Greek, or I'd share it.  Below is a mostly untested python 
class that translates from TLG to Teknia.  Adjustments to the 
translation table should be all that would be required to make this 
support SPIonic and Bibleworks.

Patrick

--
Patrick Narkinsky - patrick at narkinsky.com

"Now, What are these, '…battles of the Lord'? These are battles with 
sin, and battles with false doctrines, and battles with war. Fight 
these battles Christian and you will have enough to do."                
         - Spurgeon


'''TekniaBetaCodec.py'''

from BetaCodec import *
import re

class TekniaBetaCodec(BetaCodec):
     """Encodes and Decodes to and from the TekniaGreek font/keyboard 
map."""
     def __init__(self):
         """Init is at this point a null function."""
         return

     _finalSigmaRE = re.compile(r's[$\s]')

     _translation_table=[
         ("+=", "?"), #Diaresis + circumflex
         ("=+", "?"),
         ("+\\", ">"), # Diaresis + grave
         ("\\+", ">"),
         ("/+", "<"), # Diaresis + acute
         ("+/", "<"),
         (")=", "|"), # Rough + circumflex
         ("=)", "|"),
         (")\\", "}"), #Rough + grave
         ("\\)", "}"),
         (")/", "{"), #Rough + acute
         ("/)", "{"),
         ("(=", "\\"), # Smooth + circumflex
         ("=(", "\\"),
         ("(\\", "]"), # Smooth + grave
         ("\\(", "]"),
         ("/(", "["), # Smooth + acute
         ("(/", "["),
         (")", "j"), # smooth
         ("(", "J"), # rough
         ("/", "v"), # acute
         ("|", "/"), # iota subscript
         ("\\", ";"), # grave
         ("=", ":") #circumflex
         ]

     def decode(self, betatext):
         """Decode a beta-coded string to Teknia font mapping."""

         # Translate it to lowercase
         result=betatext.lower()

         # Deal with final sigmas.
         result=self._finalSigmaRE.sub("V", result)

         for i in self._translation_table:
             result=result.replace(i[0], i[1])

             if (result[0] == "*"):
                 result=result.replace("*", "")
                 result=result.capitalize()

         return result

     def encode(self, tekniatext):
         """Encode a teknia mapped string to Beta code."""
         raise NotImplmentedError, "TekniaBetaCodec.encode not 
implemented."

     def getDescription():
         return "Teknia"
     getDescription=staticmethod(getDescription)




More information about the B-Greek mailing list