Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/FontInstanceAdapter.h
38829 views
/*1* Copyright (c) 1999, 2013, 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*/242526/*27* (C) Copyright IBM Corp. 1998-2001 - All Rights Reserved28*29* The original version of this source code and documentation is30* copyrighted and owned by IBM. These materials are provided31* under terms of a License Agreement between IBM and Sun.32* This technology is protected by multiple US and International33* patents. This notice and attribution to IBM may not be removed.34*/3536#ifndef __FONTINSTANCEADAPTER_H37#define __FONTINSTANCEADAPTER_H3839#include "LETypes.h"40#include "LEFontInstance.h"41#include "jni.h"42#include "sunfontids.h"43#include "fontscalerdefs.h"44#include <jni_util.h>4546U_NAMESPACE_BEGIN4748class FontInstanceAdapter : public LEFontInstance {49private:50JNIEnv *env;51jobject font2D;52jobject fontStrike;5354float xppem;55float yppem;5657float xScaleUnitsToPoints;58float yScaleUnitsToPoints;5960float xScalePixelsToUnits;61float yScalePixelsToUnits;6263le_int32 upem;64float xPointSize, yPointSize;65float txMat[4];6667float euclidianDistance(float a, float b);6869/* Table format is the same as defined in the truetype spec.70Pointer can be NULL (e.g. for Type1 fonts). */71TTLayoutTableCache* layoutTables;7273public:74FontInstanceAdapter(JNIEnv *env,75jobject theFont2D, jobject theFontStrike,76float *matrix, le_int32 xRes, le_int32 yRes,77le_int32 theUPEM, TTLayoutTableCache *ltables);7879virtual ~FontInstanceAdapter() { };8081virtual const LEFontInstance *getSubFont(const LEUnicode chars[],82le_int32 *offset, le_int32 limit,83le_int32 script, LEErrorCode &success) const {84return this;85}8687// tables are cached with the native font scaler data88// only supports gsub, gpos, gdef, mort tables at present89virtual const void *getFontTable(LETag tableTag) const;90virtual const void *getFontTable(LETag tableTag, size_t &len) const;9192virtual void *getKernPairs() const {93return layoutTables->kernPairs;94}95virtual void setKernPairs(void *pairs) const {96layoutTables->kernPairs = pairs;97}9899virtual le_bool canDisplay(LEUnicode32 ch) const100{101return (le_bool)env->CallBooleanMethod(font2D,102sunFontIDs.canDisplayMID, ch);103};104105virtual le_int32 getUnitsPerEM() const {106return upem;107};108109virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;110111virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;112113virtual void mapCharsToWideGlyphs(const LEUnicode chars[],114le_int32 offset, le_int32 count, le_bool reverse,115const LECharMapper *mapper, le_uint32 glyphs[]) const;116117virtual le_uint32 mapCharToWideGlyph(LEUnicode32 ch,118const LECharMapper *mapper) const;119120virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;121122virtual void getKerningAdjustment(LEPoint &adjustment) const;123124virtual void getWideGlyphAdvance(le_uint32 glyph, LEPoint &advance) const;125126virtual le_bool getGlyphPoint(LEGlyphID glyph,127le_int32 pointNumber, LEPoint &point) const;128129float getXPixelsPerEm() const130{131return xppem;132};133134float getYPixelsPerEm() const135{136return yppem;137};138139float xUnitsToPoints(float xUnits) const140{141return xUnits * xScaleUnitsToPoints;142};143144float yUnitsToPoints(float yUnits) const145{146return yUnits * yScaleUnitsToPoints;147};148149void unitsToPoints(LEPoint &units, LEPoint &points) const150{151points.fX = xUnitsToPoints(units.fX);152points.fY = yUnitsToPoints(units.fY);153}154155float xPixelsToUnits(float xPixels) const156{157return xPixels * xScalePixelsToUnits;158};159160float yPixelsToUnits(float yPixels) const161{162return yPixels * yScalePixelsToUnits;163};164165void pixelsToUnits(LEPoint &pixels, LEPoint &units) const166{167units.fX = xPixelsToUnits(pixels.fX);168units.fY = yPixelsToUnits(pixels.fY);169};170171virtual float getScaleFactorX() const {172return xScalePixelsToUnits;173};174175virtual float getScaleFactorY() const {176return yScalePixelsToUnits;177};178179void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;180181virtual le_int32 getAscent() const { return 0; }; // not used182virtual le_int32 getDescent() const { return 0; }; // not used183virtual le_int32 getLeading() const { return 0; }; // not used184};185186#endif187188U_NAMESPACE_END189190191