Package org.pentaho.reporting.libraries.fonts.registry

Examples of org.pentaho.reporting.libraries.fonts.registry.FontMetrics


        isFeatureSupported(OutputProcessorFeature.EMBED_ALL_FONTS) ||
            styleSheet.getBooleanStyleProperty(TextStyleKeys.EMBEDDED_FONT);
    final boolean bold = styleSheet.getBooleanStyleProperty(TextStyleKeys.BOLD, false);
    final boolean italics = styleSheet.getBooleanStyleProperty(TextStyleKeys.ITALIC, false);

    final FontMetrics metrics = getFontMetrics(fontFamily, fontSize, bold, italics, encoding, embedded, antiAliasing);
    final CacheKey key = new CacheKey(styleSheet.getId(), styleSheet.getClass().getName());
    fontMetricsByStyleCache.put(key, new StyleCacheEntry(styleSheet.getChangeTracker(), metrics));
    return metrics;
  }
View Full Code Here


    Arrays.sort(sourceFiles);
    for (int i = 0; i < sourceFiles.length; i++)
    {
      final String sourceFile = sourceFiles[i];
      final FontRecord fontRecord = records.get(sourceFile);
      final FontMetrics metrics = metricsFactory.createMetrics(fontRecord.getIdentifier(), context);

      writer.writeTag(null, "font-source", "source", sourceFile, false);
/*
    <global-metrics ascent="0" descent="0" italic-angle="0" leading="0"
                    max-ascent="0" max-char-advance="0" max-descent="0" max-height="0"
                    overline-position="0" strike-through-position="0" underline-position="0" x-height="0"
                    uniform="false"/>

*/
      final AttributeList globalAttrs = new AttributeList();
      globalAttrs.setAttribute(null, "ascent", formatText(metrics.getAscent()));
      globalAttrs.setAttribute(null, "descent", formatText(metrics.getDescent()));
      globalAttrs.setAttribute(null, "italic-angle", formatText(metrics.getItalicAngle()));
      globalAttrs.setAttribute(null, "leading", formatText(metrics.getLeading()));
      globalAttrs.setAttribute(null, "max-ascent", formatText(metrics.getMaxAscent()));
      globalAttrs.setAttribute(null, "max-char-advance", formatText(metrics.getMaxCharAdvance()));
      globalAttrs.setAttribute(null, "max-descent", formatText(metrics.getMaxDescent()));
      globalAttrs.setAttribute(null, "max-height", formatText(metrics.getMaxHeight()));
      globalAttrs.setAttribute(null, "overline-position", formatText(metrics.getOverlinePosition()));
      globalAttrs.setAttribute(null, "strike-through-position", formatText(metrics.getStrikeThroughPosition()));
      globalAttrs.setAttribute(null, "underline-position", formatText(metrics.getUnderlinePosition()));
      globalAttrs.setAttribute(null, "x-height", formatText(metrics.getXHeight()));
      globalAttrs.setAttribute(null, "uniform", String.valueOf(metrics.isUniformFontMetrics()));
      writer.writeTag(null, "global-metrics", globalAttrs, true);

      for (int c = 0; c < 65536; c++)
      {
        if (c >= 0xD800 && c <= 0xDFFF)
        {
          // surrogate range is not valid in unicode
          continue;
        }
        final long width = metrics.getCharWidth(c);
        if (width == 0)
        {
          continue;
        }
        final AttributeList cwList = new AttributeList();
        cwList.setAttribute(null, "codepoint", String.valueOf(c));
        cwList.setAttribute(null, "value", String.valueOf(width));
        writer.writeTag(null, "char-width", cwList, true);
      }

      for (int c = 0; c < 65536; c++)
      {
        if (c >= 0xD800 && c <= 0xDFFF)
        {
          // surrogate range is not valid in unicode
          continue;
        }
        final long width = metrics.getCharWidth(c);
        if (width == 0)
        {
          // if there is no metrics, there is no kerning info
          continue;
        }

        for (int cPrev = 0; cPrev < 65536; cPrev++)
        {
          if (cPrev >= 0xD800 && cPrev <= 0xDFFF)
          {
            // surrogate range is not valid in unicode
            continue;
          }
          final long kerning = metrics.getKerning(cPrev, c);
          if (kerning == 0)
          {
            continue;
          }
          final AttributeList cwList = new AttributeList();
View Full Code Here

    final int minHeight = element.getStyle().getIntStyleProperty(ElementStyleKeys.MIN_HEIGHT, 0);
    final double lineHeight = element.getStyle().getIntStyleProperty(TextStyleKeys.LINEHEIGHT, 0);
    final int declaredFontSize = element.getStyle().getIntStyleProperty(TextStyleKeys.FONTSIZE, 0);

    final FontMetrics fontMetrics = outputProcessorMetaData.getFontMetrics(element.getStyle());
    final double fontHeight = StrictGeomUtility.toExternalValue(fontMetrics.getMaxHeight());

    final long effectiveLineHeight =
        RenderLength.resolveLength(StrictGeomUtility.toInternalValue(declaredFontSize), lineHeight);
    if (fontHeight <= Math.max(minHeight, StrictGeomUtility.toExternalValue(effectiveLineHeight)))
    {
View Full Code Here

    final DefaultFontContext fontContext =
        new DefaultFontContext (this, spec.isAntiAliasing(), spec.getFontSize(), "UTF-8", false);

    final FontRecord record = family.getFontRecord
            (spec.getFontWeight() > 600, spec.isItalic() || spec.isOblique());
    final FontMetrics fm = getFontStorage().getFontMetrics
            (record.getIdentifier(), fontContext);
    if (fm == null)
    {
      throw new NullPointerException("FontMetrics returned from factory is null.");
    }
View Full Code Here

            (context.getValue(TextStyleKeys.WHITE_SPACE_COLLAPSE)));
    staticBoxLayoutProperties.setDominantBaseline
        (context.getValue(LineStyleKeys.DOMINANT_BASELINE));

    final FontSpecification fontSpecification = context.getFontSpecification();
    final FontMetrics fontMetrics = metaData.getFontMetrics(fontSpecification);
    staticBoxLayoutProperties.setNominalBaselineInfo
        (TextUtility.createBaselineInfo('x', fontMetrics));

    final CSSValue widowsValue = context.getValue(PageStyleKeys.WIDOWS);
    staticBoxLayoutProperties.setWidows(Math.max(1, (int)
View Full Code Here

      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final FontMetrics fontMetrics = metaData.getFontMetrics(fspec);
        if (fontMetrics == null)
        {
          final long fontSize = (long) (fspec.getFontSize() * DEFAULT_X_HEIGHT_FACTOR);
          return StrictGeomUtility.toExternalValue((long) (value.getValue() * fontSize));
        }
        else
        {
          return StrictGeomUtility.toExternalValue((long) (value.getValue() * fontMetrics.getXHeight()));
        }
      }
    }
    return 0;
  }
View Full Code Here

      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final FontMetrics fontMetrics = metaData.getFontMetrics(fspec);
        if (fontMetrics == null)
        {
          final long fontSize = (long) (fspec.getFontSize() * DEFAULT_X_HEIGHT_FACTOR);
          return StrictGeomUtility.multiply (internal, fontSize);
        }
        else
        {
          return StrictGeomUtility.multiply (internal, fontMetrics.getXHeight());
        }
      }
    }
    return 0;
  }
View Full Code Here

    lookupKey.setFontSize(context.getFontSize());
    lookupKey.setIdentifier(rawRecord);
    lookupKey.setFractional(context.isFractionalMetrics());
    lookupKey.setEncoding(effectiveEncoding);

    final FontMetrics cachedMetrics = knownMetrics.getFontMetrics(lookupKey);
    if (cachedMetrics != null)
    {
      hits += 1;
      return cachedMetrics;
    }

    misses += 1;

    final EncodingFontContextWrapper contextWrapper = new EncodingFontContextWrapper(context, effectiveEncoding);
    final FontMetrics metrics = metricsFactory.createMetrics(rawRecord, contextWrapper);
    final EncodingFontKey key = new EncodingFontKey(rawRecord, context.isAntiAliased(),
        context.isFractionalMetrics(), context.getFontSize(), effectiveEncoding);
    knownMetrics.putFontMetrics(key, metrics);
    return metrics;
  }
View Full Code Here

    backend = new HashMap();
  }

  public FontMetrics getFontMetrics(final FontKey fontKey)
  {
    final FontMetrics metrics = (FontMetrics) backend.get(fontKey);
    if (metrics != null)
    {
      return metrics;
    }
    if (secondLevelCache == null)
    {
      return null;
    }
    final FontMetrics fromSecondLevel = secondLevelCache.getFontMetrics(fontKey);
    if (fromSecondLevel != null)
    {
      backend.put(fontKey.clone(), fromSecondLevel);
      return fromSecondLevel;
    }
View Full Code Here

  {
    final FontSpecification fontSpecification =
        layoutContext.getFontSpecification();
    final OutputProcessorMetaData outputMetaData =
        layoutProcess.getOutputMetaData();
    final FontMetrics fontMetrics =
        outputMetaData.getFontMetrics(fontSpecification);
    return new VariableFontSizeProducer(fontMetrics);
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.fonts.registry.FontMetrics

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.