Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/GlyphPositionAdjustments.h
38918 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425/*26*27* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved28*29*/3031#ifndef __GLYPHPOSITIONADJUSTMENTS_H32#define __GLYPHPOSITIONADJUSTMENTS_H3334/**35* \file36* \internal37*/3839#include "LETypes.h"40#include "OpenTypeTables.h"4142U_NAMESPACE_BEGIN4344class LEGlyphStorage;45class LEFontInstance;4647class GlyphPositionAdjustments : public UMemory48{49private:50class Adjustment : public UMemory {51public:5253inline Adjustment();54inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);55inline ~Adjustment();5657inline float getXPlacement() const;58inline float getYPlacement() const;59inline float getXAdvance() const;60inline float getYAdvance() const;6162inline le_int32 getBaseOffset() const;6364inline void setXPlacement(float newXPlacement);65inline void setYPlacement(float newYPlacement);66inline void setXAdvance(float newXAdvance);67inline void setYAdvance(float newYAdvance);6869inline void setBaseOffset(le_int32 newBaseOffset);7071inline void adjustXPlacement(float xAdjustment);72inline void adjustYPlacement(float yAdjustment);73inline void adjustXAdvance(float xAdjustment);74inline void adjustYAdvance(float yAdjustment);7576private:77float xPlacement;78float yPlacement;79float xAdvance;80float yAdvance;8182le_int32 baseOffset;8384// allow copying of this class because all of its fields are simple types85};8687class EntryExitPoint : public UMemory88{89public:90inline EntryExitPoint();91inline ~EntryExitPoint();9293inline le_bool isCursiveGlyph() const;94inline le_bool baselineIsLogicalEnd() const;9596LEPoint *getEntryPoint(LEPoint &entryPoint) const;97LEPoint *getExitPoint(LEPoint &exitPoint) const;9899inline void clearEntryPoint();100inline void clearExitPoint();101inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);102inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);103inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);104105private:106enum EntryExitFlags107{108EEF_HAS_ENTRY_POINT = 0x80000000L,109EEF_HAS_EXIT_POINT = 0x40000000L,110EEF_IS_CURSIVE_GLYPH = 0x20000000L,111EEF_BASELINE_IS_LOGICAL_END = 0x10000000L112};113114le_uint32 fFlags;115LEPoint fEntryPoint;116LEPoint fExitPoint;117};118119le_int32 fGlyphCount;120EntryExitPoint *fEntryExitPoints;121Adjustment *fAdjustments;122123GlyphPositionAdjustments();124125public:126GlyphPositionAdjustments(le_int32 glyphCount);127~GlyphPositionAdjustments();128129inline le_bool hasCursiveGlyphs() const;130inline le_bool isCursiveGlyph(le_int32 index) const;131inline le_bool baselineIsLogicalEnd(le_int32 index) const;132133const LEPoint *getEntryPoint(le_int32 index, LEPoint &entryPoint) const;134const LEPoint *getExitPoint(le_int32 index, LEPoint &exitPoint) const;135136inline float getXPlacement(le_int32 index) const;137inline float getYPlacement(le_int32 index) const;138inline float getXAdvance(le_int32 index) const;139inline float getYAdvance(le_int32 index) const;140141inline le_int32 getBaseOffset(le_int32 index) const;142143inline void setXPlacement(le_int32 index, float newXPlacement);144inline void setYPlacement(le_int32 index, float newYPlacement);145inline void setXAdvance(le_int32 index, float newXAdvance);146inline void setYAdvance(le_int32 index, float newYAdvance);147148inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);149150inline void adjustXPlacement(le_int32 index, float xAdjustment);151inline void adjustYPlacement(le_int32 index, float yAdjustment);152inline void adjustXAdvance(le_int32 index, float xAdjustment);153inline void adjustYAdvance(le_int32 index, float yAdjustment);154155void clearEntryPoint(le_int32 index);156void clearExitPoint(le_int32 index);157void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);158void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);159void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);160161void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);162};163164inline GlyphPositionAdjustments::Adjustment::Adjustment()165: xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)166{167// nothing else to do!168}169170inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)171: xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)172{173// nothing else to do!174}175176inline GlyphPositionAdjustments::Adjustment::~Adjustment()177{178// nothing to do!179}180181inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const182{183return xPlacement;184}185186inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const187{188return yPlacement;189}190191inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const192{193return xAdvance;194}195196inline float GlyphPositionAdjustments::Adjustment::getYAdvance() const197{198return yAdvance;199}200201inline le_int32 GlyphPositionAdjustments::Adjustment::getBaseOffset() const202{203return baseOffset;204}205206inline void GlyphPositionAdjustments::Adjustment::setXPlacement(float newXPlacement)207{208xPlacement = newXPlacement;209}210211inline void GlyphPositionAdjustments::Adjustment::setYPlacement(float newYPlacement)212{213yPlacement = newYPlacement;214}215216inline void GlyphPositionAdjustments::Adjustment::setXAdvance(float newXAdvance)217{218xAdvance = newXAdvance;219}220221inline void GlyphPositionAdjustments::Adjustment::setYAdvance(float newYAdvance)222{223yAdvance = newYAdvance;224}225226inline void GlyphPositionAdjustments::Adjustment::setBaseOffset(le_int32 newBaseOffset)227{228baseOffset = newBaseOffset;229}230231inline void GlyphPositionAdjustments::Adjustment::adjustXPlacement(float xAdjustment)232{233xPlacement += xAdjustment;234}235236inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)237{238yPlacement += yAdjustment;239}240241inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)242{243xAdvance += xAdjustment;244}245246inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)247{248yAdvance += yAdjustment;249}250251inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()252: fFlags(0)253{254fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fExitPoint.fY = 0;255}256257inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()258{259// nothing special to do260}261262inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const263{264return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;265}266267inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const268{269return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;270}271272inline void GlyphPositionAdjustments::EntryExitPoint::clearEntryPoint()273{274fFlags &= ~EEF_HAS_ENTRY_POINT;275}276277inline void GlyphPositionAdjustments::EntryExitPoint::clearExitPoint()278{279fFlags &= ~EEF_HAS_EXIT_POINT;280}281282inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)283{284if (baselineIsLogicalEnd) {285fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);286} else {287fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);288}289290fEntryPoint = newEntryPoint;291}292293inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)294{295if (baselineIsLogicalEnd) {296fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);297} else {298fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);299}300301fExitPoint = newExitPoint;302}303304inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)305{306if (baselineIsLogicalEnd) {307fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);308} else {309fFlags |= EEF_IS_CURSIVE_GLYPH;310}311}312313inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const314{315return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();316}317318inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const319{320return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();321}322323inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const324{325return fAdjustments[index].getXPlacement();326}327328inline float GlyphPositionAdjustments::getYPlacement(le_int32 index) const329{330return fAdjustments[index].getYPlacement();331}332333inline float GlyphPositionAdjustments::getXAdvance(le_int32 index) const334{335return fAdjustments[index].getXAdvance();336}337338inline float GlyphPositionAdjustments::getYAdvance(le_int32 index) const339{340return fAdjustments[index].getYAdvance();341}342343344inline le_int32 GlyphPositionAdjustments::getBaseOffset(le_int32 index) const345{346return fAdjustments[index].getBaseOffset();347}348349inline void GlyphPositionAdjustments::setXPlacement(le_int32 index, float newXPlacement)350{351fAdjustments[index].setXPlacement(newXPlacement);352}353354inline void GlyphPositionAdjustments::setYPlacement(le_int32 index, float newYPlacement)355{356fAdjustments[index].setYPlacement(newYPlacement);357}358359inline void GlyphPositionAdjustments::setXAdvance(le_int32 index, float newXAdvance)360{361fAdjustments[index].setXAdvance(newXAdvance);362}363364inline void GlyphPositionAdjustments::setYAdvance(le_int32 index, float newYAdvance)365{366fAdjustments[index].setYAdvance(newYAdvance);367}368369inline void GlyphPositionAdjustments::setBaseOffset(le_int32 index, le_int32 newBaseOffset)370{371fAdjustments[index].setBaseOffset(newBaseOffset);372}373374inline void GlyphPositionAdjustments::adjustXPlacement(le_int32 index, float xAdjustment)375{376fAdjustments[index].adjustXPlacement(xAdjustment);377}378379inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)380{381fAdjustments[index].adjustYPlacement(yAdjustment);382}383384inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)385{386fAdjustments[index].adjustXAdvance(xAdjustment);387}388389inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)390{391fAdjustments[index].adjustYAdvance(yAdjustment);392}393394inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const395{396return fEntryExitPoints != NULL;397}398399U_NAMESPACE_END400#endif401402403