• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  *******************************************************************************
4  *
5  *   © 2016 and later: Unicode, Inc. and others.
6  *   License & terms of use: http://www.unicode.org/copyright.html#License
7  *
8  *******************************************************************************
9  *******************************************************************************
10  *
11  *   Copyright (C) 1999-2013, International Business Machines
12  *   Corporation and others.  All Rights Reserved.
13  *
14  *******************************************************************************
15  *   file name:  PortableFontInstance.h
16  *
17  *   created on: 11/12/1999
18  *   created by: Eric R. Mader
19  */
20 
21 #ifndef __PORTABLEFONTINSTANCE_H
22 #define __PORTABLEFONTINSTANCE_H
23 
24 #include <stdio.h>
25 
26 #include "layout/LETypes.h"
27 #include "layout/LEFontInstance.h"
28 
29 #include "FontTableCache.h"
30 
31 #include "sfnt.h"
32 #include "cmaps.h"
33 
34 class PortableFontInstance : public LEFontInstance, protected FontTableCache
35 {
36 private:
37     FILE *fFile;
38 
39     float     fPointSize;
40     le_int32  fUnitsPerEM;
41     le_uint32 fFontChecksum;
42     le_int32  fAscent;
43     le_int32  fDescent;
44     le_int32  fLeading;
45 
46     const SFNTDirectory *fDirectory;
47     le_uint16 fDirPower;
48     le_uint16 fDirExtra;
49 
50     float fDeviceScaleX;
51     float fDeviceScaleY;
52 
53     const NAMETable *fNAMETable;
54     le_uint16 fNameCount;
55     le_uint16 fNameStringOffset;
56 
57     CMAPMapper *fCMAPMapper;
58 
59     const HMTXTable *fHMTXTable;
60     le_uint16 fNumGlyphs;
61     le_uint16 fNumLongHorMetrics;
62 
63     static le_int8 highBit(le_int32 value);
64 
65     const DirectoryEntry *findTable(LETag tag) const;
66     const void *readTable(LETag tag, le_uint32 *length) const;
67     void getMetrics();
68 
69     CMAPMapper *findUnicodeMapper();
70 
71 protected:
readFontTable(LETag tableTag)72     const void *readFontTable(LETag tableTag) const { size_t ignored; return readFontTable(tableTag, ignored); }
73     const void *readFontTable(LETag tableTag, size_t &length) const;
74 
75 public:
76     PortableFontInstance(const char *fileName, float pointSize, LEErrorCode &status);
77 
78     virtual ~PortableFontInstance();
79 
80     virtual const void *getFontTable(LETag tableTag) const;
81     virtual const void *getFontTable(LETag tableTag, size_t &length) const;
82 
83     virtual const char *getNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const;
84 
85     virtual const LEUnicode16 *getUnicodeNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const;
86 
87     virtual void deleteNameString(const char *name) const;
88 
89     virtual void deleteNameString(const LEUnicode16 *name) const;
90 
91     virtual le_int32 getUnitsPerEM() const;
92 
93     virtual le_uint32 getFontChecksum() const;
94 
95     virtual le_uint32 getRawChecksum() const;
96 
97     virtual le_int32 getAscent() const;
98 
99     virtual le_int32 getDescent() const;
100 
101     virtual le_int32 getLeading() const;
102 
103     // We really want to inherit this method from the superclass, but some compilers
104     // issue a warning if we don't implement it...
105     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
106 
107     // We really want to inherit this method from the superclass, but some compilers
108     // issue a warning if we don't implement it...
109     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
110 
111     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
112 
113     virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
114 
115     virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
116 
117     float getXPixelsPerEm() const;
118 
119     float getYPixelsPerEm() const;
120 
121     float getScaleFactorX() const;
122 
123     float getScaleFactorY() const;
124 
125 };
126 
127 #endif
128