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

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


    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


    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      // we have no font family, so return.
      layoutContext.setValue(TextStyleKeys.X_MIN_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      layoutContext.setValue(TextStyleKeys.X_MAX_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      layoutContext.setValue(TextStyleKeys.X_OPTIMUM_LETTER_SPACING, CSSNumericValue.ZERO_LENGTH);
      return;
    }

    final double width = StrictGeomUtility.toExternalValue(fm.getCharWidth(0x20));
    final CSSNumericValue percentageBase =
            CSSNumericValue.createValue(CSSNumericType.PT, width);
    final CSSNumericValue min = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MIN_LETTER_SPACING), percentageBase);
    final CSSNumericValue max = CSSValueResolverUtility.getLength
View Full Code Here

    // Percentages get resolved against the width of a standard space (0x20)
    // character.
    final LayoutContext layoutContext = currentNode.getLayoutContext();
    final FontSpecification fontSpecification =
            layoutContext.getFontSpecification();
    final FontMetrics fm = process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fm == null)
    {
      final CSSValue value = layoutContext.getValue(FontStyleKeys.FONT_FAMILY);
      DebugLog.log("FontFamily is " + value + " but has not been set?" + currentNode);
      return;
    }
    final double width = StrictGeomUtility.toExternalValue(fm.getCharWidth(0x20));
    final CSSNumericValue percentageBase =
            CSSNumericValue.createValue(CSSNumericType.PT, width);
    final CSSNumericValue min = CSSValueResolverUtility.getLength
            (resolveValue(layoutContext, TextStyleKeys.X_MIN_WORD_SPACING), percentageBase);
    final CSSNumericValue max = CSSValueResolverUtility.getLength
View Full Code Here

    }

    final double adjustFactor = nval.getValue();
    final FontSpecification fontSpecification =
        currentNode.getLayoutContext().getFontSpecification();
    final FontMetrics fontMetrics =
        process.getOutputMetaData().getFontMetrics(fontSpecification);
    if (fontMetrics == null)
    {
      return; // no font metrics means no valid font...
    }

    final double actualFontXHeight = StrictGeomUtility.toExternalValue(fontMetrics.getXHeight());

    final double fontSize = fontSpecification.getFontSize();
    final double aspectRatio = actualFontXHeight / fontSize;
    final double result = (fontSize * (adjustFactor / aspectRatio));
    fontSpecification.setFontSize(result);
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.