Ejemplo n.º 1
0
def processCollectedText(collectedText, textElementList, parent_map,
                         superscriptNode, unicodeFont):
    clearedTextElements = []
    global debug_output

    # First, change the text
    if debug_output:
        print('** CONVERTING %s to Unicode. ' % collectedText.encode('utf-8'))
    convertedText = osageConversion.oldOsageToUnicode(collectedText)
    convertedCount = 0
    if convertedText != collectedText:
        convertedCount = 1
    else:
        print('---- Not converted: %s' % collectedText.encode('utf-8'))

    # 1. Reset text in first element
    if not textElementList:
        return 0
        # ∂textElementList[0].text = convertedText
    parent = parent_map[textElementList[0]]
    # Fix font and superscripting
    fixElementAndParent(textElementList[0], parent, convertedText,
                        unicodeFont)  # Update the font in this item.
    if superscriptNode:
        superscriptNode.val = 'baseline'

    # 2. Clear text in other elements
    for element in textElementList[1:]:
        element.text = ''
        clearedTextElements.append(element)

    return convertedCount, clearedTextElements
Ejemplo n.º 2
0
def replFunc(matchObj):
  if matchObj.group(0):
     # Avoid converting strings with [aeo] after capital, but in English
    if notOsageLatinLower.search(matchObj.group(0)):
      return matchObj.group(0)
    else:
      return osageConversion.oldOsageToUnicode(matchObj.group(0))
Ejemplo n.º 3
0
def checkAndConvertText(textIn):

    if textIn[0] == '=':
        # Ignore function calls
        return textIn

    # Handle text in font-labeled regions
    result = osageConversion.oldOsageToUnicode(textIn)
    return result
Ejemplo n.º 4
0
def checkAndConvertText(textIn):

    if textIn[0] == '=':
        # Ignore function calls
        return textIn
    #if notOsageLatinLower.search(textIn):
    #  return textIn

    # Handle Latin and TraditionalOsage private use characters.
    tryResult = osageConversion.oldOsageToUnicode(textIn)
    #tryResult = re.subn(osageConvertPattern, replFunc, textIn)
    #if tryResult[1] >= 1:
    return tryResult  #[0]
Ejemplo n.º 5
0
def convertToOsageUnicode(oldText):
    newText = osageConversion.oldOsageToUnicode(
        oldText)  # FOR TESTING oldText[::-1]
    return newText
Ejemplo n.º 6
0
def replFunc(matchObj):
  if matchObj.group(0):
    if notOsageLatinLower.search(matchObj.group(0)):
      return matchObj.group(0)
    else:
      return osageConversion.oldOsageToUnicode(matchObj.group(0))