//
//  GSGlyphInfo.h
//  Glyphs
//
//  Created by Georg Seifert on 20.1.08.
//  Copyright 2008 schriftgestaltung.de. All rights reserved.
//

#import <GlyphsCore/GSFont.h>
#import <GlyphsCore/CFOldStylePList.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(unsigned short, GSGlyphInfoType) {
	GSGlyphInfoTypeInfo,
	GSGlyphInfoTypeHeader1,
	GSGlyphInfoTypeHeader2,
};

/** GSGlyphInfo: The class defining the glyphInfo object
 This class defines the glyphInfo object.
 */
@interface GSGlyphInfo : NSObject <NSCopying>

- (instancetype)initWithParserLine:(GSPlistParseInfo *)pInfo;

/// The glyph name.
@property (strong, nonatomic) NSString *name;

@property (readonly, nonatomic) NSString *nameUI;

@property (assign, nonatomic) BOOL deprecated;

/// The category of the glyph.
/**
This is mostly from the UnicodeData.txt file from unicode.org. Some corrections have been made (Accents, ...)
e.g: "Letter", "Number", "Punctuation", "Mark", "Separator", "Symbol", "Other"
*/
@property (strong, nonatomic) NSString *category;

/// The subcategory of the glyph.
/**
 This is mostly from the UnicodeData.txt file from unicode.org. Some corrections and additions have been made
 e.g: "Ligature", "Decimal Digit", ...
 */
@property (strong, nonatomic) NSString *subCategory;

@property (strong, nonatomic) NSString *group;

@property (nonatomic) int16_t groupIdx;

#ifndef GLYPHS_VIEWER
/** The case of the glyph

 Like Uppercase, Lowercase, smallCaps
 */
- (GSCase)case;
- (void)setCase:(GSCase)aCase;

/// The Glyph is composed from this glyphs.
/**
f_f_i > f f i
Adieresis > A dieresis
*/
@property (strong, nonatomic, nullable) NSArray<GSGlyphInfo *> *components;

@property (readonly, nonatomic) NSUInteger countOfComponents;

- (void)setComponentNames:(NSArray<NSString *> *)componentNames;

@property (strong, nonatomic) NSString *baseString;

- (void)updateBaseString:(GSGlyphsInfo *)glyphInfo;

/// The Glyph can be combined with this accents.
/**
a > dieresis, grave, acute ...
*/
@property (strong, nonatomic, nullable) NSArray *marks;

/// The anchors of the glyph.
/**
e.g: "top", "ogonek"
*/
@property (strong, nonatomic, nullable) NSArray *anchors;

/// The unicode value.
/**
as a hex string.
*/
@property (strong, nonatomic, nullable) NSOrderedSet<NSString *> *unicodes;

@property (strong, nonatomic, nullable) NSString *unicodeLegacy;

- (NSUInteger)countOfUnicodes;

@property (readonly, nonatomic, nullable) NSString *unicode;

- (void)addUnicode:(NSString *)unicode;

@property (strong, nonatomic, nullable) NSString *unicharString;

@property (readonly, nonatomic) UTF32Char unicodeChar;
/// The script.
/**
e.g: "Latin", "Cyrillic", "Greek"
*/
@property (strong, nonatomic, nullable) GSScriptID script;

/// Name to use on export
/**
acyrill > afii10065
*/
@property (strong, nonatomic, nullable) NSString *production;
#endif

@property (nonatomic) GSWritingDirection direction;
@property (strong, nonatomic, nullable) NSString *mirror;

+ (NSString *)stringFromDirection:(GSWritingDirection)direction;
+ (GSWritingDirection)directionFromString:(NSString *)directionString;
+ (nullable NSString *)stringFromCase:(GSCase)aCase;
+ (GSCase)caseFromString:(NSString *)caseString;
+ (nullable NSString *)localizedStringFromCase:(GSCase)aCase;

#ifndef GLYPHS_VIEWER
@property (nonatomic) uint32 index;
@property (strong, nonatomic, nullable) NSString *sortName;
@property (strong, nonatomic, nullable) NSString *sortNameKeep;
@property (strong, nonatomic, nullable) NSString *desc;
@property (nonatomic, strong, nullable) NSArray *altNames;

- (nullable NSString *)componentsString;

#if DEBUG
- (instancetype)initWithStringLine:(NSString *)line;
- (NSString *)line;
#endif

@property BOOL locked;
#endif

@property GSGlyphInfoType type;

@end

NS_ASSUME_NONNULL_END
