FormattedBidiReorder.java

net.minecraft.client.resources.language.FormattedBidiReorder

信息

  • 全限定名:net.minecraft.client.resources.language.FormattedBidiReorder
  • 类型:public class
  • 包:net.minecraft.client.resources.language
  • 源码路径:src/main/java/net/minecraft/client/resources/language/FormattedBidiReorder.java
  • 起始行号:L16
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static FormattedCharSequence reorder(FormattedText text, boolean defaultRightToLeft) @ L17

  • 方法名:reorder
  • 源码定位:L17
  • 返回类型:FormattedCharSequence
  • 修饰符:public static

参数:

  • text: FormattedText
  • defaultRightToLeft: boolean

说明:

TODO

private static String shape(String text) @ L32

  • 方法名:shape
  • 源码定位:L32
  • 返回类型:String
  • 修饰符:private static

参数:

  • text: String

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class FormattedBidiReorder {
    public static FormattedCharSequence reorder(FormattedText text, boolean defaultRightToLeft) {
        SubStringSource source = SubStringSource.create(text, UCharacter::getMirror, FormattedBidiReorder::shape);
        Bidi bidi = new Bidi(source.getPlainText(), defaultRightToLeft ? 127 : 126);
        bidi.setReorderingMode(0);
        List<FormattedCharSequence> result = Lists.newArrayList();
        int runCount = bidi.countRuns();
 
        for (int i = 0; i < runCount; i++) {
            BidiRun run = bidi.getVisualRun(i);
            result.addAll(source.substring(run.getStart(), run.getLength(), run.isOddRun()));
        }
 
        return FormattedCharSequence.composite(result);
    }
 
    private static String shape(String text) {
        try {
            return new ArabicShaping(8).shape(text);
        } catch (Exception var2) {
            return text;
        }
    }
}

引用的其他类