@SuppressWarnings("InstanceofIncompatibleInterface")
  static List<String> getRelevantComponents(@NotNull Font font, @NotNull CharSequence text, int startOffset, int endOffset)
    throws Exception {
    if (GET_FONT_2D_METHOD != null) {
      Font2D font2D = (Font2D)GET_FONT_2D_METHOD.invoke(font);
      if (font2D != null) {
        CompositeFont compositeFont = null;
        IntUnaryOperator charToGlyphMapper = null;
        if (font2D instanceof CompositeFont) {
          compositeFont = (CompositeFont)font2D;
          charToGlyphMapper = c -> font2D.charToGlyph(c);
        }
        else if (font2D instanceof FontSubstitution) {
          compositeFont = ((FontSubstitution)font2D).getCompositeFont2D();
          charToGlyphMapper = c -> font.createGlyphVector(DUMMY_CONTEXT, new String(new int[]{c}, 0, 1)).getGlyphCode(0);
        }
        List<Font2D> components = new ArrayList<>();
        if (compositeFont == null) {
          components.add(font2D);
        }
        else {
          for (int i = startOffset; i < endOffset; ) {
            int codePoint = Character.codePointAt(text, i);
            int glyph = charToGlyphMapper.applyAsInt(codePoint);
            int slot = glyph >>> 24;
            components.add(compositeFont.getSlotFont(slot));
            i += Character.charCount(codePoint);
          }
        }
        return ContainerUtil.map(components, f -> f.getFontName(null));
      }
    }
    return null;
  }
@SuppressWarnings("InstanceofIncompatibleInterface")
  static List<String> getRelevantComponents(@NotNull Font font, @NotNull CharSequence text, int startOffset, int endOffset)