mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-1068 Add cursive attachment, change to correct OpenType positioning model.
X-SVN-Rev: 8830
This commit is contained in:
parent
43d3a9bf2a
commit
4bad5d68eb
13 changed files with 388 additions and 60 deletions
81
icu4c/source/layout/CursiveAttachmentSubtables.cpp
Normal file
81
icu4c/source/layout/CursiveAttachmentSubtables.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001, 2002 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEFontInstance.h"
|
||||
#include "OpenTypeTables.h"
|
||||
#include "GlyphPositioningTables.h"
|
||||
#include "CursiveAttachmentSubtables.h"
|
||||
#include "AnchorTables.h"
|
||||
#include "GlyphIterator.h"
|
||||
#include "GlyphPositionAdjustments.h"
|
||||
#include "OpenTypeUtilities.h"
|
||||
#include "LESwaps.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
le_uint32 CursiveAttachmentSubtable::process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const
|
||||
{
|
||||
LEGlyphID glyphID = glyphIterator->getCurrGlyphID();
|
||||
le_int32 coverageIndex = getGlyphCoverage(glyphID);
|
||||
le_uint16 eeCount = SWAPW(entryExitCount);
|
||||
|
||||
if (coverageIndex < 0 || coverageIndex >= eeCount) {
|
||||
glyphIterator->resetCursiveLastExitPoint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
LEPoint entryAnchor, exitAnchor, pixels;
|
||||
|
||||
if (glyphIterator->hasCursiveLastExitPoint()) {
|
||||
Offset entryOffset = SWAPW(entryExitRecords[coverageIndex].entryAnchor);
|
||||
|
||||
const AnchorTable *entryAnchorTable = (const AnchorTable *) ((char *) this + entryOffset);
|
||||
|
||||
entryAnchorTable->getAnchor(glyphID, fontInstance, entryAnchor);
|
||||
glyphIterator->getCursiveLastExitPoint(exitAnchor);
|
||||
|
||||
float anchorDiffX = exitAnchor.fX - entryAnchor.fX;
|
||||
float anchorDiffY = exitAnchor.fY - entryAnchor.fY;
|
||||
float baselineAdjustment = glyphIterator->getCursiveBaselineAdjustment();
|
||||
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
LEPoint secondAdvance;
|
||||
|
||||
fontInstance->getGlyphAdvance(glyphID, pixels);
|
||||
fontInstance->pixelsToUnits(pixels, secondAdvance);
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(0, anchorDiffY + baselineAdjustment, -(anchorDiffX + secondAdvance.fX), 0);
|
||||
} else {
|
||||
LEPoint firstAdvance;
|
||||
|
||||
fontInstance->getGlyphAdvance(glyphIterator->getCursiveLastGlyphID(), pixels);
|
||||
fontInstance->pixelsToUnits(pixels, firstAdvance);
|
||||
|
||||
glyphIterator->adjustCursiveLastGlyphPositionAdjustment(0, 0, anchorDiffX - firstAdvance.fX, 0);
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(0, anchorDiffY + baselineAdjustment, 0, 0);
|
||||
}
|
||||
|
||||
glyphIterator->setCursiveBaselineAdjustment(anchorDiffY + baselineAdjustment);
|
||||
}
|
||||
|
||||
Offset exitOffset = SWAPW(entryExitRecords[coverageIndex].exitAnchor);
|
||||
|
||||
const AnchorTable *exitAnchorTable = (const AnchorTable *) ((char *) this + exitOffset);
|
||||
|
||||
exitAnchorTable->getAnchor(glyphID, fontInstance, exitAnchor);
|
||||
|
||||
if (!glyphIterator->hasCursiveFirstExitPoint()) {
|
||||
glyphIterator->setCursiveFirstExitPoint();
|
||||
}
|
||||
|
||||
glyphIterator->setCursiveLastExitPoint(exitAnchor);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
36
icu4c/source/layout/CursiveAttachmentSubtables.h
Normal file
36
icu4c/source/layout/CursiveAttachmentSubtables.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001, 2002 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CURSIVEATTACHMENTSUBTABLES_H
|
||||
#define __CURSIVEATTACHMENTSUBTABLES_H
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEFontInstance.h"
|
||||
#include "OpenTypeTables.h"
|
||||
#include "GlyphPositioningTables.h"
|
||||
#include "GlyphIterator.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
struct EntryExitRecord
|
||||
{
|
||||
Offset entryAnchor;
|
||||
Offset exitAnchor;
|
||||
};
|
||||
|
||||
struct CursiveAttachmentSubtable : GlyphPositioningSubtable
|
||||
{
|
||||
le_uint16 entryExitCount;
|
||||
EntryExitRecord entryExitRecords[ANY_NUMBER];
|
||||
|
||||
le_uint32 process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ GlyphIterator::GlyphIterator(LEGlyphID *theGlyphs, GlyphPositionAdjustment *theG
|
|||
le_bool rightToLeft, le_uint16 theLookupFlags, LETag theFeatureTag, const LETag *theGlyphTags[],
|
||||
const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader)
|
||||
: direction(1), position(-1), nextLimit(theGlyphCount), prevLimit(-1),
|
||||
cursiveFirstPosition(-1), cursiveLastPosition(-1), cursiveBaselineAdjustment(0),
|
||||
glyphs(theGlyphs), glyphPositionAdjustments(theGlyphPositionAdjustments), lookupFlags(theLookupFlags),
|
||||
featureTag(theFeatureTag), glyphTags(theGlyphTags),
|
||||
glyphClassDefinitionTable(NULL),
|
||||
|
@ -40,10 +41,13 @@ GlyphIterator::GlyphIterator(LEGlyphID *theGlyphs, GlyphPositionAdjustment *theG
|
|||
|
||||
GlyphIterator::GlyphIterator(GlyphIterator &that)
|
||||
{
|
||||
direction = that.direction;
|
||||
position = that.position;
|
||||
nextLimit = that.nextLimit;
|
||||
prevLimit = that.prevLimit;
|
||||
direction = that.direction;
|
||||
position = that.position;
|
||||
nextLimit = that.nextLimit;
|
||||
prevLimit = that.prevLimit;
|
||||
|
||||
cursiveFirstPosition = that.cursiveFirstPosition;
|
||||
cursiveLastPosition = that.cursiveLastPosition;
|
||||
|
||||
glyphs = that.glyphs;
|
||||
glyphPositionAdjustments = that.glyphPositionAdjustments;
|
||||
|
@ -56,10 +60,14 @@ GlyphIterator::GlyphIterator(GlyphIterator &that)
|
|||
|
||||
GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags)
|
||||
{
|
||||
direction = that.direction;
|
||||
position = that.position;
|
||||
nextLimit = that.nextLimit;
|
||||
prevLimit = that.prevLimit;
|
||||
direction = that.direction;
|
||||
position = that.position;
|
||||
nextLimit = that.nextLimit;
|
||||
prevLimit = that.prevLimit;
|
||||
|
||||
|
||||
cursiveFirstPosition = that.cursiveFirstPosition;
|
||||
cursiveLastPosition = that.cursiveLastPosition;
|
||||
|
||||
glyphs = that.glyphs;
|
||||
glyphPositionAdjustments = that.glyphPositionAdjustments;
|
||||
|
@ -93,6 +101,21 @@ le_bool GlyphIterator::ignoresMarks() const
|
|||
return (lookupFlags & lfIgnoreMarks) != 0;
|
||||
}
|
||||
|
||||
le_bool GlyphIterator::baselineIsLogicalEnd() const
|
||||
{
|
||||
return (lookupFlags & lfBaselineIsLogicalEnd) != 0;
|
||||
}
|
||||
|
||||
le_bool GlyphIterator::hasCursiveFirstExitPoint() const
|
||||
{
|
||||
return cursiveFirstPosition >= 0;
|
||||
}
|
||||
|
||||
le_bool GlyphIterator::hasCursiveLastExitPoint() const
|
||||
{
|
||||
return cursiveLastPosition >= 0;
|
||||
}
|
||||
|
||||
LEGlyphID GlyphIterator::getCurrGlyphID() const
|
||||
{
|
||||
if (direction < 0) {
|
||||
|
@ -108,6 +131,33 @@ LEGlyphID GlyphIterator::getCurrGlyphID() const
|
|||
return glyphs[position];
|
||||
}
|
||||
|
||||
LEGlyphID GlyphIterator::getCursiveLastGlyphID() const
|
||||
{
|
||||
if (direction < 0) {
|
||||
if (cursiveLastPosition <= nextLimit || cursiveLastPosition >= prevLimit) {
|
||||
return 0xFFFF;
|
||||
}
|
||||
} else {
|
||||
if (cursiveLastPosition <= prevLimit || cursiveLastPosition >= nextLimit) {
|
||||
return 0xFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
return glyphs[cursiveLastPosition];
|
||||
}
|
||||
|
||||
void GlyphIterator::getCursiveLastExitPoint(LEPoint &exitPoint) const
|
||||
{
|
||||
if (cursiveLastPosition >= 0) {
|
||||
exitPoint = cursiveLastExitPoint;
|
||||
}
|
||||
}
|
||||
|
||||
float GlyphIterator::getCursiveBaselineAdjustment() const
|
||||
{
|
||||
return cursiveBaselineAdjustment;
|
||||
}
|
||||
|
||||
void GlyphIterator::getCurrGlyphPositionAdjustment(GlyphPositionAdjustment &adjustment) const
|
||||
{
|
||||
if (direction < 0)
|
||||
|
@ -125,6 +175,23 @@ void GlyphIterator::getCurrGlyphPositionAdjustment(GlyphPositionAdjustment &adju
|
|||
adjustment = glyphPositionAdjustments[position];
|
||||
}
|
||||
|
||||
void GlyphIterator::getCursiveLastPositionAdjustment(GlyphPositionAdjustment &adjustment) const
|
||||
{
|
||||
if (direction < 0)
|
||||
{
|
||||
if (cursiveLastPosition <= nextLimit || cursiveLastPosition >= prevLimit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (cursiveLastPosition <= prevLimit || cursiveLastPosition >= nextLimit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
adjustment = glyphPositionAdjustments[cursiveLastPosition];
|
||||
}
|
||||
|
||||
void GlyphIterator::setCurrGlyphID(LEGlyphID glyphID)
|
||||
{
|
||||
glyphs[position] = glyphID;
|
||||
|
@ -132,6 +199,10 @@ void GlyphIterator::setCurrGlyphID(LEGlyphID glyphID)
|
|||
|
||||
void GlyphIterator::setCurrStreamPosition(le_int32 newPosition)
|
||||
{
|
||||
cursiveFirstPosition = -1;
|
||||
cursiveLastPosition = -1;
|
||||
cursiveBaselineAdjustment = 0;
|
||||
|
||||
if (direction < 0) {
|
||||
if (newPosition >= prevLimit) {
|
||||
position = prevLimit;
|
||||
|
@ -173,6 +244,21 @@ void GlyphIterator::setCurrGlyphPositionAdjustment(const GlyphPositionAdjustment
|
|||
glyphPositionAdjustments[position] = *adjustment;
|
||||
}
|
||||
|
||||
void GlyphIterator::setCurrGlyphBaseOffset(le_int32 baseOffset)
|
||||
{
|
||||
if (direction < 0) {
|
||||
if (position <= nextLimit || position >= prevLimit) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (position <= prevLimit || position >= nextLimit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
glyphPositionAdjustments[position].setBaseOffset(baseOffset);
|
||||
}
|
||||
|
||||
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
|
||||
float xAdvanceAdjust, float yAdvanceAdjust)
|
||||
{
|
||||
|
@ -192,6 +278,89 @@ void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, fl
|
|||
glyphPositionAdjustments[position].adjustYAdvance(yAdvanceAdjust);
|
||||
}
|
||||
|
||||
void GlyphIterator::setCursiveFirstExitPoint()
|
||||
{
|
||||
if (direction < 0) {
|
||||
if (position <= nextLimit || position >= prevLimit) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (position <= prevLimit || position >= nextLimit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cursiveFirstPosition = position;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GlyphIterator::resetCursiveLastExitPoint()
|
||||
{
|
||||
cursiveLastPosition = -1;
|
||||
}
|
||||
#else
|
||||
void GlyphIterator::resetCursiveLastExitPoint()
|
||||
{
|
||||
if ((lookupFlags & lfBaselineIsLogicalEnd) != 0 && cursiveFirstPosition >= 0 && cursiveLastPosition >= 0) {
|
||||
le_int32 savePosition = position, saveLimit = nextLimit;
|
||||
|
||||
position = cursiveFirstPosition - direction;
|
||||
nextLimit = cursiveLastPosition + direction;
|
||||
|
||||
while (nextInternal()) {
|
||||
glyphPositionAdjustments[position].adjustYPlacement(-cursiveBaselineAdjustment);
|
||||
}
|
||||
|
||||
position = savePosition;
|
||||
nextLimit = saveLimit;
|
||||
}
|
||||
|
||||
cursiveLastPosition = -1;
|
||||
cursiveBaselineAdjustment = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GlyphIterator::setCursiveLastExitPoint(LEPoint &exitPoint)
|
||||
{
|
||||
if (direction < 0) {
|
||||
if (position <= nextLimit || position >= prevLimit) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (position <= prevLimit || position >= nextLimit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cursiveLastPosition = position;
|
||||
cursiveLastExitPoint = exitPoint;
|
||||
|
||||
}
|
||||
|
||||
void GlyphIterator::setCursiveBaselineAdjustment(float adjustment)
|
||||
{
|
||||
cursiveBaselineAdjustment = adjustment;
|
||||
}
|
||||
|
||||
void GlyphIterator::adjustCursiveLastGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
|
||||
float xAdvanceAdjust, float yAdvanceAdjust)
|
||||
{
|
||||
if (direction < 0) {
|
||||
if (cursiveLastPosition <= nextLimit || cursiveLastPosition >= prevLimit) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (cursiveLastPosition <= prevLimit || cursiveLastPosition >= nextLimit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
glyphPositionAdjustments[cursiveLastPosition].adjustXPlacement(xPlacementAdjust);
|
||||
glyphPositionAdjustments[cursiveLastPosition].adjustYPlacement(yPlacementAdjust);
|
||||
glyphPositionAdjustments[cursiveLastPosition].adjustXAdvance(xAdvanceAdjust);
|
||||
glyphPositionAdjustments[cursiveLastPosition].adjustYAdvance(yAdvanceAdjust);
|
||||
}
|
||||
|
||||
le_bool GlyphIterator::filterGlyph(le_uint32 index) const
|
||||
{
|
||||
LEGlyphID glyphID = (LEGlyphID) glyphs[index];
|
||||
|
|
|
@ -35,18 +35,35 @@ public:
|
|||
le_bool isRightToLeft() const;
|
||||
le_bool ignoresMarks() const;
|
||||
|
||||
le_bool baselineIsLogicalEnd() const;
|
||||
le_bool hasCursiveFirstExitPoint() const;
|
||||
le_bool hasCursiveLastExitPoint() const;
|
||||
|
||||
LEGlyphID getCurrGlyphID() const;
|
||||
le_int32 getCurrStreamPosition() const;
|
||||
void getCurrGlyphPositionAdjustment(GlyphPositionAdjustment& adjustment) const;
|
||||
void getCurrGlyphPositionAdjustment(GlyphPositionAdjustment &adjustment) const;
|
||||
|
||||
le_int32 getMarkComponent(le_int32 markPosition) const;
|
||||
|
||||
void getCursiveLastExitPoint(LEPoint &exitPoint) const;
|
||||
LEGlyphID getCursiveLastGlyphID() const;
|
||||
float getCursiveBaselineAdjustment() const;
|
||||
void getCursiveLastPositionAdjustment(GlyphPositionAdjustment &adjustment) const;
|
||||
|
||||
void setCurrGlyphID(LEGlyphID glyphID);
|
||||
void setCurrStreamPosition(le_int32 position);
|
||||
void setCurrGlyphPositionAdjustment(const GlyphPositionAdjustment *adjustment);
|
||||
void setCurrGlyphBaseOffset(le_int32 baseOffset);
|
||||
void adjustCurrGlyphPositionAdjustment(float xPlacmentAdjust, float yPlacementAdjust,
|
||||
float xAdvanceAdjust, float yAdvanceAdjust);
|
||||
|
||||
void setCursiveFirstExitPoint();
|
||||
void resetCursiveLastExitPoint();
|
||||
void setCursiveLastExitPoint(LEPoint &exitPoint);
|
||||
void setCursiveBaselineAdjustment(float adjustment);
|
||||
void adjustCursiveLastGlyphPositionAdjustment(float xPlacmentAdjust, float yPlacementAdjust,
|
||||
float xAdvanceAdjust, float yAdvanceAdjust);
|
||||
|
||||
private:
|
||||
GlyphIterator();
|
||||
le_bool filterGlyph(le_uint32 index) const;
|
||||
|
@ -58,6 +75,10 @@ private:
|
|||
le_int32 position;
|
||||
le_int32 nextLimit;
|
||||
le_int32 prevLimit;
|
||||
le_int32 cursiveFirstPosition;
|
||||
le_int32 cursiveLastPosition;
|
||||
float cursiveBaselineAdjustment;
|
||||
LEPoint cursiveLastExitPoint;
|
||||
LEGlyphID *glyphs;
|
||||
GlyphPositionAdjustment *glyphPositionAdjustments;
|
||||
le_uint16 lookupFlags;
|
||||
|
|
|
@ -18,18 +18,22 @@ class GlyphPositionAdjustment
|
|||
public:
|
||||
|
||||
GlyphPositionAdjustment();
|
||||
GlyphPositionAdjustment(float xPlace, float yPlace, float xAdv, float yAdv);
|
||||
GlyphPositionAdjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
|
||||
~GlyphPositionAdjustment();
|
||||
|
||||
float getXPlacement();
|
||||
float getYPlacement();
|
||||
float getXAdvance();
|
||||
float getYAdvance();
|
||||
float getXPlacement();
|
||||
float getYPlacement();
|
||||
float getXAdvance();
|
||||
float getYAdvance();
|
||||
|
||||
void setXPlacement(float newXPlacement);
|
||||
void setYPlacement(float newYPlacement);
|
||||
void setXAdvance(float newXAdvance);
|
||||
void setYAdvance(float newYAdvance);
|
||||
le_int32 getBaseOffset();
|
||||
|
||||
void setXPlacement(float newXPlacement);
|
||||
void setYPlacement(float newYPlacement);
|
||||
void setXAdvance(float newXAdvance);
|
||||
void setYAdvance(float newYAdvance);
|
||||
|
||||
void setBaseOffset(le_int32 newBaseOffset);
|
||||
|
||||
void adjustXPlacement(float xAdjustment);
|
||||
void adjustYPlacement(float yAdjustment);
|
||||
|
@ -41,16 +45,18 @@ private:
|
|||
float yPlacement;
|
||||
float xAdvance;
|
||||
float yAdvance;
|
||||
|
||||
le_int32 baseOffset;
|
||||
};
|
||||
|
||||
inline GlyphPositionAdjustment::GlyphPositionAdjustment()
|
||||
: xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0)
|
||||
: xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
|
||||
{
|
||||
// nothing else to do!
|
||||
}
|
||||
|
||||
inline GlyphPositionAdjustment::GlyphPositionAdjustment(float xPlace, float yPlace, float xAdv, float yAdv)
|
||||
: xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv)
|
||||
inline GlyphPositionAdjustment::GlyphPositionAdjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
|
||||
: xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
|
||||
{
|
||||
// nothing else to do!
|
||||
}
|
||||
|
@ -80,6 +86,11 @@ inline float GlyphPositionAdjustment::getYAdvance()
|
|||
return yAdvance;
|
||||
}
|
||||
|
||||
inline le_int32 GlyphPositionAdjustment::getBaseOffset()
|
||||
{
|
||||
return baseOffset;
|
||||
}
|
||||
|
||||
inline void GlyphPositionAdjustment::setXPlacement(float newXPlacement)
|
||||
{
|
||||
xPlacement = newXPlacement;
|
||||
|
@ -100,6 +111,11 @@ inline void GlyphPositionAdjustment::setYAdvance(float newYAdvance)
|
|||
yAdvance = newYAdvance;
|
||||
}
|
||||
|
||||
inline void GlyphPositionAdjustment::setBaseOffset(le_int32 newBaseOffset)
|
||||
{
|
||||
baseOffset = newBaseOffset;
|
||||
}
|
||||
|
||||
inline void GlyphPositionAdjustment::adjustXPlacement(float xAdjustment)
|
||||
{
|
||||
xPlacement += xAdjustment;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "GlyphPositioningTables.h"
|
||||
#include "SinglePositioningSubtables.h"
|
||||
#include "PairPositioningSubtables.h"
|
||||
//#include "CursivePositioningSubtables.h"
|
||||
#include "CursiveAttachmentSubtables.h"
|
||||
#include "MarkToBasePosnSubtables.h"
|
||||
#include "MarkToLigaturePosnSubtables.h"
|
||||
#include "MarkToMarkPosnSubtables.h"
|
||||
|
@ -76,15 +76,13 @@ le_uint32 GlyphPositioningLookupProcessor::applySubtable(const LookupSubtable *l
|
|||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
case gpstCursive:
|
||||
{
|
||||
const CursivePositioningSubtable *subtable = (const CursivePositioningSubtable *) lookupSubtable;
|
||||
const CursiveAttachmentSubtable *subtable = (const CursiveAttachmentSubtable *) lookupSubtable;
|
||||
|
||||
delta = subtable->process(glyphIterator, fontInstance);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case gpstMarkToBase:
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @(#)Lookups.h 1.5 00/03/15
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - All Rights Reserved
|
||||
* (C) Copyright IBM Corp. 1998 - 2002 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -15,7 +15,7 @@ U_NAMESPACE_BEGIN
|
|||
|
||||
enum LookupFlags
|
||||
{
|
||||
lfReservedBit = 0x0001,
|
||||
lfBaselineIsLogicalEnd = 0x0001, // The MS spec. calls this flag "RightToLeft" but this name is more accurate
|
||||
lfIgnoreBaseGlyphs = 0x0002,
|
||||
lfIgnoreLigatures = 0x0004,
|
||||
lfIgnoreMarks = 0x0008,
|
||||
|
|
|
@ -69,6 +69,7 @@ ArabicShaping.o \
|
|||
ClassDefinitionTables.o \
|
||||
ContextualSubstSubtables.o \
|
||||
CoverageTables.o \
|
||||
CursiveAttachmentSubtables.o \
|
||||
DeviceTables.o \
|
||||
Features.o \
|
||||
GDEFMarkFilter.o \
|
||||
|
|
|
@ -75,20 +75,17 @@ le_int32 MarkToBasePositioningSubtable::process(GlyphIterator *glyphIterator, co
|
|||
float anchorDiffX = baseAnchor.fX - markAnchor.fX;
|
||||
float anchorDiffY = baseAnchor.fY - markAnchor.fY;
|
||||
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
float adjustX = markAdvance.fX + anchorDiffX;
|
||||
glyphIterator->setCurrGlyphBaseOffset(baseIterator.getCurrStreamPosition());
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, -anchorDiffY, -adjustX, anchorDiffY);
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, anchorDiffY, -markAdvance.fX, -markAdvance.fY);
|
||||
} else {
|
||||
LEPoint baseAdvance;
|
||||
|
||||
fontInstance->getGlyphAdvance(baseGlyph, pixels);
|
||||
fontInstance->pixelsToUnits(pixels, baseAdvance);
|
||||
|
||||
float adjustX = baseAdvance.fX - anchorDiffX;
|
||||
float advAdjustX = adjustX - markAdvance.fX;
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(-adjustX, -anchorDiffY, advAdjustX, anchorDiffY);
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX - baseAdvance.fX, -anchorDiffY - baseAdvance.fY, -markAdvance.fX, -markAdvance.fY);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -86,20 +86,17 @@ le_int32 MarkToLigaturePositioningSubtable::process(GlyphIterator *glyphIterator
|
|||
float anchorDiffX = ligatureAnchor.fX - markAnchor.fX;
|
||||
float anchorDiffY = ligatureAnchor.fY - markAnchor.fY;
|
||||
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
float adjustX = markAdvance.fX + anchorDiffX;
|
||||
glyphIterator->setCurrGlyphBaseOffset(ligatureIterator.getCurrStreamPosition());
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, -anchorDiffY, -adjustX, anchorDiffY);
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, anchorDiffY, -markAdvance.fX, -markAdvance.fY);
|
||||
} else {
|
||||
LEPoint ligatureAdvance;
|
||||
|
||||
fontInstance->getGlyphAdvance(ligatureGlyph, pixels);
|
||||
fontInstance->pixelsToUnits(pixels, ligatureAdvance);
|
||||
|
||||
float adjustX = ligatureAdvance.fX - anchorDiffX;
|
||||
float advAdjustX = adjustX - markAdvance.fX;
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(-adjustX, -anchorDiffY, advAdjustX, anchorDiffY);
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX - ligatureAdvance.fX, -anchorDiffY - ligatureAdvance.fY, -markAdvance.fX, -markAdvance.fY);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -75,20 +75,17 @@ le_int32 MarkToMarkPositioningSubtable::process(GlyphIterator *glyphIterator, co
|
|||
float anchorDiffX = mark2Anchor.fX - markAnchor.fX;
|
||||
float anchorDiffY = mark2Anchor.fY - markAnchor.fY;
|
||||
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
float adjustX = markAdvance.fX + anchorDiffX;
|
||||
glyphIterator->setCurrGlyphBaseOffset(mark2Iterator.getCurrStreamPosition());
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, -anchorDiffY, -adjustX, anchorDiffY);
|
||||
if (glyphIterator->isRightToLeft()) {
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX, anchorDiffY, -markAdvance.fX, -markAdvance.fY);
|
||||
} else {
|
||||
LEPoint mark2Advance;
|
||||
|
||||
fontInstance->getGlyphAdvance(mark2Glyph, pixels);
|
||||
fontInstance->pixelsToUnits(pixels, mark2Advance);
|
||||
|
||||
float adjustX = mark2Advance.fX - anchorDiffX;
|
||||
float advAdjustX = adjustX - markAdvance.fX;
|
||||
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(-adjustX, -anchorDiffY, advAdjustX, anchorDiffY);
|
||||
glyphIterator->adjustCurrGlyphPositionAdjustment(anchorDiffX - mark2Advance.fX, -anchorDiffY - mark2Advance.fY, -markAdvance.fX, -markAdvance.fY);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -181,23 +181,30 @@ void OpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int3
|
|||
le_int32 i;
|
||||
|
||||
for (i = 0; i < glyphCount; i += 1) {
|
||||
float xPlacement = fFontInstance->xUnitsToPoints(adjustments[i].getXPlacement());
|
||||
float xAdvance = fFontInstance->xUnitsToPoints(adjustments[i].getXAdvance());
|
||||
float yPlacement = fFontInstance->yUnitsToPoints(adjustments[i].getYPlacement());
|
||||
float yAdvance = fFontInstance->yUnitsToPoints(adjustments[i].getYAdvance());
|
||||
float xAdvance = adjustments[i].getXAdvance();
|
||||
float yAdvance = adjustments[i].getYAdvance();
|
||||
float xPlacement = 0;
|
||||
float yPlacement = 0;
|
||||
|
||||
xAdjust += xPlacement;
|
||||
yAdjust += yPlacement;
|
||||
#if 0
|
||||
xAdjust += xKerning;
|
||||
yAdjust += yKerning;
|
||||
#endif
|
||||
|
||||
positions[i*2] += xAdjust;
|
||||
positions[i*2+1] += yAdjust;
|
||||
for (le_int32 base = i; base >= 0; base = adjustments[base].getBaseOffset()) {
|
||||
xPlacement += adjustments[base].getXPlacement();
|
||||
yPlacement += adjustments[base].getYPlacement();
|
||||
}
|
||||
|
||||
xAdjust += xAdvance;
|
||||
yAdjust += yAdvance;
|
||||
positions[i*2] += xAdjust + fFontInstance->xUnitsToPoints(xPlacement);
|
||||
positions[i*2+1] -= yAdjust + fFontInstance->yUnitsToPoints(yPlacement);
|
||||
|
||||
xAdjust += fFontInstance->xUnitsToPoints(xAdvance);
|
||||
yAdjust += fFontInstance->yUnitsToPoints(yAdvance);
|
||||
}
|
||||
|
||||
positions[glyphCount*2] += xAdjust;
|
||||
positions[glyphCount*2+1] += yAdjust;
|
||||
positions[glyphCount*2] += xAdjust;
|
||||
positions[glyphCount*2+1] -= yAdjust;
|
||||
|
||||
delete[] adjustments;
|
||||
}
|
||||
|
|
|
@ -186,6 +186,10 @@ SOURCE=.\CoverageTables.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CursiveAttachmentSubtables.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DeviceTables.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -430,6 +434,10 @@ SOURCE=.\CoverageTables.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CursiveAttachmentSubtables.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DefaultCharMapper.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Add table
Reference in a new issue