Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/font/DelegateStrike.java
32287 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.font;2627import java.awt.geom.GeneralPath;28import java.awt.geom.Point2D;29import java.awt.Rectangle;30import java.awt.geom.Rectangle2D;3132/* Returned instead of a NativeStrike.33* It can intercept any request it wants, but mostly34* passes them on to its delegate strike. It is important that35* it override all the inherited FontStrike methods to delegate them36* appropriately.37*/3839class DelegateStrike extends NativeStrike {4041private FontStrike delegateStrike;4243DelegateStrike(NativeFont nativeFont, FontStrikeDesc desc,44FontStrike delegate) {45super(nativeFont, desc);46this.delegateStrike = delegate;47}4849/* We want the native font to be responsible for reporting the50* font metrics, even if it often delegates to another font.51* The code here isn't yet implementing exactly that. If the glyph52* transform was something native couldn't handle, there's no native53* context from which to obtain metrics. Need to revise this to obtain54* the metrics and transform them. But currently in such a case it55* gets the metrics from a different font - its glyph delegate font.56*/57StrikeMetrics getFontMetrics() {58if (strikeMetrics == null) {59if (pScalerContext != 0) {60strikeMetrics = super.getFontMetrics();61}62if (strikeMetrics == null) {63strikeMetrics = delegateStrike.getFontMetrics();64}65}66return strikeMetrics;67}6869void getGlyphImagePtrs(int[] glyphCodes, long[] images,int len) {70delegateStrike.getGlyphImagePtrs(glyphCodes, images, len);71}7273long getGlyphImagePtr(int glyphCode) {74return delegateStrike.getGlyphImagePtr(glyphCode);75}7677void getGlyphImageBounds(int glyphCode,78Point2D.Float pt, Rectangle result) {79delegateStrike.getGlyphImageBounds(glyphCode, pt, result);80}8182Point2D.Float getGlyphMetrics(int glyphCode) {83return delegateStrike.getGlyphMetrics(glyphCode);84}8586float getGlyphAdvance(int glyphCode) {87return delegateStrike.getGlyphAdvance(glyphCode);88}8990Point2D.Float getCharMetrics(char ch) {91return delegateStrike.getCharMetrics(ch);92}9394float getCodePointAdvance(int cp) {95if (cp < 0 || cp >= 0x10000) {96cp = 0xffff;97}98return delegateStrike.getGlyphAdvance(cp);99}100101Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {102return delegateStrike.getGlyphOutlineBounds(glyphCode);103}104105GeneralPath getGlyphOutline(int glyphCode, float x, float y) {106return delegateStrike.getGlyphOutline(glyphCode, x, y);107}108109GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {110return delegateStrike.getGlyphVectorOutline(glyphs, x, y);111}112113}114115116