Merge pull request #118 from gnustep/NSGlyphInfo_branch

This commit is contained in:
Gregory Casamento 2021-10-21 16:38:54 -04:00 committed by GitHub
commit 7617392f80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 264 additions and 1 deletions

View file

@ -171,6 +171,7 @@
#import <AppKit/NSFontDescriptor.h>
#import <AppKit/NSGestureRecognizer.h>
#import <AppKit/NSGlyphGenerator.h>
#import <AppKit/NSGlyphInfo.h>
#import <AppKit/NSGradient.h>
#import <AppKit/NSGraphicsContext.h>
#import <AppKit/NSGridView.h>

View file

@ -0,0 +1,127 @@
/* Interface of class NSGlyphInfo
Copyright (C) 2021 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 14-10-2021
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSGlyphInfo_h_GNUSTEP_GUI_INCLUDE
#define _NSGlyphInfo_h_GNUSTEP_GUI_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <Foundation/NSObject.h>
#import <AppKit/NSFont.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
typedef unsigned short CGGlyph;
enum {
NSIdentityMappingCharacterCollection = 0,
NSAdobeCNS1CharacterCollection,
NSAdobeGB1CharacterCollection,
NSAdobeJapan1CharacterCollection,
NSAdobeJapan2CharacterCollection,
NSAdobeKorea1CharacterCollection
};
typedef NSUInteger NSCharacterCollection;
@class NSFont, NSString;
@interface NSGlyphInfo : NSObject
{
CGGlyph _glyphID;
NSFont *_font;
NSString *_baseString;
NSString *_glyphName;
NSUInteger _characterIdentifier;
NSCharacterCollection _characterCollection;
}
/**
* Creates an NSGlyphInfo object from the specified glyph.
*/
+ (NSGlyphInfo *) glyphInfoWithCGGlyph: (CGGlyph)glyph
forFont: (NSFont *)font
baseString: (NSString *)string;
/**
* The string containing the specified glyph
*/
- (NSString *) baseString;
/**
* The glyph this glyph info object represents.
*/
- (CGGlyph) glyphID;
// Deprecated methods...
/**
* Creates an NSGlyphInfo object with the given cid.
*/
+ (NSGlyphInfo *)glyphInfoWithCharacterIdentifier:(NSUInteger)cid
collection:(NSCharacterCollection)characterCollection
baseString:(NSString *)string;
/**
* Creates an NSGlyphInfo object with the given NSGlyph.
*/
+ (NSGlyphInfo *)glyphInfoWithGlyph:(NSGlyph)glyph
forFont:(NSFont *)font
baseString:(NSString *)string;
/**
* Creates an NSGlyphInfo object with the given glyph name.
*/
+ (NSGlyphInfo *)glyphInfoWithGlyphName:(NSString *)glyphName
forFont:(NSFont *)font
baseString:(NSString *)string;
/**
* the character identifier, readonly.
*/
- (NSUInteger) characterIdentifier;
/**
* the character collection, readonly.
*/
- (NSCharacterCollection) characterCollection;
/**
* the glyph name, readonly.
*/
- (NSString *) glyphName;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSGlyphInfo_h_GNUSTEP_GUI_INCLUDE */

View file

@ -12,7 +12,6 @@ MISSING HEADERS ( * = difficult, - = quick, + = placeholder, x = won't do )
> NSDraggingSession.h -
> NSFilePromiseProvider.h -
> NSFilePromiseReceiver.h -
> NSGlyphInfo.h -
> NSItemProvider.h +
> NSMenuToolbarItem.h -
> NSOpenGLLayer.h +

View file

@ -142,6 +142,7 @@ NSTouchBarItem.m \
NSGestureRecognizer.m \
NSGradient.m \
NSGlyphGenerator.m \
NSGlyphInfo.m \
NSGraphicsContext.m \
NSGroupTouchBarItem.m \
NSHelpPanel.m \
@ -445,6 +446,7 @@ NSGestureRecognizer.h \
NSGradient.h \
NSGroupTouchBarItem.h \
NSGlyphGenerator.h \
NSGlyphInfo.h \
NSGraphicsContext.h \
NSGridView.h \
NSHelpPanel.h \

134
Source/NSGlyphInfo.m Normal file
View file

@ -0,0 +1,134 @@
/* Implementation of class NSGlyphInfo
Copyright (C) 2021 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 14-10-2021
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
/*
* This class should use data from this project for it's character collection data...
* https://github.com/adobe-type-tools/cmap-resources
* NOTE: This class is a place holder until the above is better understood.
*/
#import <Foundation/NSString.h>
#import "AppKit/NSGlyphInfo.h"
#import "AppKit/NSFont.h"
#import "AppKit/NSGlyphGenerator.h"
@implementation NSGlyphInfo
/*
* The purpose of this method is to determine the mapping as it is not
* always going to be one to one.
*/
- (void) _characterMapping
{
_characterCollection = NSIdentityMappingCharacterCollection;
_characterIdentifier = _glyphID;
}
// GNUstep specific method...
- (instancetype) initWithCGGlyph: (CGGlyph)g
forFont: (NSFont *)f
baseString: (NSString *)s
{
self = [super init];
if (self != nil)
{
_glyphID = g;
ASSIGN(_font, f);
ASSIGN(_baseString, s);
[self _characterMapping];
}
return self;
}
+ (NSGlyphInfo *) glyphInfoWithCGGlyph: (CGGlyph)glyph
forFont: (NSFont *)font
baseString: (NSString *)string
{
return [[NSGlyphInfo alloc] initWithCGGlyph: glyph
forFont: font
baseString: string];
}
- (NSString *) baseString
{
return _baseString;
}
- (CGGlyph) glyphID
{
return _glyphID;
}
// Deprecated methods...
+ (NSGlyphInfo *)glyphInfoWithCharacterIdentifier:(NSUInteger)cid
collection:(NSCharacterCollection)characterCollection
baseString:(NSString *)string
{
NSGlyphInfo *gi = [NSGlyphInfo glyphInfoWithCGGlyph: (CGGlyph)cid
forFont: nil
baseString: string];
gi->_characterCollection = characterCollection;
return gi;
}
+ (NSGlyphInfo *)glyphInfoWithGlyph:(NSGlyph)glyph
forFont:(NSFont *)font
baseString:(NSString *)string
{
return nil;
}
+ (NSGlyphInfo *)glyphInfoWithGlyphName:(NSString *)glyphName
forFont:(NSFont *)font
baseString:(NSString *)string
{
return nil;
}
- (NSUInteger) characterIdentifier
{
return _characterIdentifier;
}
- (NSCharacterCollection) characterCollection;
{
return _characterCollection;
}
- (NSString *) glyphName
{
return _glyphName;
}
- (NSString *) description
{
return [NSString stringWithFormat: @"GID %4x", _glyphID];
}
@end