/* * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.font; import java.awt.Font; import java.awt.Rectangle; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /* * performance: * it seems expensive that when using a composite font for * every char you have to find which "slot" can display it. * Just the fact that you need to check at all .. * A composite glyph code ducks this by encoding the slot into the * glyph code, but you still need to get from char to glyph code. */ public final class CompositeStrike extends FontStrike { static final int SLOTMASK = 0xffffff; private CompositeFont compFont; private PhysicalStrike[] strikes; int numGlyphs = 0; CompositeStrike(CompositeFont font2D, FontStrikeDesc desc) { this.compFont = font2D; this.desc = desc; this.disposer = new FontStrikeDisposer(compFont, desc); if (desc.style != compFont.style) { algoStyle = true; if ((desc.style & Font.BOLD) == Font.BOLD && ((compFont.style & Font.BOLD) == 0)) { boldness = 1.33f; } if ((desc.style & Font.ITALIC) == Font.ITALIC && (compFont.style & Font.ITALIC) == 0) { italic = 0.7f; } } strikes = new PhysicalStrike[compFont.numSlots]; } /* do I need this (see Strike::compositeStrikeForGlyph) */ PhysicalStrike getStrikeForGlyph(int glyphCode) { return getStrikeForSlot(glyphCode >>> 24); } PhysicalStrike getStrikeForSlot(int slot) { PhysicalStrike strike = strikes[slot]; if (strike == null) { strike = (PhysicalStrike)(compFont.getSlotFont(slot).getStrike(desc)); strikes[slot] = strike; } return strike; } public int getNumGlyphs() { return compFont.getNumGlyphs(); } StrikeMetrics getFontMetrics() { if (strikeMetrics == null) { StrikeMetrics compMetrics = new StrikeMetrics(); for (int s=0; s>> 24; while (glyphIndex < glyphs.length && (glyphs[glyphIndex+1] >>> 24) == slot) { glyphIndex++; } int tmpLen = glyphIndex-start+1; tmpGlyphs = new int[tmpLen]; for (int i=0;i