1 /* 2 Source File : UsedFontsRepository.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 26 #include <string> 27 #include <map> 28 #include <utility> 29 30 31 32 class FreeTypeWrapper; 33 class PDFUsedFont; 34 class ObjectsContext; 35 class PDFParser; 36 37 typedef std::pair<std::string,long> StringAndLong; 38 typedef std::map<StringAndLong,PDFUsedFont*> StringAndLongToPDFUsedFontMap; 39 typedef std::map<std::string,std::string> StringToStringMap; 40 41 class UsedFontsRepository 42 { 43 public: 44 UsedFontsRepository(void); 45 ~UsedFontsRepository(void); 46 47 void SetObjectsContext(ObjectsContext* inObjectsContext); 48 49 PDFUsedFont* GetFontForFile(const std::string& inFontFilePath,long inFontIndex); 50 // second overload is for type 1, when an additional metrics file is available 51 PDFUsedFont* GetFontForFile(const std::string& inFontFilePath,const std::string& inOptionalMetricsFile,long inFontIndex); 52 53 PDFHummus::EStatusCode WriteUsedFontsDefinitions(); 54 55 PDFHummus::EStatusCode WriteState(ObjectsContext* inStateWriter,ObjectIDType inObjectID); 56 PDFHummus::EStatusCode ReadState(PDFParser* inStateReader,ObjectIDType inObjectID); 57 58 void Reset(); 59 60 private: 61 62 ObjectsContext* mObjectsContext; 63 FreeTypeWrapper* mInputFontsInformation; 64 StringAndLongToPDFUsedFontMap mUsedFonts; 65 StringToStringMap mOptionaMetricsFiles; 66 }; 67