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