Example #1
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;
 }