Skip to content

Commit

Permalink
DEVTOOLS: BLADERUNNER: Full cp-1252 support for subtitles
Browse files Browse the repository at this point in the history
And additional bug fixes for font creation and detection of error cases
  • Loading branch information
antoniou79 committed Jun 30, 2019
1 parent 3a7219f commit cfee64e
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 301 deletions.
508 changes: 257 additions & 251 deletions devtools/create_bladerunner/subtitles/fontCreator/grabberFromPNG17BR.py

Large diffs are not rendered by default.

@@ -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=ÿ:€
Expand Up @@ -125,7 +125,7 @@
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"
Expand Down Expand Up @@ -315,38 +315,40 @@ 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:
# check if the list contains same item as key and value (in different pairs)
# 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
#
for (itFontName, itOOOGlyphList) in gListOfFontNamesToOutOfOrderGlyphs:
while (True):
foundMatchingPairs = False
for glyphDelegItA in itOOOGlyphList:
for glyphDelegItB in itOOOGlyphList:
if (glyphDelegItA[1] == glyphDelegItB[0] and itOOOGlyphList.index(glyphDelegItA) < itOOOGlyphList.index(glyphDelegItB)):
# swap
itamA, itamB = itOOOGlyphList.index(glyphDelegItA), itOOOGlyphList.index(glyphDelegItB)
itOOOGlyphList[itamB], itOOOGlyphList[itamA] = itOOOGlyphList[itamA], itOOOGlyphList[itamB]
foundMatchingPairs = True
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
for (itFontName, itOOOGlyphList) in gListOfFontNamesToOutOfOrderGlyphs:
while (True):
foundMatchingPairs = False
for glyphDelegItA in itOOOGlyphList:
for glyphDelegItB in itOOOGlyphList:
if (glyphDelegItA[1] == glyphDelegItB[0] and itOOOGlyphList.index(glyphDelegItA) < itOOOGlyphList.index(glyphDelegItB)):
# swap
itamA, itamB = itOOOGlyphList.index(glyphDelegItA), itOOOGlyphList.index(glyphDelegItB)
itOOOGlyphList[itamB], itOOOGlyphList[itamA] = itOOOGlyphList[itamA], itOOOGlyphList[itamB]
foundMatchingPairs = True
break
if (foundMatchingPairs == True):
break
if (foundMatchingPairs == True):
break
if(foundMatchingPairs == False):
break # the whole while loop
gArrangedListOfFontNamesToOutOfOrderGlyphs.append( ( itFontName, itOOOGlyphList))
if(foundMatchingPairs == False):
break # the whole while loop
gArrangedListOfFontNamesToOutOfOrderGlyphs.append( ( itFontName, itOOOGlyphList))
if gTraceModeEnabled:
print "[Debug] Arranged Glyphs Delegates List: " , gArrangedListOfFontNamesToOutOfOrderGlyphs
return
Expand Down Expand Up @@ -473,8 +475,13 @@ 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':
listOfSupportedTranslatedTrxFilenames.append(translatedTRxFileName)
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
#
def outputMIX():
Expand Down Expand Up @@ -641,10 +648,11 @@ def translateQuoteToAsciiProper(cellObj, pSheetName):
localTargetEncoding = tmpTargetEnc
break

for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
if tmpFontName == DEFAULT_SUBTITLES_FONT_NAME[:-4]:
pertinentListOfOutOfOrderGlyphs = tmpOOOList
break
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
if tmpFontName == DEFAULT_SUBTITLES_FONT_NAME[:-4]:
pertinentListOfOutOfOrderGlyphs = tmpOOOList
break
elif pSheetName in supportedTranslatedTrxFilenamesList:
pertinentFontType = ''
#[treAndFontTypeTuple for treAndFontTypeTuple in SUPPORTED_TRANSLATION_SHEETS if treAndFontTypeTuple[0] == pSheetName]
Expand All @@ -658,10 +666,11 @@ def translateQuoteToAsciiProper(cellObj, pSheetName):
localTargetEncoding = tmpTargetEnc
break

for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
if tmpFontName == pertinentFontType:
pertinentListOfOutOfOrderGlyphs = tmpOOOList
break
if(len(gListOfFontNamesToOutOfOrderGlyphs) > 0):
for (tmpFontName, tmpOOOList) in gListOfFontNamesToOutOfOrderGlyphs:
if tmpFontName == pertinentFontType:
pertinentListOfOutOfOrderGlyphs = tmpOOOList
break

#newQuoteReplaceSpecials = newQuoteReplaceSpecials.replace(u"\u0386", u"\u00A3")
for repTuple in pertinentListOfOutOfOrderGlyphs:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
@@ -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=ÿ:€
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cfee64e

Please sign in to comment.