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