Map attributes) {
boolean isDirectionLTR = true;
byte[] levels = null;
int[] charsLtoV = null;
Bidi bidi = null;
int characterCount = chars.length;
boolean requiresBidi = false;
byte[] embs = null;
AttributeValues values = null;
if (attributes != null) {
values = AttributeValues.fromMap(attributes);
if (values.getRunDirection() >= 0) {
isDirectionLTR = values.getRunDirection() == 0;
requiresBidi = !isDirectionLTR;
}
if (values.getBidiEmbedding() != 0) {
requiresBidi = true;
byte level = (byte)values.getBidiEmbedding();
embs = new byte[characterCount];
for (int i = 0; i < embs.length; ++i) {
embs[i] = level;
}
}
}
// dlf: get baseRot from font for now???
if (!requiresBidi) {
requiresBidi = Bidi.requiresBidi(chars, 0, chars.length);
}
if (requiresBidi) {
int bidiflags = values == null
? Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT
: values.getRunDirection();
bidi = new Bidi(chars, 0, embs, 0, chars.length, bidiflags);
if (!bidi.isLeftToRight()) {
levels = BidiUtils.getLevels(bidi);
int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
charsLtoV = BidiUtils.createInverseMap(charsVtoL);
isDirectionLTR = bidi.baseIsLeftToRight();
}
}
Decoration decorator = Decoration.getDecoration(values);