Exemplo n.º 1
0
 private void fillFontDesc(PdfDictionary fontDesc) {
   if (fontDesc == null) return;
   PdfNumber v = fontDesc.getAsNumber(PdfName.ASCENT);
   if (v != null) ascender = v.floatValue();
   v = fontDesc.getAsNumber(PdfName.CAPHEIGHT);
   if (v != null) capHeight = v.floatValue();
   v = fontDesc.getAsNumber(PdfName.DESCENT);
   if (v != null) descender = v.floatValue();
   v = fontDesc.getAsNumber(PdfName.ITALICANGLE);
   if (v != null) italicAngle = v.floatValue();
   v = fontDesc.getAsNumber(PdfName.FONTWEIGHT);
   if (v != null) {
     fontWeight = v.floatValue();
   }
   PdfArray bbox = fontDesc.getAsArray(PdfName.FONTBBOX);
   if (bbox != null) {
     llx = bbox.getAsNumber(0).floatValue();
     lly = bbox.getAsNumber(1).floatValue();
     urx = bbox.getAsNumber(2).floatValue();
     ury = bbox.getAsNumber(3).floatValue();
     if (llx > urx) {
       float t = llx;
       llx = urx;
       urx = t;
     }
     if (lly > ury) {
       float t = lly;
       lly = ury;
       ury = t;
     }
   }
   float maxAscent = Math.max(ury, ascender);
   float minDescent = Math.min(lly, descender);
   ascender = maxAscent * 1000 / (maxAscent - minDescent);
   descender = minDescent * 1000 / (maxAscent - minDescent);
 }