Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.BaseFont


    if (style == UNDEFINED) {
      style = NORMAL;
    }
    String fontName = BaseFont.HELVETICA;
    String encoding = BaseFont.WINANSI;
    BaseFont cfont = null;
    switch (family) {
    case COURIER:
      switch (style & BOLDITALIC) {
      case BOLD:
        fontName = BaseFont.COURIER_BOLD;
View Full Code Here


            if (font.getColor() != null) {
                writeCssProperty(Markup.CSS_KEY_COLOR, HtmlEncoder.encode(font.getColor()));
            }
           
            int fontstyle = font.getStyle();
            BaseFont bf = font.getBaseFont();
            if (bf != null) {
                String ps = bf.getPostscriptFontName().toLowerCase();
                if (ps.indexOf("bold") >= 0) {
                    if (fontstyle == Font.UNDEFINED)
                        fontstyle = 0;
                    fontstyle |= Font.BOLD;
                }
View Full Code Here

            // Create a writer for the outputstream
            final PdfWriter writer = PdfWriter.getInstance(document,
                    outputStream);
            document.open();
            final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
                    BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            final PdfContentByte cb = writer.getDirectContent(); // Holds the
            // PDF data
            PdfImportedPage page;
            int currentPageNumber = 0;
View Full Code Here

        float refY = state.transformY(y);
        float angle = state.transformAngle(font.getAngle());
        float sin = (float)Math.sin(angle);
        float cos = (float)Math.cos(angle);
        float fontSize = font.getFontSize(state);
        BaseFont bf = font.getFont();
        int align = state.getTextAlign();
        float textWidth = bf.getWidthPoint(text, fontSize);
        float tx = 0;
        float ty = 0;
        float descender = bf.getFontDescriptor(BaseFont.DESCENT, fontSize);
        float ury = bf.getFontDescriptor(BaseFont.BBOXURY, fontSize);
        cb.saveState();
        cb.concatCTM(cos, sin, -sin, cos, refX, refY);
        if ((align & MetaState.TA_CENTER) == MetaState.TA_CENTER)
            tx = -textWidth / 2;
        else if ((align & MetaState.TA_RIGHT) == MetaState.TA_RIGHT)
View Full Code Here

            return fontRecord;
          }

          // filename is null, so no ttf file registered for the fontname, maybe this is
          // one of the internal fonts ...
          final BaseFont f = BaseFont.createFont(fontName, stringEncoding, embedded,
              useGlobalCache, null, null);
          if (f != null)
          {
            fontRecord = new BaseFontRecord(fontName, false, embedded, f, bold, italic);
            putToCache(fontRecord);
            return fontRecord;
          }
        }
      }

      // If we got to this point, then the font was not recognized as any known font. We will fall back
      // to Helvetica instead ..
    }
    catch (Exception e)
    {
      if (Log.isDebugEnabled())
      {
        Log.debug(new Log.SimpleMessage
            ("BaseFont.createFont failed. Key = ", fontKey, ": ", e.getMessage()), e);
      }
      else if (Log.isWarningEnabled())
      {
        Log.warn(new Log.SimpleMessage
            ("BaseFont.createFont failed. Key = ", fontKey, ": ", e.getMessage()));
      }
    }
    // fallback .. use BaseFont.HELVETICA as default
    try
    {
      // check, whether HELVETICA is already created - yes, then return cached instance instead
      BaseFontRecord fontRecord = getFromCache(BaseFont.HELVETICA, stringEncoding, embedded);
      if (fontRecord != null)
      {
        // map all font references of the invalid font to the default font..
        // this might be not very nice, but at least the report can go on..
        putToCache(new BaseFontRecordKey(fontKey, encoding, embedded), fontRecord);
        return fontRecord;
      }

      // no helvetica created, so do this now ...
      final BaseFont f = BaseFont.createFont(BaseFont.HELVETICA, stringEncoding, embedded,
          useGlobalCache, null, null);
      if (f != null)
      {
        fontRecord = new BaseFontRecord
            (BaseFont.HELVETICA, false, embedded, f, bold, italic);
View Full Code Here

    if (fontRec != null)
    {
      return fontRec;
    }

    BaseFont f;
    try
    {
      try
      {
        f = BaseFont.createFont(filename, encoding, embedded, false, null, null);
View Full Code Here

    else
    {
      throw new IllegalArgumentException("Unknown font-identifier type encountered.");
    }

    final BaseFont baseFont = baseFontSupport.createBaseFont
        (fontName, bold, italic, context.getEncoding(), context.isEmbedded());

    final FontMetrics metrics = new BaseFontFontMetrics(baseFont, (float) context.getFontSize());
    final FontKey key = new FontKey(rawRecord, context.isAntiAliased(),
        context.isFractionalMetrics(), context.getFontSize());
View Full Code Here

            .canRead() == false)
    {
      Log.warn("Cannot embedd font: " + filePfb + " is missing for " + font);
      embedded = false;
    }
    BaseFont bfont;
    try
    {
      bfont = BaseFont.createFont(font, encoding, embedded, false, null, null);
    }
    catch (DocumentException de)
    {
      if (embedded == false)
      {
        throw de;
      }
      // failed to load the font as embedded font, try not-embedded.
      bfont = BaseFont.createFont(font, encoding, false, false, null, null);
      embedded = false;
      Log.info(new Log.SimpleMessage
              ("Font ", font, "  cannot be used as embedded font " +
                      "due to licensing restrictions (PFB)."));
    }

    String embeddedText = String.valueOf(embedded);
    final String[][] fi = bfont.getFullFontName();
    for (int i = 0; i < fi.length; i++)
    {
      final String[] ffi = fi[i];
      final String knownFontEmbeddedState = notEmbeddedFonts.getProperty(font,
              "false");

      // if unknown or the known font is a restricted version and this one is none,
      // then register the new font
      final String logicalFontname = ffi[3];
      notEmbeddedFonts.setProperty(font, embeddedText);
      if ((fontsByName.containsKey(logicalFontname) == false) ||
              (("true".equals(knownFontEmbeddedState) == false) &&
                      embeddedText.equals(knownFontEmbeddedState) == false))
      {
        fontsByName.setProperty(logicalFontname, font);
        Log.debug(new Log.SimpleMessage
                ("Registered font (primary name):", logicalFontname,
                        "; embedded=",
                        embeddedText, new Log.SimpleMessage(", file=", font)));
      }
    }

    final String[][] afi = bfont.getFamilyFontName();
    for (int i = 0; i < afi.length; i++)
    {
      String[] strings = afi[i];
      Log.debug(new Log.SimpleMessage
              ("Registered font (alternate name):", strings[3], "; embedded=",
View Full Code Here

    }

    try
    {
      Log.debug ("Created font " + fontType);
      BaseFont baseFont = BaseFont.createFont
              (fontType, encoding, embedded, false, ttfAfm, pfb);
      return new CompoundResource (key, dc, baseFont);
    }
    catch (Exception e)
    {
View Full Code Here

          return fontRecord;
        }

        // filename is null, so no ttf file registered for the fontname, maybe this is
        // one of the internal fonts ...
        final BaseFont f = BaseFont.createFont(fontKey, stringEncoding, embedded,
                useGlobalCache, null, null);
        if (f != null)
        {
          fontRecord = new BaseFontRecord(fontKey, false, embedded, f, bold, italic);
          putToCache(fontRecord);
          return fontRecord;
        }
      }
    }
    catch (Exception e)
    {
      if (Log.isDebugEnabled())
      {
        Log.debug(new Log.SimpleMessage
              ("BaseFont.createFont failed. Key = ", fontKey, ": ", e.getMessage()), e);
      }
      else if (Log.isWarningEnabled())
      {
        Log.warn(new Log.SimpleMessage
              ("BaseFont.createFont failed. Key = ", fontKey, ": ", e.getMessage()));
      }
    }
    // fallback .. use BaseFont.HELVETICA as default
    try
    {
      // check, whether HELVETICA is already created - yes, then return cached instance instead
      BaseFontRecord fontRecord = getFromCache(BaseFont.HELVETICA, stringEncoding, embedded);
      if (fontRecord != null)
      {
        // map all font references of the invalid font to the default font..
        // this might be not very nice, but at least the report can go on..
        putToCache(new BaseFontRecordKey(fontKey, encoding, embedded), fontRecord);
        return fontRecord;
      }

      // no helvetica created, so do this now ...
      final BaseFont f = BaseFont.createFont(BaseFont.HELVETICA, stringEncoding, embedded,
              useGlobalCache, null, null);
      if (f != null)
      {
        fontRecord = new BaseFontRecord
                (BaseFont.HELVETICA, false, embedded, f, bold, italic);
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.BaseFont

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.