TextRenderer extends AbstractRenderer implements ILeafElementRenderer { @Override PdfFont resolveFirstPdfFont(String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts) { FontSelectorStrategy strategy = provider.getStrategy(strToBeConverted, Arrays.asList(font), fc, additionalFonts); List<Glyph> resolvedGlyphs; PdfFont currentFont; while (!strategy.endOfText()) { resolvedGlyphs = strategy.nextGlyphs(); currentFont = strategy.getCurrentFont(); for (Glyph glyph : resolvedGlyphs) { if (currentFont.containsGlyph(glyph.getUnicode())) { return currentFont; } } } return super.resolveFirstPdfFont(font, provider, fc, additionalFonts); } TextRenderer(Text textElement);  TextRenderer(Text textElement, String text); protected  TextRenderer(TextRenderer other); @Override LayoutResult layout(LayoutContext layoutContext); void applyOtf(); @Override void draw(DrawContext drawContext); void trimFirst(); @Override float getAscent(); @Override float getDescent(); float getYLine(); void moveYLineTo(float y); void setText(String text); @Deprecated void setText(GlyphLine text, int leftPos, int rightPos); void setText(GlyphLine text, PdfFont font); GlyphLine getText(); int length(); @Override String toString(); int charAt(int pos); float getTabAnchorCharacterPosition(); @Override IRenderer getNextRenderer(); static float[] calculateAscenderDescender(PdfFont font); static float[] calculateAscenderDescender(PdfFont font, RenderingMode mode); @Override MinMaxWidth getMinMaxWidth();  }
@Test public void resolveFirstPdfFontWithGlyphsAvailableOnlyInSecondaryFont() { Text text = new Text("\u043A\u0456\u0440\u044B\u043B\u0456\u0446\u0430"); text.setFontFamily(Arrays.asList("Puritan 2.0", "Noto Sans")); FontProvider fontProvider = new FontProvider(); fontProvider.addFont(FONTS_FOLDER + "Puritan2.otf"); fontProvider.addFont(FONTS_FOLDER + "NotoSans-Regular.ttf"); text.setProperty(Property.FONT_PROVIDER, fontProvider); TextRenderer renderer = (TextRenderer) new TextRenderer(text); PdfFont pdfFont = renderer.resolveFirstPdfFont(); Assert.assertEquals("NotoSans", pdfFont.getFontProgram().getFontNames().getFontName()); }