EPSCanvasProvider extends AbstractCanvasProvider { @Override public void deviceText( String text, double x1, double x2, double y1, String fontName, double fontSize, TextAlignment textAlign) { if (firstError != null) { return; } if (textAlign == null) { throw new IllegalArgumentException("textAlign must not be NULL"); } checkFontName(fontName); try { writer.write("/" + fontName + " findfont " + UnitConv.mm2pt(fontSize) + " scalefont setfont\n"); switch (textAlign) { case TA_LEFT: writeLeftTextAlign(x1, y1, text); break; case TA_CENTER: writeCenterTextAlign(text, x1, x2, y1); break; case TA_RIGHT: writeRightTextAlign(text, x1, x2, y1); break; case TA_JUSTIFY: writeJustifyTextAlign(text, x1, x2, y1); break; default: throw new AssertionError(textAlign.name()); } } catch (IOException ioe) { firstError = ioe; } } EPSCanvasProvider(OutputStream out, Orientation orientation); @Deprecated  EPSCanvasProvider(OutputStream out, int orientation); void finish(); @Override void establishDimensions(BarcodeDimension dim); @Override void deviceFillRect(double x, double y, double w, double h); @Override void deviceText(
            String text,
            double x1,
            double x2,
            double y1,
            String fontName,
            double fontSize,
            TextAlignment textAlign);  }
@Test public void testDeviceText() throws Exception { System.out.println("deviceText"); String text = "Barcode4J"; double x1 = 0.0; double x2 = 100.0; double y1 = 0.0; String fontName = "Tahoma"; double fontSize = 10.0; EPSCanvasProvider instance = new EPSCanvasProvider(out, orientation); instance.deviceText(text, x1, x2, y1, fontName, fontSize, TextAlignment.TA_CENTER); instance.deviceText(text, x1, x2, y1, fontName, fontSize, TextAlignment.TA_JUSTIFY); instance.deviceText(text, x1, x2, y1, fontName, fontSize, TextAlignment.TA_LEFT); instance.deviceText(text, x1, x2, y1, fontName, fontSize, TextAlignment.TA_RIGHT); instance.finish(); String result = ((ByteArrayOutputStream) out).toString("US-ASCII"); assertThat(result, startsWith("/Tahoma findfont 28.35 scalefont setfont")); assertThat(result, containsString("(Barcode4J) 141.75 0 ct")); assertThat(result, containsString("(Barcode4J) 0 283.5 0 jt")); assertThat(result, containsString("0 0 moveto (Barcode4J) show")); assertThat(result, containsString("(Barcode4J) 0 283.5 0 rt")); }