private FSFont resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = (FontDescription)_fontCache.get(cacheKey); if (result != null) { return new ITextFSFont(result, size); } FontFamily family = (FontFamily)_fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return new ITextFSFont(result, size); } } return null; }
public int getWidth(FontContext context, FSFont font, String string) { BaseFont bf = ((ITextFSFont)font).getFontDescription().getFont(); float result = bf.getWidthPoint(string, font.getSize2D()); if (result - Math.floor(result) < TEXT_MEASURING_DELTA) { return (int)result; } else { return (int)Math.ceil(result); } }
private PdfTextArray makeJustificationArray(String s, JustificationInfo info) { PdfTextArray array = new PdfTextArray(); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); array.add(Character.toString(c)); if (i != len - 1) { float offset; if (c == ' ' || c == '\u00a0' || c == '\u3000') { offset = info.getSpaceAdjust(); } else { offset = info.getNonSpaceAdjust(); } array.add((-offset / _dotsPerPoint) * 1000 / (_font.getSize2D() / _dotsPerPoint)); } } return array; }
public void drawString(String s, float x, float y, JustificationInfo info) { if (s.length() == 0) return; PdfContentByte cb = _currentPage; ensureFillColor(); AffineTransform at = (AffineTransform)getTransform().clone(); at.translate(x, y); AffineTransform inverse = normalizeMatrix(at); AffineTransform flipper = AffineTransform.getScaleInstance(1, -1); inverse.concatenate(flipper); inverse.scale(_dotsPerPoint, _dotsPerPoint); double[] mx = new double[6]; inverse.getMatrix(mx); cb.beginText(); cb.setFontAndSize(_font.getFontDescription().getFont(), _font.getSize2D() / _dotsPerPoint); cb.setTextMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]); if (info == null) { cb.showText(s); } else { PdfTextArray array = makeJustificationArray(s, info); cb.showText(array); } cb.endText(); }
public void drawString(String s, float x, float y, JustificationInfo info) { if (s.length() == 0) return; PdfContentByte cb = _currentPage; ensureFillColor(); AffineTransform at = (AffineTransform)getTransform().clone(); at.translate(x, y); AffineTransform inverse = normalizeMatrix(at); AffineTransform flipper = AffineTransform.getScaleInstance(1, -1); inverse.concatenate(flipper); inverse.scale(_dotsPerPoint, _dotsPerPoint); double[] mx = new double[6]; inverse.getMatrix(mx); cb.beginText(); cb.setFontAndSize(_font.getFontDescription().getFont(), _font.getSize2D() / _dotsPerPoint); cb.setTextMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]); if (info == null) { cb.showText(s); } else { PdfTextArray array = makeJustificationArray(s, info); cb.showText(array); } cb.endText(); }
private void createAppearance( RenderingContext c, ITextOutputDevice outputDevice, BlockBox box, PdfFormField field) { PdfWriter writer = outputDevice.getWriter(); ITextFSFont font = (ITextFSFont)box.getStyle().getFSFont(c); PdfContentByte cb = writer.getDirectContent(); float width = outputDevice.getDeviceLength(getWidth()); float height = outputDevice.getDeviceLength(getHeight()); float fontSize = outputDevice.getDeviceLength(font.getSize2D()); PdfAppearance tp = cb.createAppearance(width, height); tp.setFontAndSize(font.getFontDescription().getFont(), fontSize); FSColor color = box.getStyle().getColor(); setFillColor(tp, color); field.setDefaultAppearanceString(tp); }
public int getWidth(FontContext context, FSFont font, String string) { BaseFont bf = ((ITextFSFont)font).getFontDescription().getFont(); float result = bf.getWidthPoint(string, font.getSize2D()); if (result - Math.floor(result) < TEXT_MEASURING_DELTA) { return (int)result; } else { return (int)Math.ceil(result); } }
private FSFont resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = (FontDescription)_fontCache.get(cacheKey); if (result != null) { return new ITextFSFont(result, size); } FontFamily family = (FontFamily)_fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return new ITextFSFont(result, size); } } return null; }
private PdfTextArray makeJustificationArray(String s, JustificationInfo info) { PdfTextArray array = new PdfTextArray(); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); array.add(Character.toString(c)); if (i != len - 1) { float offset; if (c == ' ' || c == '\u00a0' || c == '\u3000') { offset = info.getSpaceAdjust(); } else { offset = info.getNonSpaceAdjust(); } array.add((-offset / _dotsPerPoint) * 1000 / (_font.getSize2D() / _dotsPerPoint)); } } return array; }
private void createAppearance( RenderingContext c, ITextOutputDevice outputDevice, BlockBox box, PdfFormField field) { PdfWriter writer = outputDevice.getWriter(); ITextFSFont font = (ITextFSFont)box.getStyle().getFSFont(c); PdfContentByte cb = writer.getDirectContent(); float width = outputDevice.getDeviceLength(getWidth()); float height = outputDevice.getDeviceLength(getHeight()); float fontSize = outputDevice.getDeviceLength(font.getSize2D()); PdfAppearance tp = cb.createAppearance(width, height); tp.setFontAndSize(font.getFontDescription().getFont(), fontSize); FSColor color = box.getStyle().getColor(); setFillColor(tp, color); field.setDefaultAppearanceString(tp); }
public int getWidth(FontContext context, FSFont font, String string) { BaseFont bf = ((ITextFSFont)font).getFontDescription().getFont(); float result = bf.getWidthPoint(string, font.getSize2D()); if (result - Math.floor(result) < TEXT_MEASURING_DELTA) { return (int)result; } else { return (int)Math.ceil(result); } }
private FSFont resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = (FontDescription)_fontCache.get(cacheKey); if (result != null) { return new ITextFSFont(result, size); } FontFamily family = (FontFamily)_fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return new ITextFSFont(result, size); } } return null; }
private PdfTextArray makeJustificationArray(String s, JustificationInfo info) { PdfTextArray array = new PdfTextArray(); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); array.add(Character.toString(c)); if (i != len - 1) { float offset; if (c == ' ' || c == '\u00a0' || c == '\u3000') { offset = info.getSpaceAdjust(); } else { offset = info.getNonSpaceAdjust(); } array.add((-offset / _dotsPerPoint) * 1000 / (_font.getSize2D() / _dotsPerPoint)); } } return array; }
private void createAppearance( RenderingContext c, ITextOutputDevice outputDevice, BlockBox box, PdfFormField field) { PdfWriter writer = outputDevice.getWriter(); ITextFSFont font = (ITextFSFont)box.getStyle().getFSFont(c); PdfContentByte cb = writer.getDirectContent(); float width = outputDevice.getDeviceLength(getWidth()); float height = outputDevice.getDeviceLength(getHeight()); float fontSize = outputDevice.getDeviceLength(font.getSize2D()); PdfAppearance tp = cb.createAppearance(width, height); tp.setFontAndSize(font.getFontDescription().getFont(), fontSize); FSColor color = box.getStyle().getColor(); setFillColor(tp, color); field.setDefaultAppearanceString(tp); }
public int getWidth(FontContext context, FSFont font, String string) { BaseFont bf = ((ITextFSFont)font).getFontDescription().getFont(); float result = bf.getWidthPoint(string, font.getSize2D()); if (result - Math.floor(result) < TEXT_MEASURING_DELTA) { return (int)result; } else { return (int)Math.ceil(result); } }
private FSFont resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = (FontDescription)_fontCache.get(cacheKey); if (result != null) { return new ITextFSFont(result, size); } FontFamily family = (FontFamily)_fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return new ITextFSFont(result, size); } } return null; }
private PdfTextArray makeJustificationArray(String s, JustificationInfo info) { PdfTextArray array = new PdfTextArray(); int len = s.length(); for (int i = 0; i < len; i++) { char c = s.charAt(i); array.add(Character.toString(c)); if (i != len - 1) { float offset; if (c == ' ' || c == '\u00a0' || c == '\u3000') { offset = info.getSpaceAdjust(); } else { offset = info.getNonSpaceAdjust(); } array.add((-offset / _dotsPerPoint) * 1000 / (_font.getSize2D() / _dotsPerPoint)); } } return array; }
private void createAppearance( RenderingContext c, ITextOutputDevice outputDevice, BlockBox box, PdfFormField field) { PdfWriter writer = outputDevice.getWriter(); ITextFSFont font = (ITextFSFont)box.getStyle().getFSFont(c); PdfContentByte cb = writer.getDirectContent(); float width = outputDevice.getDeviceLength(getWidth()); float height = outputDevice.getDeviceLength(getHeight()); float fontSize = outputDevice.getDeviceLength(font.getSize2D()); PdfAppearance tp = cb.createAppearance(width, height); tp.setFontAndSize(font.getFontDescription().getFont(), fontSize); FSColor color = box.getStyle().getColor(); setFillColor(tp, color); field.setDefaultAppearanceString(tp); }
public int getWidth(FontContext context, FSFont font, String string) { BaseFont bf = ((ITextFSFont)font).getFontDescription().getFont(); float result = bf.getWidthPoint(string, font.getSize2D()); if (result - Math.floor(result) < TEXT_MEASURING_DELTA) { return (int)result; } else { return (int)Math.ceil(result); } }
private FSFont resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = (FontDescription)_fontCache.get(cacheKey); if (result != null) { return new ITextFSFont(result, size); } FontFamily family = (FontFamily)_fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return new ITextFSFont(result, size); } } return null; }