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

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


      final StaticBoxLayoutProperties staticBoxLayoutProperties = writeContext.getStaticBoxLayoutProperties();
      long spaceWidth = staticBoxLayoutProperties.getSpaceWidth();
      if (spaceWidth == 0)
      {
        // Space has not been computed yet.
        final FontMetrics fontMetrics = metaData.getFontMetrics(writeContext.getStyleSheet());
        spaceWidth = fontMetrics.getCharWidth(' ');
        staticBoxLayoutProperties.setSpaceWidth(spaceWidth);
      }

      if ((next.getNodeType() & LayoutNodeTypes.MASK_BOX) == LayoutNodeTypes.MASK_BOX)
      {
View Full Code Here


                                                    final boolean embedded,
                                                    final boolean antiAliasing) throws IllegalArgumentException
  {
    try
    {
      final FontMetrics metrics = super.getFontMetrics(fontFamily, fontSize, bold, italics, encoding, embedded,
          antiAliasing);
      if (metrics instanceof LegacyFontMetrics)
      {
        final LegacyFontMetrics lm = (LegacyFontMetrics) metrics;
        return (BaseFontFontMetrics) lm.getParent();
View Full Code Here

    lookupKey.setFontFamily(fontFamily);
    lookupKey.setFontSize(fontSize);
    lookupKey.setBold(bold);
    lookupKey.setItalics(italics);

    final FontMetrics cached = (FontMetrics) fontMetricsCache.get(lookupKey);
    if (cached != null)
    {
      return cached;
    }

    final FontRegistry registry = getFontRegistry();
    FontFamily family = registry.getFontFamily(fontFamily);
    if (family == null)
    {
      AbstractOutputProcessorMetaData.logger.warn("Unable to lookup the font family: " + fontFamily);

      // Get the default font name
      final String fallBack = getNormalizedFontFamilyName(null);
      if (fallBack == null)
      {
        // If this case happens, the output-processor meta-data does not provide a sensible
        // fall-back value. As we cannot continue without a font, we fail here instead of
        // waiting for a NullPointer or other weird error later.
        throw new IllegalArgumentException("No default family defined, aborting.");
      }

      family = registry.getFontFamily(fallBack);
      if (family == null)
      {
        // If this case happens, the output-processor meta-data does not provide a sensible
        // fall-back value. As we cannot continue without a font, we fail here instead of
        // waiting for a NullPointer or other weird error later.
        throw new IllegalArgumentException("Default family is invalid. Aborting.");
      }
    }


    reusableFontContext.setAntiAliased(antiAliasing);
    reusableFontContext.setFontSize(fontSize);
    reusableFontContext.setEncoding(encoding);
    reusableFontContext.setEmbedded(embedded);

    final FontRecord record = family.getFontRecord(bold, italics);
    final FontMetrics fm = getFontStorage().getFontMetrics(record.getIdentifier(), reusableFontContext);
    if (fm == null)
    {
      // If this case happens, then the previous steps of mapping the font name into sensible
      // defaults failed. The font-system's font-registry is not in sync with the actual font-metrics
      // provider (which indicates that the LibFonts font-system implementation is invalid).
View Full Code Here

    return fm;
  }

  public ExtendedBaselineInfo getBaselineInfo(final int codePoint, final StyleSheet styleSheet)
  {
    final FontMetrics fontMetrics = getFontMetrics(styleSheet);
    if (fontMetrics.isUniformFontMetrics())
    {
      final String fontFamily = getNormalizedFontFamilyName((String) styleSheet.getStyleProperty(TextStyleKeys.FONT));
      if (fontFamily == null)
      {
        // If this case happens, the stylesheet is not implemented correctly. At that point,
        // we have to assume that the whole engine is no longer behaving valid and therefore we
        // abort early.
        throw new IllegalArgumentException("No valid font family specified.");
      }

      final double fontSize = styleSheet.getDoubleStyleProperty
          (TextStyleKeys.FONTSIZE, defaultFontSize);

      final boolean antiAliasing = RenderUtility.isFontSmooth(styleSheet, this);
      final String encoding = (String) styleSheet.getStyleProperty(TextStyleKeys.FONTENCODING);
      final boolean embedded =
          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);

      lookupKey.setAntiAliased(antiAliasing);
      lookupKey.setEncoding(encoding);
      lookupKey.setEmbedded(embedded);
      lookupKey.setFontFamily(fontFamily);
      lookupKey.setFontSize(fontSize);
      lookupKey.setBold(bold);
      lookupKey.setItalics(italics);

      final ExtendedBaselineInfo cached = (ExtendedBaselineInfo) baselinesCache.get(lookupKey);
      if (cached != null)
      {
        return cached;
      }
    }
    final ExtendedBaselineInfo baselineInfo = TextUtility.createBaselineInfo('x', fontMetrics, null);
    if (fontMetrics.isUniformFontMetrics())
    {
      baselinesCache.put(new FontMetricsKey(lookupKey), baselineInfo);
    }
    return baselineInfo;
  }
View Full Code Here

        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);
    fontMetricsByStyleCache.put(key, new StyleCacheEntry(styleSheet.getChangeTracker(), metrics));
    return metrics;
  }
View Full Code Here

                                                    final boolean embedded,
                                                    final boolean antiAliasing) throws IllegalArgumentException
  {
    try
    {
      final FontMetrics metrics = super.getFontMetrics(fontFamily, fontSize, bold, italics, encoding, embedded,
          antiAliasing);
      if (metrics instanceof LegacyFontMetrics)
      {
        final LegacyFontMetrics lm = (LegacyFontMetrics) metrics;
        return (BaseFontFontMetrics) lm.getParent();
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

    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(RenderableText.convert(fontMetrics.getMaxHeight()));

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

    lookupKey.setFontFamily(fontFamily);
    lookupKey.setFontSize(fontSize);
    lookupKey.setBold(bold);
    lookupKey.setItalics(italics);

    final FontMetrics cached = (FontMetrics) fontMetricsCache.get(lookupKey);
    if (cached != null)
    {
      return cached;
    }

    final FontRegistry registry = getFontRegistry();
    FontFamily family = registry.getFontFamily(fontFamily);
    if (family == null)
    {
      AbstractOutputMetaData.logger.warn("Unable to lookup the font family: " + fontFamily);

      // Get the default font name
      final CSSValue fallBack = getDefaultFontFamily();
      if (fallBack == null)
      {
        // If this case happens, the output-processor meta-data does not provide a sensible
        // fall-back value. As we cannot continue without a font, we fail here instead of
        // waiting for a NullPointer or other weird error later.
        throw new IllegalArgumentException("No default family defined, aborting.");
      }

      if (fallBack instanceof CSSStringValue)
      {
        final CSSStringValue svalue = (CSSStringValue) fallBack;
        family = registry.getFontFamily(svalue.getValue());
      }
      else
      {
        family = registry.getFontFamily(fallBack.getCSSText());
      }
      if (family == null)
      {
        // If this case happens, the output-processor meta-data does not provide a sensible
        // fall-back value. As we cannot continue without a font, we fail here instead of
        // waiting for a NullPointer or other weird error later.
        throw new IllegalArgumentException("Default family is invalid. Aborting.");
      }
    }


    reusableFontContext.setAntiAliased(antiAliasing);
    reusableFontContext.setFontSize(fontSize);
    reusableFontContext.setEncoding(encoding);
    reusableFontContext.setEmbedded(embedded);

    final FontRecord record = family.getFontRecord(bold, italics);
    final FontMetrics fm = getFontStorage().getFontMetrics(record.getIdentifier(), reusableFontContext);
    if (fm == null)
    {
      // If this case happens, then the previous steps of mapping the font name into sensible
      // defaults failed. The font-system's font-registry is not in sync with the actual font-metrics
      // provider (which indicates that the LibFonts font-system implementation is invalid).
View Full Code Here

    lookupKey.setAliased(context.isAntiAliased());
    lookupKey.setFontSize(context.getFontSize());
    lookupKey.setIdentifier(record);
    lookupKey.setFractional(context.isFractionalMetrics());

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

    final CompoundFontIdentifier cid = (CompoundFontIdentifier) record;
    final FontRegistry registry = cid.getRegistry();
    FontMetricsFactory metricsFactory = (FontMetricsFactory) metricsFactories.get(registry);
    if (metricsFactory == null)
    {
      metricsFactory = registry.createMetricsFactory();
      metricsFactories.put(registry, metricsFactory);
    }

    misses += 1;

    final FontKey key = new FontKey(record, context.isAntiAliased(),
        context.isFractionalMetrics(), context.getFontSize());
    final FontMetrics metrics = metricsFactory.createMetrics(cid.getIdentifier(), context);
    firstLevelFontCache.putFontMetrics(key, metrics);
    return metrics;
  }
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.