Package org.axsl.font

Examples of org.axsl.font.FontUse


     * Computes the width of a word, in millipoints.
     * @param word The word whose width should be computed.
     * @return The width of the word, in millipoints.
     */
    public int getWordWidth(final CharSequence word) {
        final FontUse fontUse = getPrimaryFont();
        final Font font = fontUse.getFont();
        fontUse.registerCharsUsed(word);
        return font.width(word, traitFontSize(),
                traitGeneratedBy().traitLetterSpacingOpt(this),
                traitGeneratedBy().traitWordSpacingOpt(this), true);
    }
View Full Code Here


        /* The block area. */
        AreaNode node = firstNormalFlowArea.getChildAt(0);
        assertTrue(node instanceof NormalBlockArea);
        final NormalBlockArea blockArea = (NormalBlockArea) node;
        final FontUse font = blockArea.getPrimaryFont();
        assertEquals("Courier", font.getFont().getPostscriptName());
        assertEquals(12000, blockArea.traitFontSize());

        /* The first child of the block area is a line-area. */
        node = blockArea.getChildAt(0);
        assertTrue(node instanceof LineArea);
View Full Code Here

        /* TODO: If the font handles small-caps natively, that is, they do not need to be simulated,
         * return false, regardless of whether it has also been configured to simulate small caps.
         * Right now we rely on the user to configure the font correctly to avoid this. */

        /* Has the font been configured to simulate small-caps? */
        final FontUse fontUse = this.getPrimaryFont(context);
        if (fontUse.simulateSmallCaps() == FontServer.SMALL_CAP_SIMULATION_INVALID) {
            return false;
        }
        return true;
    }
View Full Code Here

     * @param fobj The FO for which this value is needed.
     * @return The initial value for the multiplier component of this property.
     */
    public static float getValueMultiplierNoInstance(final FoContext context,
            final FObj fobj) {
        final FontUse fontUse = fobj.getPrimaryFont(context);
        final Font.LineHeightAlgorithm algorithm
                = Font.LineHeightAlgorithm.DEFAULT;
        return fontUse.getFont().normalLineHeightFactor(algorithm);
    }
View Full Code Here

    FontUse getInheritedFont(final FoContext context, final FObj fobj) {
        final FObj parent = fobj.effectiveParent(context);
        if (parent == null) {
            return null;
        }
        final FontUse font = parent.getPrimaryFont(context);
        return font;
    }
View Full Code Here

            /* Position the cursor. */
            final float originX = toPoints(area.baselineX());
            final float originY = toPoints(area.baselineY());
            getContentStream().setCursor(originX, originY);

            final FontUse primaryFont = area.getPrimaryFont();
            FontUse currentFont = primaryFont;
            int startIndex = 0;
            for (int i = 0; i < text.length(); i++) {
                final int codePoint = Character.codePointAt(text, i);
                if (Character.isSupplementaryCodePoint(codePoint)) {
                    i++;
                }
                final FontUse newFont = whichFont(area, primaryFont, currentFont,
                        codePoint);
                if (newFont != currentFont) {
                    /* Font has changed. Write the text so far. */
                    final int size = i - startIndex;
                    paintText(area, currentFont, text, startIndex, size,
View Full Code Here

        if (primaryFont.glyphAvailable(c)) {
            return primaryFont;
        }

        /* Look for a secondary font that can do the job. */
        final FontUse secondaryFont = area.getSecondaryFont(c);
        if (secondaryFont != null) {
            return secondaryFont;
        }

        /* Otherwise, punt. */
 
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void renderTextSegment(final TextArea area,
            final CharSequence text) {
        final FontUse font = area.getPrimaryFont();
        final int size = area.traitFontSize();

        final float red = colorToFloat(area.traitColor().getRed());
        final float green = colorToFloat(area.traitColor().getGreen());
        final float blue = colorToFloat(area.traitColor().getBlue());
View Full Code Here

     * @param context An object that knows how to resolve FO Tree context
     * issues.
     * @return This object's dominant-baseline, as computed from its font and script.
     */
    public Baseline getBaselineFromScript(final FoContext context) {
        final FontUse fontUse = this.getPrimaryFont(context);
        if (fontUse == null) {
            throw new IllegalStateException("Unable to obtain a font for baseline computation.");
        }
        final Font font = fontUse.getFont();
        final Script script = this.traitScript(context);
        final String opentypeScript = FontUtil.getOpenTypeScript(script);
        final Font.Baseline fontBaseline = font.baseline(opentypeScript);
        switch (fontBaseline) {
        case ALPHABETIC: return Baseline.ALPHABETIC;
View Full Code Here

     * size needed to get the width.
     * @param codePoint The Unicode code point whose width is needed.
     * @return The width of {@code codePoint}, in millipoints.
     */
    public int getCharWidth(final LineText lineText, final int codePoint) {
        final FontUse fontUse = lineText.inlinePrimaryFont();
        final Font font = fontUse.getFont();
        int fontSize = lineText.inlineFontSize();
        int codePointToUse = codePoint;
        if (lineText.inlineIsFauxSmallCaps()
                && isLowerCase(codePoint)) {
            fontSize = lineText.inlineFauxSmallCapsFontSize();
            codePointToUse = java.lang.Character.toUpperCase((char) codePoint);
        }
        fontUse.registerCharUsed(codePointToUse);
        return font.width(codePointToUse, fontSize)
                + lineText.inlineLetterSpacingOptimum();
    }
View Full Code Here

TOP

Related Classes of org.axsl.font.FontUse

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.