当前位置: 首页>>代码示例>>Java>>正文


Java GVTFont类代码示例

本文整理汇总了Java中org.apache.batik.gvt.font.GVTFont的典型用法代码示例。如果您正苦于以下问题:Java GVTFont类的具体用法?Java GVTFont怎么用?Java GVTFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GVTFont类属于org.apache.batik.gvt.font包,在下文中一共展示了GVTFont类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initLineInfo

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
public void initLineInfo(FontRenderContext frc) {
    float fontSize = 12;
    Float fsFloat = (Float)fontAttrs.get(TextAttribute.SIZE);
    if (fsFloat != null)
        fontSize = fsFloat.floatValue();

    Iterator i = fontList.iterator();
    while (i.hasNext()) {
        GVTFont font = (GVTFont)i.next();
        GVTLineMetrics lm = font.getLineMetrics("", frc);
        this.ascent = lm.getAscent();
        this.descent = lm.getDescent();
        break;
    }
    if (ascent == -1) {
        ascent  = fontSize * 0.8f;
        descent = fontSize * 0.2f;
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:20,代码来源:BlockInfo.java

示例2: deriveFont

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
@Override
public GVTFont deriveFont(float size, Map attrs) 
{
	if (font != null)
		return new AWTGVTFont(font, size);

	String fontFamilyName = fontFace.getFamilyName();
	if (
		fontFamilyName.startsWith("'")
		&& fontFamilyName.endsWith("'")
		)
	{
		fontFamilyName = fontFamilyName.substring(1, fontFamilyName.length() - 1);
	}

	// svg font-family could have locale suffix because it is needed in svg measured by phantomjs;
	int localeSeparatorPos = fontFamilyName.lastIndexOf(HtmlFontFamily.LOCALE_SEPARATOR);
	if (localeSeparatorPos > 0)
	{
		fontFamilyName = fontFamilyName.substring(0, localeSeparatorPos);
	}

	Font awtFont = 
		FontUtil.getInstance(jasperReportsContext).getAwtFontFromBundles(
			true,
			fontFamilyName,
			(TextAttribute.WEIGHT_BOLD.equals(attrs.get(TextAttribute.WEIGHT)) ? Font.BOLD : Font.PLAIN)
			| (TextAttribute.POSTURE_OBLIQUE.equals(attrs.get(TextAttribute.POSTURE)) ? Font.ITALIC : Font.PLAIN),
			size, 
			null,//FIXMEBATIK locale 
			true
			);
	
	if (awtFont != null)
	{
		return new AWTGVTFont(awtFont);
	}

	return super.deriveFont(size, attrs);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:41,代码来源:BatikAWTFontFamily.java

示例3: GlyphIterator

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
public GlyphIterator(AttributedCharacterIterator aci,
                     GVTGlyphVector gv) {
    this.aci       = aci;
    this.gv        = gv;

    this.idx       = 0;
    this.chIdx     = 0;
    this.lineIdx   = 0;
    this.aciIdx    = aci.getBeginIndex();
    this.charCount = gv.getCharacterCount(idx, idx);
    this.ch        = aci.first();
    this.frc       = gv.getFontRenderContext();

    this.font = (GVTFont)aci.getAttribute(GVT_FONT);
    if (font == null) {
        font = new AWTGVTFont(aci.getAttributes());
    }
    fontStart = aciIdx;
    this.maxFontSize = -Float.MAX_VALUE;
    this.maxAscent   = -Float.MAX_VALUE;
    this.maxDescent  = -Float.MAX_VALUE;

    // Figure out where the font size might change again...
    this.runLimit  = aci.getRunLimit(TEXT_COMPOUND_ID);

    this.lineBreakRunLimit = aci.getRunLimit(FLOW_LINE_BREAK);
    Object o = aci.getAttribute(FLOW_LINE_BREAK);
    this.lineBreakCount = (o == null)?0:1;


    this.numGlyphs   = gv.getNumGlyphs();
    this.gp          = gv.getGlyphPositions(0, this.numGlyphs+1, null);
    this.gvBase      = new Point2D.Float(gp[0], gp[1]);
    this.adv = getCharWidth();
    this.adj = getCharAdvance();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:37,代码来源:GlyphIterator.java

示例4: deriveFont

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
/**
 * Derives a GVTFont object of the correct size from an attribute Map.
 * @param size  The required size of the derived font.
 * @param attrs The Attribute Map to get Values from.
 */
public GVTFont deriveFont(float size, Map attrs) {
    SVGFontElementBridge fontBridge;
    fontBridge = (SVGFontElementBridge)ctx.getBridge(fontElement);
    SoftReference sr = (SoftReference)attrs.get(TEXT_COMPOUND_ID);
    Element textElement = (Element)sr.get();
    return fontBridge.createFont(ctx, fontElement, textElement,
                                 size, fontFace);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:SVGFontFamily.java

示例5: getFont

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
/**
 * Returns the GVTFont to use when rendering the specified
 * character iterator.  This should already be set as an attribute
 * on the aci.
 *
 * @return The GVTFont to use.
 */
protected GVTFont getFont() {
    aci.first();
    GVTFont gvtFont = (GVTFont)aci.getAttribute(GVT_FONT);

    if (gvtFont != null)
        return gvtFont;

    // shouldn't get here
    return new AWTGVTFont(aci.getAttributes());
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:18,代码来源:GlyphLayout.java

示例6: getFontList

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
/**
 * This method adds all the font related properties to <code>result</code>
 * It also builds a List of the GVTFonts and returns it.
 */
protected List getFontList(BridgeContext ctx,
                           Element       element,
                           Map           result) {

    // Unique value for text element - used for run identification.
    result.put(TEXT_COMPOUND_ID, new SoftReference(element));

    Float fsFloat = TextUtilities.convertFontSize(element);
    float fontSize = fsFloat.floatValue();
    // Font size.
    result.put(TextAttribute.SIZE, fsFloat);

    // Font stretch
    result.put(TextAttribute.WIDTH,
            TextUtilities.convertFontStretch(element));

    // Font style
    result.put(TextAttribute.POSTURE,
            TextUtilities.convertFontStyle(element));

    // Font weight
    result.put(TextAttribute.WEIGHT,
            TextUtilities.convertFontWeight(element));

    // Font weight
    Value v = CSSUtilities.getComputedStyle
        (element, SVGCSSEngine.FONT_WEIGHT_INDEX);
    String fontWeightString = v.getCssText();

    // Font style
    String fontStyleString = CSSUtilities.getComputedStyle
        (element, SVGCSSEngine.FONT_STYLE_INDEX).getStringValue();

    // Needed for SVG fonts (also for dynamic documents).
    result.put(TEXT_COMPOUND_DELIMITER, element);

    //  make a list of GVTFont objects
    Value val = CSSUtilities.getComputedStyle
        (element, SVGCSSEngine.FONT_FAMILY_INDEX);
    List fontFamilyList = new ArrayList();
    List fontList = new ArrayList();
    int len = val.getLength();
    for (int i = 0; i < len; i++) {
        Value it = val.item(i);
        String fontFamilyName = it.getStringValue();
        GVTFontFamily fontFamily;
        fontFamily = SVGFontUtilities.getFontFamily(element, ctx, fontFamilyName,
                fontWeightString, fontStyleString);
        if (fontFamily != null && fontFamily instanceof UnresolvedFontFamily) {
            fontFamily = ctx.getFontFamilyResolver().resolve(fontFamily.getFamilyName());
        }
        if (fontFamily == null) {
            continue;
        }
        fontFamilyList.add(fontFamily);
        if (fontFamily.isComplex()) {
            usingComplexSVGFont = true;
        }
        GVTFont ft = fontFamily.deriveFont(fontSize, result);
        fontList.add(ft);
    }

    // Eventually this will need to go for SVG fonts it
    // holds hard ref to DOM.
    result.put(GVT_FONT_FAMILIES, fontFamilyList);

    if (!ctx.isDynamic()) {
        // Only leave this in the map for dynamic documents.
        // Otherwise it will cause the whole DOM to stay when
        // we don't really need it.
        result.remove(TEXT_COMPOUND_DELIMITER);
    }
    return fontList;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:79,代码来源:SVGTextElementBridge.java

示例7: addLineMetrics

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
public void addLineMetrics(GVTFont font, GVTLineMetrics lm) {
    if (ascent < lm.getAscent())
        ascent = lm.getAscent();
    if (descent < lm.getDescent())
        descent = lm.getDescent();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:7,代码来源:WordInfo.java

示例8: deriveFont

import org.apache.batik.gvt.font.GVTFont; //导入依赖的package包/类
/**
 * Creates a new GVTFont object by replicating this font object and
 * applying a new size to it.
 *
 * @param size The size of the new font.
 *
 * @return The new font object.
 */
public GVTFont deriveFont(float size) {
    return new SVGGVTFont(size, fontFace, glyphUnicodes, glyphNames,
                          glyphLangs, glyphOrientations, glyphForms, ctx,
                          glyphElements, missingGlyphElement,
                          hkernElements, vkernElements, textElement);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:15,代码来源:SVGGVTFont.java


注:本文中的org.apache.batik.gvt.font.GVTFont类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。