Esempio n. 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;
 }
Esempio n. 2
0
 /** {@inheritDoc} */
 public int hashCode() {
   if (this.hash == 0) {
     int hash = 17;
     hash = 37 * hash + (language == null ? 0 : language.hashCode());
     hash = 37 * hash + (script == null ? 0 : script.hashCode());
     hash = 37 * hash + (country == null ? 0 : country.hashCode());
     hash = 37 * hash + (hyphenate == null ? 0 : hyphenate.hashCode());
     hash = 37 * hash + (hyphenationCharacter == null ? 0 : hyphenationCharacter.hashCode());
     hash =
         37 * hash
             + (hyphenationPushCharacterCount == null
                 ? 0
                 : hyphenationPushCharacterCount.hashCode());
     hash =
         37 * hash
             + (hyphenationRemainCharacterCount == null
                 ? 0
                 : hyphenationRemainCharacterCount.hashCode());
     this.hash = hash;
   }
   return this.hash;
 }