Is it a bug that tab.textRange
and tab.textCursor
count glyphs with suffixes as 2?
Selecting a single n.ss01 gives textRange=2
Is it a bug that tab.textRange
and tab.textCursor
count glyphs with suffixes as 2?
Selecting a single n.ss01 gives textRange=2
that is not a bug. Glyphs that do not have a unicode, will use an Upper plane PUA code. In ObjectiveC, strings are encoded with UTF-16. Those Upper plane codes are encoded with two codes.
In that case, what’s the best way to replace some selected layers with other layers, to capitalize them for instance? If the tab layers are a.ss01 b c
and I want to capitalize that b
:
In that case tab.layers[tab.textCursor]
returns c
, which suggests that to connect the text selection to actual layers needs re-building indexes every time?
try
tab.layers[tab.layersCursor]
(don’t mix the text and the layer API, They can deviate in both direction. The layer can represent multiple characters (ligatures) or one character in the text can result in multiple layer (one to many substitution))
The internal API for this looks like this:
NSRange replaceRange = editView.selectedRange;
replaceRange.length = 1;
UTF32Char aChar = [activeFont characterForGlyph:newGlyph];
NSString *layerKey = nil;
[editView replaceCharactersInRange:replaceRange withString:[NSString stringWithChar:aChar]];
Thank you! Is there a good way to select a given number of layers in a tab similarly to tab.textRange
but for layers’ indexes?
That is missing in the python wrapper. But you can use the objectiveC API directly:
range = tab.graphicView().selectedLayerRange()
tab.graphicView().setSelectedLayerRange_(newRange)
Range is of Type NSRange
.
range = NSMakeRange(location, length)
range.location = 12
range.length = 1