private static void addFragments(
     BidiRun run,
     char[] text,
     int start,
     int end,
     int fontStyle,
     FontPreferences fontPreferences,
     FontRenderContext fontRenderContext,
     @Nullable TabFragment tabFragment) {
   Font currentFont = null;
   int currentIndex = start;
   for (int i = start; i < end; i++) {
     char c = text[i];
     if (c == '\t' && tabFragment != null) {
       assert run.level == 0;
       addTextFragmentIfNeeded(
           run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl());
       run.fragments.add(tabFragment);
       currentFont = null;
       currentIndex = i + 1;
     } else {
       Font font =
           ComplementaryFontsRegistry.getFontAbleToDisplay(c, fontStyle, fontPreferences)
               .getFont();
       if (!font.equals(currentFont)) {
         addTextFragmentIfNeeded(
             run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl());
         currentFont = font;
         currentIndex = i;
       }
     }
   }
   addTextFragmentIfNeeded(
       run, text, currentIndex, end, currentFont, fontRenderContext, run.isRtl());
 }
    public void advance() {
      myCurrentFontFamilyName = myNextFontFamilyName;
      myCurrentStartOffset = myCurrentOffset;
      for (; myCurrentOffset < myEndOffset; myCurrentOffset++) {
        FontInfo fontInfo =
            ComplementaryFontsRegistry.getFontAbleToDisplay(
                myCharSequence.charAt(myCurrentOffset),
                myFontSize,
                myFontStyle,
                myDefaultFontFamilyName);
        String fontFamilyName = fontInfo.getFont().getFamily();

        if (myCurrentFontFamilyName == null) {
          myCurrentFontFamilyName = fontFamilyName;
        } else if (!myCurrentFontFamilyName.equals(fontFamilyName)) {
          myNextFontFamilyName = fontFamilyName;
          break;
        }
      }
    }
 @NotNull
 public static Font getFontAbleToDisplay(char c, int size, int style, @NotNull String family) {
   return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, family).getFont();
 }