os/textandloc/fontservices/textshaperplugin/test/letest/PortableFontInstance.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
 *******************************************************************************
sl@0
     3
 *
sl@0
     4
 *   Copyright (C) 1999-2003, International Business Machines
sl@0
     5
 *   Corporation and others.  All Rights Reserved.
sl@0
     6
 *
sl@0
     7
 *******************************************************************************
sl@0
     8
 *   file name:  PortableFontInstance.h
sl@0
     9
 *
sl@0
    10
 *   created on: 11/12/1999
sl@0
    11
 *   created by: Eric R. Mader
sl@0
    12
 */
sl@0
    13
sl@0
    14
#ifndef __PORTABLEFONTINSTANCE_H
sl@0
    15
#define __PORTABLEFONTINSTANCE_H
sl@0
    16
sl@0
    17
#include <stdio.h>
sl@0
    18
sl@0
    19
#include "layout/LETypes.h"
sl@0
    20
#include "layout/LEFontInstance.h"
sl@0
    21
sl@0
    22
#include "FontTableCache.h"
sl@0
    23
sl@0
    24
#include "sfnt.h"
sl@0
    25
#include "cmaps.h"
sl@0
    26
sl@0
    27
class PortableFontInstance : public LEFontInstance, protected FontTableCache
sl@0
    28
{
sl@0
    29
private:
sl@0
    30
    FILE *fFile;
sl@0
    31
sl@0
    32
    float    fPointSize;
sl@0
    33
    le_int32 fUnitsPerEM;
sl@0
    34
    le_int32 fAscent;
sl@0
    35
    le_int32 fDescent;
sl@0
    36
    le_int32 fLeading;
sl@0
    37
sl@0
    38
    const SFNTDirectory *fDirectory;
sl@0
    39
    le_uint16 fDirPower;
sl@0
    40
    le_uint16 fDirExtra;
sl@0
    41
sl@0
    42
    float fDeviceScaleX;
sl@0
    43
    float fDeviceScaleY;
sl@0
    44
sl@0
    45
    CMAPMapper *fCMAPMapper;
sl@0
    46
sl@0
    47
    const HMTXTable *fHMTXTable;
sl@0
    48
    le_uint16 fNumGlyphs;
sl@0
    49
    le_uint16 fNumLongHorMetrics;
sl@0
    50
sl@0
    51
    static le_int8 highBit(le_int32 value);
sl@0
    52
sl@0
    53
    const DirectoryEntry *findTable(LETag tag) const;
sl@0
    54
    const void *readTable(LETag tag, le_uint32 *length) const;
sl@0
    55
    void deleteTable(const void *table) const;
sl@0
    56
    void getMetrics();
sl@0
    57
sl@0
    58
    CMAPMapper *findUnicodeMapper();
sl@0
    59
sl@0
    60
protected:
sl@0
    61
    const void *readFontTable(LETag tableTag) const;
sl@0
    62
sl@0
    63
public:
sl@0
    64
    PortableFontInstance(char *fileName, float pointSize, LEErrorCode &status);
sl@0
    65
sl@0
    66
    virtual ~PortableFontInstance();
sl@0
    67
sl@0
    68
    virtual const void *getFontTable(LETag tableTag) const;
sl@0
    69
sl@0
    70
    virtual le_int32 getUnitsPerEM() const
sl@0
    71
    {
sl@0
    72
        return fUnitsPerEM;
sl@0
    73
    };
sl@0
    74
sl@0
    75
    virtual le_int32 getAscent() const
sl@0
    76
    {
sl@0
    77
        return fAscent;
sl@0
    78
    }
sl@0
    79
sl@0
    80
    virtual le_int32 getDescent() const
sl@0
    81
    {
sl@0
    82
        return fDescent;
sl@0
    83
    }
sl@0
    84
sl@0
    85
    virtual le_int32 getLeading() const
sl@0
    86
    {
sl@0
    87
        return fLeading;
sl@0
    88
    }
sl@0
    89
sl@0
    90
    virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const
sl@0
    91
    {
sl@0
    92
        return fCMAPMapper->unicodeToGlyph(ch);
sl@0
    93
    }
sl@0
    94
sl@0
    95
    virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
sl@0
    96
sl@0
    97
    virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
sl@0
    98
sl@0
    99
    float getXPixelsPerEm() const
sl@0
   100
    {
sl@0
   101
        return fPointSize;
sl@0
   102
    };
sl@0
   103
sl@0
   104
    float getYPixelsPerEm() const
sl@0
   105
    {
sl@0
   106
        return fPointSize;
sl@0
   107
    };
sl@0
   108
sl@0
   109
    float getScaleFactorX() const
sl@0
   110
    {
sl@0
   111
        return 1.0;
sl@0
   112
    }
sl@0
   113
sl@0
   114
    float getScaleFactorY() const
sl@0
   115
    {
sl@0
   116
        return 1.0;
sl@0
   117
    }
sl@0
   118
sl@0
   119
};
sl@0
   120
sl@0
   121
#endif