os/textandloc/fontservices/textshaperplugin/test/letest/PortableFontInstance.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/test/letest/PortableFontInstance.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,121 @@
     1.4 +/*
     1.5 + *******************************************************************************
     1.6 + *
     1.7 + *   Copyright (C) 1999-2003, International Business Machines
     1.8 + *   Corporation and others.  All Rights Reserved.
     1.9 + *
    1.10 + *******************************************************************************
    1.11 + *   file name:  PortableFontInstance.h
    1.12 + *
    1.13 + *   created on: 11/12/1999
    1.14 + *   created by: Eric R. Mader
    1.15 + */
    1.16 +
    1.17 +#ifndef __PORTABLEFONTINSTANCE_H
    1.18 +#define __PORTABLEFONTINSTANCE_H
    1.19 +
    1.20 +#include <stdio.h>
    1.21 +
    1.22 +#include "layout/LETypes.h"
    1.23 +#include "layout/LEFontInstance.h"
    1.24 +
    1.25 +#include "FontTableCache.h"
    1.26 +
    1.27 +#include "sfnt.h"
    1.28 +#include "cmaps.h"
    1.29 +
    1.30 +class PortableFontInstance : public LEFontInstance, protected FontTableCache
    1.31 +{
    1.32 +private:
    1.33 +    FILE *fFile;
    1.34 +
    1.35 +    float    fPointSize;
    1.36 +    le_int32 fUnitsPerEM;
    1.37 +    le_int32 fAscent;
    1.38 +    le_int32 fDescent;
    1.39 +    le_int32 fLeading;
    1.40 +
    1.41 +    const SFNTDirectory *fDirectory;
    1.42 +    le_uint16 fDirPower;
    1.43 +    le_uint16 fDirExtra;
    1.44 +
    1.45 +    float fDeviceScaleX;
    1.46 +    float fDeviceScaleY;
    1.47 +
    1.48 +    CMAPMapper *fCMAPMapper;
    1.49 +
    1.50 +    const HMTXTable *fHMTXTable;
    1.51 +    le_uint16 fNumGlyphs;
    1.52 +    le_uint16 fNumLongHorMetrics;
    1.53 +
    1.54 +    static le_int8 highBit(le_int32 value);
    1.55 +
    1.56 +    const DirectoryEntry *findTable(LETag tag) const;
    1.57 +    const void *readTable(LETag tag, le_uint32 *length) const;
    1.58 +    void deleteTable(const void *table) const;
    1.59 +    void getMetrics();
    1.60 +
    1.61 +    CMAPMapper *findUnicodeMapper();
    1.62 +
    1.63 +protected:
    1.64 +    const void *readFontTable(LETag tableTag) const;
    1.65 +
    1.66 +public:
    1.67 +    PortableFontInstance(char *fileName, float pointSize, LEErrorCode &status);
    1.68 +
    1.69 +    virtual ~PortableFontInstance();
    1.70 +
    1.71 +    virtual const void *getFontTable(LETag tableTag) const;
    1.72 +
    1.73 +    virtual le_int32 getUnitsPerEM() const
    1.74 +    {
    1.75 +        return fUnitsPerEM;
    1.76 +    };
    1.77 +
    1.78 +    virtual le_int32 getAscent() const
    1.79 +    {
    1.80 +        return fAscent;
    1.81 +    }
    1.82 +
    1.83 +    virtual le_int32 getDescent() const
    1.84 +    {
    1.85 +        return fDescent;
    1.86 +    }
    1.87 +
    1.88 +    virtual le_int32 getLeading() const
    1.89 +    {
    1.90 +        return fLeading;
    1.91 +    }
    1.92 +
    1.93 +    virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const
    1.94 +    {
    1.95 +        return fCMAPMapper->unicodeToGlyph(ch);
    1.96 +    }
    1.97 +
    1.98 +    virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
    1.99 +
   1.100 +    virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
   1.101 +
   1.102 +    float getXPixelsPerEm() const
   1.103 +    {
   1.104 +        return fPointSize;
   1.105 +    };
   1.106 +
   1.107 +    float getYPixelsPerEm() const
   1.108 +    {
   1.109 +        return fPointSize;
   1.110 +    };
   1.111 +
   1.112 +    float getScaleFactorX() const
   1.113 +    {
   1.114 +        return 1.0;
   1.115 +    }
   1.116 +
   1.117 +    float getScaleFactorY() const
   1.118 +    {
   1.119 +        return 1.0;
   1.120 +    }
   1.121 +
   1.122 +};
   1.123 +
   1.124 +#endif