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