/**
  * Creates a new instance of BasicScaledBaselineTable for the given font, baseline and
  * writingmode.
  *
  * @param font the font for which a baseline table is requested
  * @param dominantBaselineIdentifier the dominant baseline given as an integer constant
  * @param writingMode the writing mode given as an integer constant
  * @return a scaled baseline table for the given font
  */
 public static ScaledBaselineTable makeFontScaledBaselineTable(
     Font font, int dominantBaselineIdentifier, int writingMode) {
   return new BasicScaledBaselineTable(
       font.getAscender(),
       font.getDescender(),
       font.getXHeight(),
       dominantBaselineIdentifier,
       writingMode);
 }
示例#2
0
 /**
  * Returns the effective hyphenation character for a font. The hyphenation character specified in
  * XSL-FO may be substituted if it's not available in the font.
  *
  * @param font the font
  * @return the effective hyphenation character.
  */
 public char getHyphChar(org.apache.fop.fonts.Font font) {
   char hyphChar = hyphenationCharacter.getCharacter();
   if (font.hasChar(hyphChar)) {
     return hyphChar; // short-cut
   }
   char effHyphChar = hyphChar;
   boolean warn = false;
   if (font.hasChar(HYPHEN_MINUS)) {
     effHyphChar = HYPHEN_MINUS;
     warn = true;
   } else if (font.hasChar(MINUS_SIGN)) {
     effHyphChar = MINUS_SIGN;
     FontMetrics metrics = font.getFontMetrics();
     if (metrics instanceof Typeface) {
       Typeface typeface = (Typeface) metrics;
       if ("SymbolEncoding".equals(typeface.getEncodingName())) {
         // SymbolEncoding doesn't have HYPHEN_MINUS, so replace by MINUS_SIGN
       } else {
         // only warn if the encoding is not SymbolEncoding
         warn = true;
       }
     }
   } else {
     effHyphChar = ' ';
     FontMetrics metrics = font.getFontMetrics();
     if (metrics instanceof Typeface) {
       Typeface typeface = (Typeface) metrics;
       if ("ZapfDingbatsEncoding".equals(typeface.getEncodingName())) {
         // ZapfDingbatsEncoding doesn't have HYPHEN_MINUS, so replace by ' '
       } else {
         // only warn if the encoding is not ZapfDingbatsEncoding
         warn = true;
       }
     }
   }
   if (warn) {
     log.warn(
         "Substituted specified hyphenation character (0x"
             + Integer.toHexString(hyphChar)
             + ") with 0x"
             + Integer.toHexString(effHyphChar)
             + " because the font doesn't have the specified hyphenation character: "
             + font.getFontTriplet());
   }
   return effHyphChar;
 }
示例#3
0
 /**
  * Returns the IPD for the hyphenation character for a font.
  *
  * @param font the font
  * @return the IPD in millipoints for the hyphenation character.
  */
 public int getHyphIPD(org.apache.fop.fonts.Font font) {
   char hyphChar = getHyphChar(font);
   return font.getCharWidth(hyphChar);
 }