//
//  CFFFontSet.h
//  GSFontTools
//
//  Created by Georg Seifert on 29.07.11.
//  Copyright 2011 schriftgestaltung.de. All rights reserved.
//

#import <GSFontTools/CFFVersion.h>

@class CFFTopDict;
@class CFFTopDictIndex;
@class GSFileData;
@class GSFont;
@class GSXMLWriter;
@class TTFont;
@class CFFGlobalSubrsIndex;

NS_ASSUME_NONNULL_BEGIN

/*
 A CFF font "file" can contain more than one font, although this is
 extremely rare (and not allowed within OpenType fonts).

 This class is the entry point for parsing a CFF table. To actually
 manipulate the data inside the CFF font, you will want to access the
 ``CFFFontSet``'s :class:`TopDict` object. To do this, a ``CFFFontSet``
 object can either be treated as a dictionary (with appropriate
 ``keys()`` and ``values()`` methods) mapping font names to :class:`TopDict`
 objects, or as a list.
 */
@interface CFFFontSet : NSObject

@property (nonatomic, assign) CFFVersion major;
@property (nonatomic, assign) uint8_t minor;
@property (nonatomic, strong) NSArray<NSString *> *fontNames;
@property (nonatomic, strong, nullable) CFFTopDictIndex *topDictIndex;
@property (nonatomic, readonly) NSUInteger count;
@property (nonatomic, strong) CFFGlobalSubrsIndex *globalSubrs;

//- (NSArray *)allKeys;
//- (void)setItem:(CFFTopDict *)item forKey:(NSString *)key;
- (nullable CFFTopDict *)itemForKey:(NSString *)key;

/*
 Parse a binary CFF file into an internal representation. ``file``
 should be a file handle object. ``otFont`` is the top-level
 :py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

 If ``isCFF2`` is passed and set to ``True`` or ``False``, then the
 library makes an assertion that the CFF header is of the appropriate
 version.
 */
- (BOOL)decompile:(GSFileData *)data
			 font:(TTFont *)font
			error:(NSError **)error;

/*
 Write the object back into binary representation onto the given file.
 ``file`` should be a file handle object. ``otFont`` is the top-level
 :py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

 If ``isCFF2`` is passed and set to ``True`` or ``False``, then the
 library makes an assertion that the CFF header is of the appropriate
 version.
 */
- (BOOL)compile:(NSMutableData *)data font:(TTFont *)font error:(NSError **)error;

- (void)fromXML:(NSString *)name attrs:(NSDictionary *)attrs content:(id)content;
- (void)toXML:(GSXMLWriter *)writer;

@end

NS_ASSUME_NONNULL_END
