os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphPositionAdjustments.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphPositionAdjustments.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,362 @@
     1.4 +/*
     1.5 + *
     1.6 + * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
     1.7 + *
     1.8 + */
     1.9 +
    1.10 +#ifndef __GLYPHPOSITIONADJUSTMENTS_H
    1.11 +#define __GLYPHPOSITIONADJUSTMENTS_H
    1.12 +
    1.13 +/**
    1.14 + * \file
    1.15 + * \internal
    1.16 + */
    1.17 +
    1.18 +#include "LETypes.h"
    1.19 +#include "OpenTypeTables.h"
    1.20 +
    1.21 +U_NAMESPACE_BEGIN
    1.22 +
    1.23 +class LEGlyphStorage;
    1.24 +class LEFontInstance;
    1.25 +
    1.26 +class GlyphPositionAdjustments : public UMemory
    1.27 +{
    1.28 +private:
    1.29 +    class Adjustment : public UMemory {
    1.30 +    public:
    1.31 +
    1.32 +        inline Adjustment();
    1.33 +        inline Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff = -1);
    1.34 +        inline ~Adjustment();
    1.35 +
    1.36 +        inline float    getXPlacement() const;
    1.37 +        inline float    getYPlacement() const;
    1.38 +        inline float    getXAdvance() const;
    1.39 +        inline float    getYAdvance() const;
    1.40 +
    1.41 +        inline le_int32 getBaseOffset() const;
    1.42 +
    1.43 +        inline void     setXPlacement(float newXPlacement);
    1.44 +        inline void     setYPlacement(float newYPlacement);
    1.45 +        inline void     setXAdvance(float newXAdvance);
    1.46 +        inline void     setYAdvance(float newYAdvance);
    1.47 +
    1.48 +        inline void     setBaseOffset(le_int32 newBaseOffset);
    1.49 +
    1.50 +        inline void    adjustXPlacement(float xAdjustment);
    1.51 +        inline void    adjustYPlacement(float yAdjustment);
    1.52 +        inline void    adjustXAdvance(float xAdjustment);
    1.53 +        inline void    adjustYAdvance(float yAdjustment);
    1.54 +
    1.55 +    private:
    1.56 +        float xPlacement;
    1.57 +        float yPlacement;
    1.58 +        float xAdvance;
    1.59 +        float yAdvance;
    1.60 +
    1.61 +        le_int32 baseOffset;
    1.62 +
    1.63 +        // allow copying of this class because all of its fields are simple types
    1.64 +    };
    1.65 +
    1.66 +    class EntryExitPoint : public UMemory
    1.67 +    {
    1.68 +    public:
    1.69 +        inline EntryExitPoint();
    1.70 +        inline ~EntryExitPoint();
    1.71 +
    1.72 +        inline le_bool isCursiveGlyph() const;
    1.73 +        inline le_bool baselineIsLogicalEnd() const;
    1.74 +
    1.75 +        LEPoint *getEntryPoint(LEPoint &entryPoint) const;
    1.76 +        LEPoint *getExitPoint(LEPoint &exitPoint) const;
    1.77 +
    1.78 +        inline void setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
    1.79 +        inline void setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
    1.80 +        inline void setCursiveGlyph(le_bool baselineIsLogicalEnd);
    1.81 +
    1.82 +    private:
    1.83 +        enum EntryExitFlags
    1.84 +        {
    1.85 +            EEF_HAS_ENTRY_POINT         = 0x80000000L,
    1.86 +            EEF_HAS_EXIT_POINT          = 0x40000000L,
    1.87 +            EEF_IS_CURSIVE_GLYPH        = 0x20000000L,
    1.88 +            EEF_BASELINE_IS_LOGICAL_END = 0x10000000L
    1.89 +        };
    1.90 +
    1.91 +        le_uint32 fFlags;
    1.92 +        LEPoint fEntryPoint;
    1.93 +        LEPoint fExitPoint;
    1.94 +    };
    1.95 +
    1.96 +    le_int32 fGlyphCount;
    1.97 +    EntryExitPoint *fEntryExitPoints;
    1.98 +    Adjustment *fAdjustments;
    1.99 +
   1.100 +    GlyphPositionAdjustments();
   1.101 +
   1.102 +public:
   1.103 +    GlyphPositionAdjustments(le_int32 glyphCount);
   1.104 +    ~GlyphPositionAdjustments();
   1.105 +
   1.106 +    inline le_bool hasCursiveGlyphs() const;
   1.107 +    inline le_bool isCursiveGlyph(le_int32 index) const;
   1.108 +    inline le_bool baselineIsLogicalEnd(le_int32 index) const;
   1.109 +
   1.110 +    const LEPoint *getEntryPoint(le_int32 index, LEPoint &entryPoint) const;
   1.111 +    const LEPoint *getExitPoint(le_int32 index, LEPoint &exitPoint) const;
   1.112 +
   1.113 +    inline float getXPlacement(le_int32 index) const;
   1.114 +    inline float getYPlacement(le_int32 index) const;
   1.115 +    inline float getXAdvance(le_int32 index) const;
   1.116 +    inline float getYAdvance(le_int32 index) const;
   1.117 +
   1.118 +    inline le_int32 getBaseOffset(le_int32 index) const;
   1.119 +
   1.120 +    inline void setXPlacement(le_int32 index, float newXPlacement);
   1.121 +    inline void setYPlacement(le_int32 index, float newYPlacement);
   1.122 +    inline void setXAdvance(le_int32 index, float newXAdvance);
   1.123 +    inline void setYAdvance(le_int32 index, float newYAdvance);
   1.124 +
   1.125 +    inline void setBaseOffset(le_int32 index, le_int32 newBaseOffset);
   1.126 +
   1.127 +    inline void adjustXPlacement(le_int32 index, float xAdjustment);
   1.128 +    inline void adjustYPlacement(le_int32 index, float yAdjustment);
   1.129 +    inline void adjustXAdvance(le_int32 index, float xAdjustment);
   1.130 +    inline void adjustYAdvance(le_int32 index, float yAdjustment);
   1.131 +   
   1.132 +    void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
   1.133 +    void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
   1.134 +    void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
   1.135 +
   1.136 +    void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
   1.137 +};
   1.138 +
   1.139 +inline GlyphPositionAdjustments::Adjustment::Adjustment()
   1.140 +  : xPlacement(0), yPlacement(0), xAdvance(0), yAdvance(0), baseOffset(-1)
   1.141 +{
   1.142 +    // nothing else to do!
   1.143 +}
   1.144 +
   1.145 +inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
   1.146 +  : xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
   1.147 +{
   1.148 +    // nothing else to do!
   1.149 +}
   1.150 +
   1.151 +inline GlyphPositionAdjustments::Adjustment::~Adjustment()
   1.152 +{
   1.153 +    // nothing to do!
   1.154 +}
   1.155 +
   1.156 +inline float GlyphPositionAdjustments::Adjustment::getXPlacement() const
   1.157 +{
   1.158 +    return xPlacement;
   1.159 +}
   1.160 +
   1.161 +inline float GlyphPositionAdjustments::Adjustment::getYPlacement() const
   1.162 +{
   1.163 +    return yPlacement;
   1.164 +}
   1.165 +
   1.166 +inline float GlyphPositionAdjustments::Adjustment::getXAdvance() const
   1.167 +{
   1.168 +    return xAdvance;
   1.169 +}
   1.170 +
   1.171 +inline float GlyphPositionAdjustments::Adjustment::getYAdvance() const
   1.172 +{
   1.173 +    return yAdvance;
   1.174 +}
   1.175 +
   1.176 +inline le_int32 GlyphPositionAdjustments::Adjustment::getBaseOffset() const
   1.177 +{
   1.178 +    return baseOffset;
   1.179 +}
   1.180 +
   1.181 +inline void GlyphPositionAdjustments::Adjustment::setXPlacement(float newXPlacement)
   1.182 +{
   1.183 +    xPlacement = newXPlacement;
   1.184 +}
   1.185 +
   1.186 +inline void GlyphPositionAdjustments::Adjustment::setYPlacement(float newYPlacement)
   1.187 +{
   1.188 +    yPlacement = newYPlacement;
   1.189 +}
   1.190 +
   1.191 +inline void GlyphPositionAdjustments::Adjustment::setXAdvance(float newXAdvance)
   1.192 +{
   1.193 +    xAdvance = newXAdvance;
   1.194 +}
   1.195 +
   1.196 +inline void GlyphPositionAdjustments::Adjustment::setYAdvance(float newYAdvance)
   1.197 +{
   1.198 +    yAdvance = newYAdvance;
   1.199 +}
   1.200 +
   1.201 +inline void GlyphPositionAdjustments::Adjustment::setBaseOffset(le_int32 newBaseOffset)
   1.202 +{
   1.203 +    baseOffset = newBaseOffset;
   1.204 +}
   1.205 +
   1.206 +inline void GlyphPositionAdjustments::Adjustment::adjustXPlacement(float xAdjustment)
   1.207 +{
   1.208 +    xPlacement += xAdjustment;
   1.209 +}
   1.210 +
   1.211 +inline void GlyphPositionAdjustments::Adjustment::adjustYPlacement(float yAdjustment)
   1.212 +{
   1.213 +    yPlacement += yAdjustment;
   1.214 +}
   1.215 +
   1.216 +inline void GlyphPositionAdjustments::Adjustment::adjustXAdvance(float xAdjustment)
   1.217 +{
   1.218 +    xAdvance += xAdjustment;
   1.219 +}
   1.220 +
   1.221 +inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustment)
   1.222 +{
   1.223 +    yAdvance += yAdjustment;
   1.224 +}
   1.225 +
   1.226 +inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
   1.227 +    : fFlags(0)
   1.228 +{
   1.229 +    fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fEntryPoint.fY = 0;
   1.230 +}
   1.231 +
   1.232 +inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
   1.233 +{
   1.234 +    // nothing special to do
   1.235 +}
   1.236 +
   1.237 +inline le_bool GlyphPositionAdjustments::EntryExitPoint::isCursiveGlyph() const
   1.238 +{
   1.239 +    return (fFlags & EEF_IS_CURSIVE_GLYPH) != 0;
   1.240 +}
   1.241 +
   1.242 +inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd() const
   1.243 +{
   1.244 +    return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
   1.245 +}
   1.246 +
   1.247 +inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
   1.248 +{
   1.249 +    if (baselineIsLogicalEnd) {
   1.250 +        fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
   1.251 +    } else {
   1.252 +        fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
   1.253 +    }
   1.254 +
   1.255 +    fEntryPoint = newEntryPoint;
   1.256 +}
   1.257 +
   1.258 +inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
   1.259 +{
   1.260 +    if (baselineIsLogicalEnd) {
   1.261 +        fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
   1.262 +    } else {
   1.263 +        fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
   1.264 +    }
   1.265 +
   1.266 +    fExitPoint  = newExitPoint;
   1.267 +}
   1.268 +
   1.269 +inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
   1.270 +{
   1.271 +    if (baselineIsLogicalEnd) {
   1.272 +        fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
   1.273 +    } else {
   1.274 +        fFlags |= EEF_IS_CURSIVE_GLYPH;
   1.275 +    }
   1.276 +}
   1.277 +
   1.278 +inline le_bool GlyphPositionAdjustments::isCursiveGlyph(le_int32 index) const
   1.279 +{
   1.280 +    return fEntryExitPoints != NULL && fEntryExitPoints[index].isCursiveGlyph();
   1.281 +}
   1.282 +
   1.283 +inline le_bool GlyphPositionAdjustments::baselineIsLogicalEnd(le_int32 index) const
   1.284 +{
   1.285 +    return fEntryExitPoints != NULL && fEntryExitPoints[index].baselineIsLogicalEnd();
   1.286 +}
   1.287 +
   1.288 +inline float GlyphPositionAdjustments::getXPlacement(le_int32 index) const
   1.289 +{
   1.290 +    return fAdjustments[index].getXPlacement();
   1.291 +}
   1.292 +
   1.293 +inline float GlyphPositionAdjustments::getYPlacement(le_int32 index) const
   1.294 +{
   1.295 +    return fAdjustments[index].getYPlacement();
   1.296 +}
   1.297 +
   1.298 +inline float GlyphPositionAdjustments::getXAdvance(le_int32 index) const
   1.299 +{
   1.300 +    return fAdjustments[index].getXAdvance();
   1.301 +}
   1.302 +
   1.303 +inline float GlyphPositionAdjustments::getYAdvance(le_int32 index) const
   1.304 +{
   1.305 +    return fAdjustments[index].getYAdvance();
   1.306 +}
   1.307 +
   1.308 +
   1.309 +inline le_int32 GlyphPositionAdjustments::getBaseOffset(le_int32 index) const
   1.310 +{
   1.311 +    return fAdjustments[index].getBaseOffset();
   1.312 +}
   1.313 +
   1.314 +inline void GlyphPositionAdjustments::setXPlacement(le_int32 index, float newXPlacement)
   1.315 +{
   1.316 +    fAdjustments[index].setXPlacement(newXPlacement);
   1.317 +}
   1.318 +
   1.319 +inline void GlyphPositionAdjustments::setYPlacement(le_int32 index, float newYPlacement)
   1.320 +{
   1.321 +    fAdjustments[index].setYPlacement(newYPlacement);
   1.322 +}
   1.323 +
   1.324 +inline void GlyphPositionAdjustments::setXAdvance(le_int32 index, float newXAdvance)
   1.325 +{
   1.326 +    fAdjustments[index].setXAdvance(newXAdvance);
   1.327 +}
   1.328 +
   1.329 +inline void GlyphPositionAdjustments::setYAdvance(le_int32 index, float newYAdvance)
   1.330 +{
   1.331 +    fAdjustments[index].setYAdvance(newYAdvance);
   1.332 +}
   1.333 +
   1.334 +inline void GlyphPositionAdjustments::setBaseOffset(le_int32 index, le_int32 newBaseOffset)
   1.335 +{
   1.336 +    fAdjustments[index].setBaseOffset(newBaseOffset);
   1.337 +}
   1.338 +
   1.339 +inline void GlyphPositionAdjustments::adjustXPlacement(le_int32 index, float xAdjustment)
   1.340 +{
   1.341 +    fAdjustments[index].adjustXPlacement(xAdjustment);
   1.342 +}
   1.343 +
   1.344 +inline void GlyphPositionAdjustments::adjustYPlacement(le_int32 index, float yAdjustment)
   1.345 +{
   1.346 +    fAdjustments[index].adjustYPlacement(yAdjustment);
   1.347 +}
   1.348 +
   1.349 +inline void GlyphPositionAdjustments::adjustXAdvance(le_int32 index, float xAdjustment)
   1.350 +{
   1.351 +    fAdjustments[index].adjustXAdvance(xAdjustment);
   1.352 +}
   1.353 +
   1.354 +inline void GlyphPositionAdjustments::adjustYAdvance(le_int32 index, float yAdjustment)
   1.355 +{
   1.356 +    fAdjustments[index].adjustYAdvance(yAdjustment);
   1.357 +}
   1.358 +
   1.359 +inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
   1.360 +{
   1.361 +    return fEntryExitPoints != NULL;
   1.362 +}
   1.363 +
   1.364 +U_NAMESPACE_END
   1.365 +#endif