Skip to content

Commit

Permalink
Merge b5043d8 into 57ce236
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonarddeR committed May 21, 2024
2 parents 57ce236 + b5043d8 commit 8147d2e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,20 +499,20 @@ def update(self):
mode |= louis.compbrlAtCursor

converter: UnicodeNormalizationOffsetConverter | None = None
if config.conf["braille"]["unicodeNormalization"] and not isUnicodeNormalized(self.rawText):
converter = UnicodeNormalizationOffsetConverter(self.rawText)
textToTranslate = self.rawText
textToTranslateTypeforms = self.rawTextTypeforms
cursorPos = self.cursorPos
if config.conf["braille"]["unicodeNormalization"] and not isUnicodeNormalized(textToTranslate):
converter = UnicodeNormalizationOffsetConverter(textToTranslate)
textToTranslate = converter.encoded
# Typeforms must be adapted to represent normalized characters.
textToTranslateTypeforms = [
self.rawTextTypeforms[strOffset] for strOffset in converter.computedEncodedToStrOffsets
]
# Convert the cursor position to a normalized offset.
cursorPos = converter.strToEncodedOffsets(self.cursorPos)
else:
textToTranslate = self.rawText
textToTranslateTypeforms = self.rawTextTypeforms
cursorPos = self.cursorPos

if textToTranslateTypeforms is not None:
# Typeforms must be adapted to represent normalized characters.
textToTranslateTypeforms = [
textToTranslateTypeforms[strOffset] for strOffset in converter.computedEncodedToStrOffsets
]
if cursorPos is not None:
# Convert the cursor position to a normalized offset.
cursorPos = converter.strToEncodedOffsets(cursorPos)
self.brailleCells, brailleToRawPos, rawToBraillePos, self.brailleCursorPos = louisHelper.translate(
[handler.table.fileName, "braille-patterns.cti"],
textToTranslate,
Expand Down

0 comments on commit 8147d2e

Please sign in to comment.