Compose: Allow to force string final states

Appending the ':' character to a sequence result forces it to be a
string final state. This will cause a KeyValue lookup that would
normally not happen for single-character results.
This is useful to make Tamil letters smaller, even when they are the
result of a Shift.
This commit is contained in:
Jules Aguillon 2024-12-17 11:27:09 +01:00
parent bd2170e04b
commit 82e472ba46

View File

@ -195,6 +195,9 @@ def make_automata(tries):
# There are two encoding for leafs: character final state for 15-bit
# characters and string final state for the rest.
if len(c) > 1 or ord(c[0]) > 32767: # String final state
# A ':' can be added to the result of a sequence to force a string
# final state. For example, to go through KeyValue lookup.
if c.startswith(":"): c = c[1:]
javachars = array('H', c.encode("UTF-16-LE"))
states.append((-1, len(javachars) + 1))
for c in javachars: