-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use custom font for stable version and copyright #1799
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,18 +33,24 @@ | |
|
||
protected: | ||
virtual void SetUp() { | ||
const CFStringRef fontName = static_cast<CFStringRef>(@"Segoe UI"); | ||
_font = CTFontCreateWithName(fontName, 0.0, NULL); | ||
EXPECT_TRUE_MSG(_font != nil, "Failed: Font is nil."); | ||
auto fontName = woc::MakeAutoCF<CFStringRef>(CFSTR("Metadata Test")); | ||
_testFileURL = __GetURLFromPathRelativeToModuleDirectory(@"/data/MetadataTest-Regular.ttf"); | ||
CFErrorRef error = nullptr; | ||
EXPECT_TRUE(CTFontManagerRegisterFontsForURL((__bridge CFURLRef)_testFileURL.get(), kCTFontManagerScopeSession, &error)); | ||
EXPECT_EQ(nullptr, error); | ||
|
||
_font = woc::MakeAutoCF<CTFontRef>(CTFontCreateWithName(fontName, 20, nullptr)); | ||
ASSERT_NE(nullptr, _font); | ||
} | ||
|
||
virtual void TearDown() { | ||
if (_font) { | ||
CFRelease(_font); | ||
} | ||
CFErrorRef error = nullptr; | ||
EXPECT_TRUE(CTFontManagerUnregisterFontsForURL((__bridge CFURLRef)_testFileURL.get(), kCTFontManagerScopeSession, &error)); | ||
EXPECT_EQ(nullptr, error); | ||
} | ||
|
||
CTFontRef _font; | ||
woc::AutoCF<CTFontRef> _font; | ||
StrongId<NSURL> _testFileURL; | ||
}; | ||
|
||
TEST_P(FontCopyName, VerifyProperties) { | ||
|
@@ -53,21 +59,23 @@ virtual void TearDown() { | |
CFRelease(propertyValue); | ||
} | ||
|
||
const NSString* c_familyName = @"Segoe UI"; | ||
const NSString* c_familyName = @"Metadata Test"; | ||
const NSString* c_subFamilyName = @"Regular"; | ||
const NSString* c_styleName = @"Regular"; | ||
const NSString* c_uniqueName = @"Segoe UI Regular"; | ||
const NSString* c_fullName = @"Segoe UI"; | ||
const NSString* c_uniqueName = @"Metadata Test Regular"; | ||
const NSString* c_fullName = @"Metadata Test"; | ||
|
||
const NSString* c_postscriptName = @"SegoeUI"; | ||
const NSString* c_trademarkName = @"Segoe is a trademark of the Microsoft group of companies."; | ||
const NSString* c_postscriptName = @"MetadataTest-Regular"; | ||
const NSString* c_trademarkName = @"MetadataTest is not a trademark."; | ||
const NSString* c_manufacturerName = @"Microsoft Corporation"; | ||
const NSString* c_designerName = nullptr; | ||
const NSString* c_descriptionName = nullptr; | ||
const NSString* c_vendorURLName = @"http://www.microsoft.com/typography/fonts/"; | ||
const NSString* c_vendorURLName = @"https://developer.microsoft.com/en-us/windows/bridges/ios"; | ||
const NSString* c_designerURLName = nullptr; | ||
const NSString* c_licenseURLName = @"http://www.microsoft.com/typography/fonts/"; | ||
const NSString* c_licenseURLName = @"https://developer.microsoft.com/en-us/windows/bridges/ios"; | ||
const NSString* c_sampleTextName = nullptr; | ||
const NSString* c_copyrightName = @"Copyright (c) Microsoft"; | ||
const NSString* c_versionName = @"Version 1.01 "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How strange that it leave a space at the end; I was even cautious to have it not do that. |
||
const NSString* c_postscriptCIDName = nullptr; | ||
|
||
INSTANTIATE_TEST_CASE_P(CTFont, | ||
|
@@ -86,28 +94,10 @@ virtual void TearDown() { | |
::testing::make_tuple(kCTFontDesignerURLNameKey, c_designerURLName), | ||
::testing::make_tuple(kCTFontLicenseURLNameKey, c_licenseURLName), | ||
::testing::make_tuple(kCTFontSampleTextNameKey, c_sampleTextName), | ||
::testing::make_tuple(kCTFontCopyrightNameKey, c_copyrightName), | ||
::testing::make_tuple(kCTFontVersionNameKey, c_versionName), | ||
::testing::make_tuple(kCTFontPostScriptCIDNameKey, c_postscriptCIDName))); | ||
|
||
TEST(CTFont, RegisteredFontCopyName) { | ||
auto fontName = woc::MakeAutoCF<CFStringRef>(CFSTR("WinObjC")); | ||
NSURL* testFileURL = __GetURLFromPathRelativeToModuleDirectory(@"/data/WinObjC.ttf"); | ||
CFErrorRef error = nullptr; | ||
EXPECT_TRUE(CTFontManagerRegisterFontsForURL((__bridge CFURLRef)testFileURL, kCTFontManagerScopeSession, &error)); | ||
EXPECT_EQ(nullptr, error); | ||
|
||
auto font = woc::MakeAutoCF<CTFontRef>(CTFontCreateWithName(fontName, 20, nullptr)); | ||
ASSERT_NE(nullptr, font); | ||
|
||
auto copyright = woc::MakeAutoCF<CFStringRef>(CTFontCopyName(font, kCTFontCopyrightNameKey)); | ||
EXPECT_OBJCEQ(@"Copyright (c) Microsoft", static_cast<NSString*>(copyright.get())); | ||
|
||
auto version = woc::MakeAutoCF<CFStringRef>(CTFontCopyName(font, kCTFontVersionNameKey)); | ||
EXPECT_OBJCEQ(@"Version 001.000 ", static_cast<NSString*>(version.get())); | ||
|
||
EXPECT_TRUE(CTFontManagerUnregisterFontsForURL((__bridge CFURLRef)testFileURL, kCTFontManagerScopeSession, &error)); | ||
EXPECT_EQ(nullptr, error); | ||
} | ||
|
||
TEST(CTFont, EqualHash) { | ||
CTFontRef font1 = CTFontCreateWithName(CFSTR("Times New Roman"), 12.0, NULL); | ||
CTFontRef font2 = CTFontCreateWithName(CFSTR("Times New Roman"), 12.0, NULL); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aww, these moved around w.r.t. the true original. the diff could look so much prettier if Version was below fullName and copyright was above familyName! :P