|
|
|||
File indexing completed on 2025-12-11 10:26:09
0001 //======================================================================== 0002 // 0003 // FoFiTrueType.h 0004 // 0005 // Copyright 1999-2003 Glyph & Cog, LLC 0006 // 0007 //======================================================================== 0008 0009 //======================================================================== 0010 // 0011 // Modified under the Poppler project - http://poppler.freedesktop.org 0012 // 0013 // All changes made under the Poppler project to this file are licensed 0014 // under GPL version 2 or later 0015 // 0016 // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> 0017 // Copyright (C) 2007 Koji Otani <sho@bbr.jp> 0018 // Copyright (C) 2011, 2012, 2018-2020 Albert Astals Cid <aacid@kde.org> 0019 // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> 0020 // Copyright (C) 2016 William Bader <williambader@hotmail.com> 0021 // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> 0022 // Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de> 0023 // 0024 // To see a description of the changes please see the Changelog file that 0025 // came with your tarball or type make ChangeLog if you are building from git 0026 // 0027 //======================================================================== 0028 0029 #ifndef FOFITRUETYPE_H 0030 #define FOFITRUETYPE_H 0031 0032 #include <cstddef> 0033 #include <memory> 0034 #include <unordered_map> 0035 #include <string> 0036 #include "FoFiBase.h" 0037 #include "poppler_private_export.h" 0038 0039 class GooString; 0040 struct TrueTypeTable; 0041 struct TrueTypeCmap; 0042 0043 //------------------------------------------------------------------------ 0044 // FoFiTrueType 0045 //------------------------------------------------------------------------ 0046 0047 class POPPLER_PRIVATE_EXPORT FoFiTrueType : public FoFiBase 0048 { 0049 public: 0050 // Create a FoFiTrueType object from a memory buffer. 0051 static std::unique_ptr<FoFiTrueType> make(const unsigned char *fileA, int lenA, int faceIndexA = 0); 0052 0053 // Create a FoFiTrueType object from a file on disk. 0054 static std::unique_ptr<FoFiTrueType> load(const char *fileName, int faceIndexA = 0); 0055 0056 ~FoFiTrueType() override; 0057 0058 // Returns true if this an OpenType font containing CFF data, false 0059 // if it's a TrueType font (or OpenType font with TrueType data). 0060 bool isOpenTypeCFF() const { return openTypeCFF; } 0061 0062 // Return the number of cmaps defined by this font. 0063 int getNumCmaps() const; 0064 0065 // Return the platform ID of the <i>th cmap. 0066 int getCmapPlatform(int i) const; 0067 0068 // Return the encoding ID of the <i>th cmap. 0069 int getCmapEncoding(int i) const; 0070 0071 // Return the index of the cmap for <platform>, <encoding>. Returns 0072 // -1 if there is no corresponding cmap. 0073 int findCmap(int platform, int encoding) const; 0074 0075 // Return the GID corresponding to <c> according to the <i>th cmap. 0076 int mapCodeToGID(int i, unsigned int c) const; 0077 0078 // map gid to vertical glyph gid if exist. 0079 // if not exist return original gid 0080 unsigned int mapToVertGID(unsigned int orgGID); 0081 0082 // Returns the GID corresponding to <name> according to the post 0083 // table. Returns 0 if there is no mapping for <name> or if the 0084 // font does not have a post table. 0085 int mapNameToGID(const char *name) const; 0086 0087 // Return the mapping from CIDs to GIDs, and return the number of 0088 // CIDs in *<nCIDs>. This is only useful for CID fonts. (Only 0089 // useful for OpenType CFF fonts.) 0090 int *getCIDToGIDMap(int *nCIDs) const; 0091 0092 // Returns the least restrictive embedding licensing right (as 0093 // defined by the TrueType spec): 0094 // * 4: OS/2 table is missing or invalid 0095 // * 3: installable embedding 0096 // * 2: editable embedding 0097 // * 1: preview & print embedding 0098 // * 0: restricted license embedding 0099 int getEmbeddingRights() const; 0100 0101 // Return the font matrix as an array of six numbers. (Only useful 0102 // for OpenType CFF fonts.) 0103 void getFontMatrix(double *mat) const; 0104 0105 // Convert to a Type 42 font, suitable for embedding in a PostScript 0106 // file. <psName> will be used as the PostScript font name (so we 0107 // don't need to depend on the 'name' table in the font). The 0108 // <encoding> array specifies the mapping from char codes to names. 0109 // If <encoding> is NULL, the encoding is unknown or undefined. The 0110 // <codeToGID> array specifies the mapping from char codes to GIDs. 0111 // (Not useful for OpenType CFF fonts.) 0112 void convertToType42(const char *psName, char **encoding, int *codeToGID, FoFiOutputFunc outputFunc, void *outputStream) const; 0113 0114 // Convert to a Type 1 font, suitable for embedding in a PostScript 0115 // file. This is only useful with 8-bit fonts. If <newEncoding> is 0116 // not NULL, it will be used in place of the encoding in the Type 1C 0117 // font. If <ascii> is true the eexec section will be hex-encoded, 0118 // otherwise it will be left as binary data. If <psName> is 0119 // non-NULL, it will be used as the PostScript font name. (Only 0120 // useful for OpenType CFF fonts.) 0121 void convertToType1(const char *psName, const char **newEncoding, bool ascii, FoFiOutputFunc outputFunc, void *outputStream) const; 0122 0123 // Convert to a Type 2 CIDFont, suitable for embedding in a 0124 // PostScript file. <psName> will be used as the PostScript font 0125 // name (so we don't need to depend on the 'name' table in the 0126 // font). The <cidMap> array maps CIDs to GIDs; it has <nCIDs> 0127 // entries. (Not useful for OpenType CFF fonts.) 0128 void convertToCIDType2(const char *psName, const int *cidMap, int nCIDs, bool needVerticalMetrics, FoFiOutputFunc outputFunc, void *outputStream) const; 0129 0130 // Convert to a Type 0 CIDFont, suitable for embedding in a 0131 // PostScript file. <psName> will be used as the PostScript font 0132 // name. (Only useful for OpenType CFF fonts.) 0133 void convertToCIDType0(const char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream) const; 0134 0135 // Convert to a Type 0 (but non-CID) composite font, suitable for 0136 // embedding in a PostScript file. <psName> will be used as the 0137 // PostScript font name (so we don't need to depend on the 'name' 0138 // table in the font). The <cidMap> array maps CIDs to GIDs; it has 0139 // <nCIDs> entries. (Not useful for OpenType CFF fonts.) 0140 void convertToType0(const char *psName, int *cidMap, int nCIDs, bool needVerticalMetrics, int *maxValidGlyph, FoFiOutputFunc outputFunc, void *outputStream) const; 0141 0142 // Convert to a Type 0 (but non-CID) composite font, suitable for 0143 // embedding in a PostScript file. <psName> will be used as the 0144 // PostScript font name. (Only useful for OpenType CFF fonts.) 0145 void convertToType0(const char *psName, int *cidMap, int nCIDs, FoFiOutputFunc outputFunc, void *outputStream) const; 0146 0147 // Returns a pointer to the CFF font embedded in this OpenType font. 0148 // If successful, sets *<start> and *<length>, and returns true. 0149 // Otherwise returns false. (Only useful for OpenType CFF fonts). 0150 bool getCFFBlock(char **start, int *length) const; 0151 0152 // setup vert/vrt2 GSUB for default lang 0153 int setupGSUB(const char *scriptName); 0154 0155 // setup vert/vrt2 GSUB for specified lang 0156 int setupGSUB(const char *scriptName, const char *languageName); 0157 0158 private: 0159 FoFiTrueType(const unsigned char *fileA, int lenA, bool freeFileDataA, int faceIndexA); 0160 void cvtEncoding(char **encoding, FoFiOutputFunc outputFunc, void *outputStream) const; 0161 void cvtCharStrings(char **encoding, const int *codeToGID, FoFiOutputFunc outputFunc, void *outputStream) const; 0162 void cvtSfnts(FoFiOutputFunc outputFunc, void *outputStream, const GooString *name, bool needVerticalMetrics, int *maxUsedGlyph) const; 0163 void dumpString(const unsigned char *s, int length, FoFiOutputFunc outputFunc, void *outputStream) const; 0164 unsigned int computeTableChecksum(const unsigned char *data, int length) const; 0165 void parse(); 0166 void readPostTable(); 0167 int seekTable(const char *tag) const; 0168 unsigned int charToTag(const char *tagName); 0169 unsigned int doMapToVertGID(unsigned int orgGID); 0170 unsigned int scanLookupList(unsigned int listIndex, unsigned int orgGID); 0171 unsigned int scanLookupSubTable(unsigned int subTable, unsigned int orgGID); 0172 int checkGIDInCoverage(unsigned int coverage, unsigned int orgGID); 0173 0174 TrueTypeTable *tables; 0175 int nTables; 0176 TrueTypeCmap *cmaps; 0177 int nCmaps; 0178 int nGlyphs; 0179 int locaFmt; 0180 int bbox[4]; 0181 std::unordered_map<std::string, int> nameToGID; 0182 bool openTypeCFF; 0183 0184 bool parsedOk; 0185 int faceIndex; 0186 unsigned int gsubFeatureTable; 0187 unsigned int gsubLookupList; 0188 }; 0189 0190 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|