📄 pdffont.java
字号:
// $Id: PDFFont.java,v 1.2 2003/10/06 12:40:07 mike Exp $package org.faceless.pdf;import java.util.*;/** * <p> * The PDFFont is the abstract superclass for all Fonts in a PDF document. * It defines properties which are common to all fonts, regardless of writing * direction. * </p> * @see PDFSimpleFont * @see StandardFont * @see StandardCJKFont * @version $Revision: 1.2 $ */public class PDFFont extends PeeredObject{ final org.faceless.pdf2.PDFFont font; PDFFont(org.faceless.pdf2.PDFFont font) { this.font=font; } Object getPeer() { return font; } /** * Return true if the specified Unicode character is defined in the font. */ public boolean isDefined(char c) { return font.isDefined(c); } /** * Return the width of the specific character in millipoints of this * character in 1 point high text * @since 1.2 */ public int getCharWidth(char c) { return font.getCharWidth(c); } /** * Get the left-most X co-ordinate if this String was rendered in 1 * point high text at position (0,0) */ public float getLeft(String s) { return font.getLeft(s); } /** * Get the right-most X co-ordinate if this String was rendered in 1 * point high text at position (0,0) */ public float getRight(String s) { return font.getRight(s); } /** * Get the top-most Y co-ordinate if this String was rendered in 1 * point high text at position (0,0) */ public float getTop(String s) { return font.getTop(s); } /** * Get the bottom-most Y co-ordinate if this String was rendered in 1 * point high text at position (0,0) */ public float getBottom(String s) { return font.getBottom(s); } /** * Get the Ascender for the font (the maximum height above the baseline the * font extends), as a proportion of the point size. * @since 1.1 */ public float getAscender() { return font.getAscender(); } /** * Get the Descender for the font (the maximum height below the baseline the * font extends), as a proportion of the point size. <i>The returned value is * usually negative.</i> * @since 1.1 */ public float getDescender() { return font.getDescender(); } /** * <p> * Get the default leading for this font - the preferred distance between * two successive baselines of text. Values are a ratio of the font size, and * are typically between 1 and 1.3 * </p><p> * Note that the values of the different spacing-between-lines methods have * changed - in versions 1.0.4 and earlier this routine normally returned 1 * and the spacing was set by the {@link PDFStyle#setTextLineSpacing} method. * Since 1.1, the values for these two methods are effectively reversed. See * the relevant method comments in the {@link PDFStyle} class for more * information. * </p> */ public float getDefaultLeading() { return font.getDefaultLeading(); } /** * Get the underline thickness, as a proportion of the font size. * @since 1.1 */ public float getUnderlineThickness() { return font.getUnderlineThickness(); } /** * Get the underline position, as a proportion of the font size. Like * the <code>getDescender()</code> method, the returned value is almost * always negative, indicating below the baseline. * @since 1.1 */ public float getUnderlinePosition() { return font.getUnderlinePosition(); } /** * Get the strikeout thickness, as a proportion of the font size. * @since 1.1 */ public float getStrikeoutThickness() { return font.getStrikeoutThickness(); } /** * Get the strikeout position, as a proportion of the font size. * @since 1.1 */ public float getStrikeoutPosition() { return font.getStrikeoutPosition(); } /** * <p> * Get the recommended size of a super/sub script version of this font, as * a proportion of the normal font size. Typical value is around 0.6. * </p><p> * For some fonts (like CJK or barcode fonts) where there is no concept * of super or subscript, this value is entirely arbitrary. * </p> * @since 1.1 */ public float getSubscriptSize() { return font.getSubscriptSize(); } /** * <p> * Get the recommended position of a super-script version of this font, as * a proportion of the <i>sub-scripted</i> font size. Value is always positive. * </p><p> * For some fonts (like CJK or barcode fonts) where there is no concept * of super or subscript, this value is entirely arbitrary. * </p> * @since 1.1 */ public float getSuperscriptPosition() { return font.getSuperscriptPosition(); } /** * <p> * Get the recommended position of a sub-script version of this font, as * a proportion of the <i>sub-scripted</i> font size. Value is almost always * zero or negative. * </p><p> * For some fonts (like CJK or barcode fonts) where there is no concept * of super or subscript, this value is entirely arbitrary. * </p> * @since 1.1 */ public float getSubscriptPosition() { return font.getSubscriptPosition(); } /** * Return true if the specified font is written Left-to-Right or * Right-to-Left. */ public boolean isHorizontal() { return font.isHorizontal(); } /** * Return true if every character has the same width (like Courier), * false if every character is potentially a different width (like * Times-Roman) * @since 1.1.23 */ public boolean isMonospace() { return font.isMonospace(); } /** * All fonts can be cloned. The clone is identical but (if the font can * be remapped) it will have the default mapping. */ public Object clone() { PDFFont f=null; try { f = (PDFFont)super.clone(); } catch (CloneNotSupportedException e) {} return f; } /** * Return the Base Font Name for this font. */ public final String getBaseName() { return font.getBaseName(); } /** * Get the horizontal character-to-character (or "pair-wise") kerning in this font * for the specified characters, in millipoints. This is the distance to move the * text cursor left after drawing character c1 in order to correctly position * character c2. For many fonts and combinations of characters, this returns zero. * (Method promoted from {@link PDFSimpleFont} in version 1.1.14) * * @see PDFStyle#setTrackKerning */ public int getKerning(char c1, char c2) { return font.getKerning(c1,c2); } /** * <p> * Return the specified string with ligatures substituted where appropriate. * Which ligatures are available depends on those that are defined in the font. * The zero-width non-joiner (U+200D) can be used to inhibit ligatures * </p> * <p> * Also replaces all instances of the Unicode Line or Paragraph separators (U+2028 and U+2029) * with a standard newline character * </p> * @since 1.1 * @deprecated since 1.2.1 the {@link #ligaturize(char[],int,int,Locale)} method is preferred. This method will be * removed in the near future. */ public String ligaturize(String s, Locale locale) { return font.ligaturize(s,locale); } /** * Substitute ligatures into the specified string where appropriate. * As for {@link #ligaturize(String, Locale)} but takes a character array * @param buf the buffer to modify * @param off the offset into the buffer for the start of the data * @param len the length of the data in the buffer * @param locale controls which language the buffer is in. Currently not used. * @return the new length of the buffer * @since 1.2.1 */ public int ligaturize(char[] buf, int off, int len, Locale locale) { return font.ligaturize(buf,off,len,locale); } /** * Substitute curly-quotes into the specified buffer where appropriate. * As for {@link PDFPage#requote} but takes a character array. * @param buf the buffer to modify * @param off the offset into the buffer to the start of the data * @param len the length of the data in the buffer * @param locale determines which style of quote is substituted. Recognized languages are english, dutch, italian, spanish, portuguese, catalan, turkish, czech, german, slovak, danish, swedish, norwegian, finnish, polish and hungarian * @return true if quotes were substituted, false otherwise * @since 1.2.1 */ public boolean requote(char[] buf, int off, int len, Locale locale) { return font.requote(buf,off,len,locale); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -