1 /* 2 Source File : ANSIFontWriter.h 3 4 5 Copyright 2011 Gal Kahana PDFWriter 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 20 */ 21 #pragma once 22 23 #include "EStatusCode.h" 24 #include "ObjectsBasicTypes.h" 25 #include "WrittenFontRepresentation.h" 26 27 #include <utility> 28 #include <vector> 29 #include <string> 30 #include <list> 31 32 class FreeTypeFaceWrapper; 33 class ObjectsContext; 34 class DictionaryContext; 35 class IANSIFontWriterHelper; 36 class IByteWriter; 37 38 39 40 typedef std::pair<unsigned short,std::string> UShortAndString; 41 typedef std::list<UShortAndString> UShortAndStringList; 42 43 typedef std::pair<unsigned int, GlyphEncodingInfo> UIntAndGlyphEncodingInfo; 44 typedef std::vector<UIntAndGlyphEncodingInfo> UIntAndGlyphEncodingInfoVector; 45 46 class ANSIFontWriter 47 { 48 public: 49 ANSIFontWriter(void); 50 ~ANSIFontWriter(void); 51 52 53 PDFHummus::EStatusCode WriteFont( FreeTypeFaceWrapper& inFontInfo, 54 WrittenFontRepresentation* inFontOccurrence, 55 ObjectsContext* inObjectsContext, 56 IANSIFontWriterHelper* inANSIFontWriterHelper, 57 const std::string& inWrittenFontName); 58 59 private: 60 61 void CalculateCharacterEncodingArray(); 62 void WriteWidths(DictionaryContext* inFontContext); 63 void CalculateDifferences(); 64 void WriteEncoding(DictionaryContext* inFontContext); 65 void WriteEncodingDictionary(); 66 void WriteToUnicodeMap(ObjectIDType inToUnicodeMap); 67 void WriteGlyphEntry(IByteWriter* inWriter,unsigned short inEncodedCharacter,const ULongVector& inUnicodeValues); 68 69 FreeTypeFaceWrapper* mFontInfo; 70 WrittenFontRepresentation* mFontOccurrence; 71 ObjectsContext* mObjectsContext; 72 73 UIntAndGlyphEncodingInfoVector mCharactersVector; 74 UShortAndStringList mDifferences; 75 ObjectIDType mEncodingDictionaryID; 76 }; 77