DEVTOOLS: BLADERUNNER: Full cp-1252 support for subtitles
And additional bug fixes for font creation and detection of error cases
This commit is contained in:
parent
3a7219fa57
commit
cfee64e630
6 changed files with 314 additions and 297 deletions
|
@ -129,7 +129,7 @@ from struct import *
|
|||
from fonFileLib import *
|
||||
|
||||
COMPANY_EMAIL = "classic.adventures.in.greek@gmail.com"
|
||||
APP_VERSION = "0.80"
|
||||
APP_VERSION = "1.00"
|
||||
APP_NAME = "grabberFromPNGHHBR"
|
||||
APP_WRAPPER_NAME = "fontCreator.py"
|
||||
APP_NAME_SPACED = "Blade Runner Font Creator/Exporter"
|
||||
|
@ -305,12 +305,13 @@ class grabberFromPNG:
|
|||
|
||||
if(len(self.listOfOutOfOrderGlyphs) == 0 and self.specialGlyphMode == True):
|
||||
# Just keep those that are needed
|
||||
if self.originalFontName == 'SUBTLS_E':
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xed', u'\u0386')) # spanish i (si)
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xf1', u'\xa5')) # spanish n (senor)
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xe2', u'\xa6')) # a for (liver) pate
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xe9', u'\xa7')) # e for (liver) pate
|
||||
elif self.originalFontName == 'TAHOMA': # treat TAHOMA18 and TAHOMA24 similarily here
|
||||
#if self.originalFontName == 'SUBTLS_E':
|
||||
# self.listOfOutOfOrderGlyphs.append((u'\xed', u'\u0386')) # spanish i (si)
|
||||
# self.listOfOutOfOrderGlyphs.append((u'\xf1', u'\xa5')) # spanish n (senor)
|
||||
# self.listOfOutOfOrderGlyphs.append((u'\xe2', u'\xa6')) # a for (liver) pate
|
||||
# self.listOfOutOfOrderGlyphs.append((u'\xe9', u'\xa7')) # e for (liver) pate
|
||||
#elif self.originalFontName == 'TAHOMA': # treat TAHOMA18 and TAHOMA24 similarily here
|
||||
if self.originalFontName == 'TAHOMA': # treat TAHOMA18 and TAHOMA24 similarily here
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xe9', u'\u0192')) # french e punctuated
|
||||
self.listOfOutOfOrderGlyphs.append((u'\xfc', u'\u2013')) # u umlaut
|
||||
if gTraceModeEnabled:
|
||||
|
@ -723,6 +724,13 @@ class grabberFromPNG:
|
|||
print "[Debug] Max Width: %d, Max Height: %d (not necessarily for the same character glyph)." % (maxFontWidth, maxFontHeight)
|
||||
# print "Index\tAsciiOrd\tX Offs\tY Offs\tWidth\tHeight"
|
||||
# print zip(range(1, len(self.listOfXOffsets)), self.targetLangOrderAndListOfForeignLettersAsciiValues[1:], self.listOfXOffsets, self.listOfYOffsets, listOfCalcWidths, self.listOfHeights)
|
||||
numberOfEntriesInFontTable = self.maxAsciiValueInEncoding + 1 + 1 # 0x0100 # This is actually the max ascii value + plus one (1) to get the font index value + plus another one (1) to get the count (since we have zero based indices)
|
||||
# TODO ??? could be more than this if we need to keep other characters (not in our codeset) and expand the ascii table and offset the new characters
|
||||
if self.maxAsciiValueInEncoding > 254:
|
||||
print "[Error] Max ascii value is too large. Should be less than or equal to 254 (max)"
|
||||
errorFound = True
|
||||
retVal = -3
|
||||
if not errorFound:
|
||||
targetFontFile = None
|
||||
try:
|
||||
targetFontFile = open(self.targetFONFilename, 'wb')
|
||||
|
@ -753,8 +761,6 @@ class grabberFromPNG:
|
|||
# pack 'I' unsigned int
|
||||
if gTraceModeEnabled:
|
||||
print "[Debug] Number Of Entries In Font Table: ", (self.maxAsciiValueInEncoding + 1 + 1)
|
||||
numberOfEntriesInFontTable = self.maxAsciiValueInEncoding + 1 + 1 # 0x0100 # This is actually the max ascii value + plus one (1) to get the font index value + plus another one (1) to get the count (since we have zero based indices)
|
||||
# TODO ??? could be more than this if we need to keep other characters (not in our codeset) and expand the ascii table and offset the new characters
|
||||
numberOfEntriesInFontTableInFile = pack('I', numberOfEntriesInFontTable )
|
||||
targetFontFile.write(numberOfEntriesInFontTableInFile)
|
||||
maxFontWidthPixelsToWrite = pack('I', maxFontWidth)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
targetEncoding=windows-1253
|
||||
asciiCharList=!!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~…Ά£¥¦§ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ
|
||||
explicitKerningList=i:-1
|
||||
targetEncoding=windows-1252
|
||||
asciiCharList=!!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
|
||||
explicitKerningList=i:-1,ì:-1,í:-1,î:-1,ï:-1,u:-1
|
||||
explicitWidthIncrement=i:0,j:1,l:1
|
||||
originalFontName=SUBLTS
|
||||
specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=í:Ά,ñ:¥,â:¦,é:§,Ά:£
|
||||
|
||||
specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=ÿ:€
|
||||
|
|
|
@ -125,7 +125,7 @@ from struct import *
|
|||
from subtlsVersTextResource import *
|
||||
|
||||
COMPANY_EMAIL = "classic.adventures.in.greek@gmail.com"
|
||||
APP_VERSION = "1.10"
|
||||
APP_VERSION = "1.50"
|
||||
APP_NAME = "packBladeRunnerMIXFromPCTLKXLS"
|
||||
APP_WRAPPER_NAME = "mixResourceCreator.py"
|
||||
APP_NAME_SPACED = "Blade Runner MIX Resource Creator"
|
||||
|
@ -315,15 +315,16 @@ def initOverrideEncoding(pathToConfigureFontsTranslationTxt):
|
|||
sys.exit(1) # terminate if override Failed (Blade Runner)
|
||||
#
|
||||
#
|
||||
if(len(gListOfFontNamesToOutOfOrderGlyphs) == 0):
|
||||
tmpFontType = DEFAULT_SUBTITLES_FONT_NAME[:-4] # remove the .FON extensionFromTheName
|
||||
print "[Info] Empty list for out of order glyphs. Assuming default out of order glyphs and only for the %s font" % (tmpFontType)
|
||||
tmplistOfOutOfOrderGlyphs = []
|
||||
tmplistOfOutOfOrderGlyphs.append((u'\xed', u'\u0386')) # spanish i (si)
|
||||
tmplistOfOutOfOrderGlyphs.append((u'\xf1', u'\xa5')) # spanish n (senor)
|
||||
tmplistOfOutOfOrderGlyphs.append((u'\xe2', u'\xa6')) # a for (liver) pate
|
||||
tmplistOfOutOfOrderGlyphs.append((u'\xe9', u'\xa7')) # e for (liver) pate
|
||||
gListOfFontNamesToOutOfOrderGlyphs.append( (tmpFontType, tmplistOfOutOfOrderGlyphs))
|
||||
#We no longer assume default out of order list
|
||||
#if(len(gListOfFontNamesToOutOfOrderGlyphs) == 0):
|
||||
# tmpFontType = DEFAULT_SUBTITLES_FONT_NAME[:-4] # remove the .FON extensionFromTheName
|
||||
# print "[Info] Empty list for out of order glyphs. Assuming default out of order glyphs and only for the %s font" % (tmpFontType)
|
||||
# tmplistOfOutOfOrderGlyphs = []
|
||||
# tmplistOfOutOfOrderGlyphs.append((u'\xed', u'\u0386')) # spanish i (si)
|
||||
# tmplistOfOutOfOrderGlyphs.append((u'\xf1', u'\xa5')) # spanish n (senor)
|
||||
# tmplistOfOutOfOrderGlyphs.append((u'\xe2', u'\xa6')) # a for (liver) pate
|
||||
# tmplistOfOutOfOrderGlyphs.append((u'\xe9', u'\xa7')) # e for (liver) pate
|
||||
# gListOfFontNamesToOutOfOrderGlyphs.append( (tmpFontType, tmplistOfOutOfOrderGlyphs))
|
||||
if gTraceModeEnabled:
|
||||
print "[Info] Explicit Out Of Order Glyphs List: " , gListOfFontNamesToOutOfOrderGlyphs
|
||||
# arrange list properly:
|
||||
|
@ -331,6 +332,7 @@ def initOverrideEncoding(pathToConfigureFontsTranslationTxt):
|
|||
# if such case then the pair with the key should precede the pair with the value matched,
|
||||
# to avoid replacing instances of a special character (key) with a delegate (value) that will be later replaced again due to the second pair
|
||||
#
|
||||
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
|
||||
for (itFontName, itOOOGlyphList) in gListOfFontNamesToOutOfOrderGlyphs:
|
||||
while (True):
|
||||
foundMatchingPairs = False
|
||||
|
@ -473,7 +475,12 @@ def getSupportedTranslatedTrxFilenamesList():
|
|||
if (gActiveLanguageDescriptionCodeTuple[1] != '#' and tmpActiveLanguageDescriptionCodeTuple[1] == gActiveLanguageDescriptionCodeTuple[1]) \
|
||||
or (gActiveLanguageDescriptionCodeTuple[1] == '#' and tmpActiveLanguageDescriptionCodeTuple[1] != '#' and tmpActiveLanguageDescriptionCodeTuple[0] != 'RU_RUS'):
|
||||
for translatedTRxFileName in [ (x[0] + '%s' % (tmpActiveLanguageDescriptionCodeTuple[1])) for x in SUPPORTED_TRANSLATION_SHEETS] :
|
||||
if translatedTRxFileName[:-1] != SUPPORTED_DIALOGUE_VERSION_SHEET[:-1] or tmpActiveLanguageDescriptionCodeTuple[1] == 'E':
|
||||
if translatedTRxFileName[:-1] != SUPPORTED_DIALOGUE_VERSION_SHEET[:-1] \
|
||||
or (gActiveLanguageDescriptionCodeTuple[1] == '#' and tmpActiveLanguageDescriptionCodeTuple[1] == 'E') \
|
||||
or (gActiveLanguageDescriptionCodeTuple[1] != '#'):
|
||||
if translatedTRxFileName[:-1] == SUPPORTED_DIALOGUE_VERSION_SHEET[:-1]:
|
||||
listOfSupportedTranslatedTrxFilenames.append(SUPPORTED_DIALOGUE_VERSION_SHEET)
|
||||
else:
|
||||
listOfSupportedTranslatedTrxFilenames.append(translatedTRxFileName)
|
||||
return listOfSupportedTranslatedTrxFilenames
|
||||
#
|
||||
|
@ -641,6 +648,7 @@ def translateQuoteToAsciiProper(cellObj, pSheetName):
|
|||
localTargetEncoding = tmpTargetEnc
|
||||
break
|
||||
|
||||
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
|
||||
for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
|
||||
if tmpFontName == DEFAULT_SUBTITLES_FONT_NAME[:-4]:
|
||||
pertinentListOfOutOfOrderGlyphs = tmpOOOList
|
||||
|
@ -658,6 +666,7 @@ def translateQuoteToAsciiProper(cellObj, pSheetName):
|
|||
localTargetEncoding = tmpTargetEnc
|
||||
break
|
||||
|
||||
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
|
||||
for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
|
||||
if tmpFontName == pertinentFontType:
|
||||
pertinentListOfOutOfOrderGlyphs = tmpOOOList
|
||||
|
@ -772,6 +781,8 @@ def inputXLS(pathtoInputExcelFilename):
|
|||
# Check for a version info sheet and create one if it does not exist
|
||||
xl_sheet = None
|
||||
try:
|
||||
if gTraceModeEnabled:
|
||||
print '[Debug] Checking for existence of sheet: ' + SUPPORTED_DIALOGUE_VERSION_SHEET
|
||||
xl_sheet = xl_workbook.sheet_by_name(SUPPORTED_DIALOGUE_VERSION_SHEET)
|
||||
except Exception as e:
|
||||
if gTraceModeEnabled:
|
||||
|
@ -820,6 +831,8 @@ def inputXLS(pathtoInputExcelFilename):
|
|||
return
|
||||
# end of check for a version info sheet
|
||||
|
||||
if gTraceModeEnabled:
|
||||
print '[Debug] mergedListOfSupportedSubtitleSheetsAndTranslatedTREs: ', mergedListOfSupportedSubtitleSheetsAndTranslatedTREs
|
||||
for sheetDialogueName in mergedListOfSupportedSubtitleSheetsAndTranslatedTREs:
|
||||
xl_sheet = None
|
||||
try:
|
||||
|
@ -882,16 +895,16 @@ def inputXLS(pathtoInputExcelFilename):
|
|||
del gTableOfStringEntries[:]
|
||||
del gTableOfStringOffsets[:]
|
||||
for row_idx in range(2, xl_sheet.nrows):
|
||||
if gTraceModeEnabled:
|
||||
print "[Debug] Line %d" % (row_idx)
|
||||
#if gTraceModeEnabled:
|
||||
# print "[Debug] Line %d" % (row_idx)
|
||||
for col_idx in range(0, xl_sheet.ncols):
|
||||
cell_obj = xl_sheet.cell(row_idx, col_idx)
|
||||
#
|
||||
# FOR IN-GAME QUOTES -- Iterate through columns starting from col 0. We need cols: 0, 2
|
||||
#
|
||||
if mode == 1:
|
||||
if gTraceModeEnabled:
|
||||
print ('[Debug] Column: [%s] cell_obj: [%s]' % (col_idx, cell_obj))
|
||||
#if gTraceModeEnabled:
|
||||
# print ('[Debug] Column: [%s] cell_obj: [%s]' % (col_idx, cell_obj))
|
||||
if(col_idx == 0):
|
||||
#switchFlagShowQuote = False
|
||||
twoTokensfirstColSplitAtDotXLS = cell_obj.value.split('.', 1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fontNameAndOutOfOrderGlyphs=SUBTLS_E#windows-1253#í:Ά,ñ:¥,â:¦,é:§,Ά:£
|
||||
fontNameAndOutOfOrderGlyphs=SUBTLS_E#windows-1252#ÿ:€
|
||||
fontNameAndOutOfOrderGlyphs=KIA6PT#cp437#
|
||||
fontNameAndOutOfOrderGlyphs=TAHOMA#cp437#
|
||||
fontNameAndOutOfOrderGlyphs=SYSTEM#latin-1#
|
|
@ -1,7 +1,6 @@
|
|||
targetEncoding=windows-1253
|
||||
asciiCharList=!!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~…Ά£¥¦§ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ
|
||||
explicitKerningList=i:-1
|
||||
targetEncoding=windows-1252
|
||||
asciiCharList=!!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
|
||||
explicitKerningList=i:-1,ì:-1,í:-1,î:-1,ï:-1,u:-1
|
||||
explicitWidthIncrement=i:0,j:1,l:1
|
||||
originalFontName=SUBLTS
|
||||
specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=í:Ά,ñ:¥,â:¦,é:§,Ά:£
|
||||
|
||||
specialOutOfOrderGlyphsUTF8ToAsciiTargetEncoding=ÿ:€
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 40 KiB |
Loading…
Add table
Add a link
Reference in a new issue