mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-28 19:08:50 +00:00
CPFontManager convertFont:toFace:.
This commit is contained in:
1 parent
7f1b396ce8
commit
6a67243460
2 files changed
+26
No files matched your search
@@ -189,6 +189,20 @@ var CPSharedFontManager = nil,
|
||||
return aFont;
|
||||
}
|
||||
|
||||
- (CPFont)convertFont:(CPFont)aFont toFace:(CPString)aTypeface
|
||||
{
|
||||
if (!aFont)
|
||||
return nil;
|
||||
|
||||
var shouldBeBold = [aFont isBold],
|
||||
shouldBeItalic = [aFont isItalic],
|
||||
shouldBeSize = [aFont size];
|
||||
|
||||
aFont = [CPFont _fontWithName:aTypeface size:shouldBeSize bold:shouldBeBold italic:shouldBeItalic] || aFont;
|
||||
|
||||
return aFont;
|
||||
}
|
||||
|
||||
- (@action)addFontTrait:(id)sender
|
||||
{
|
||||
_activeChange = [CPDictionary dictionaryWithObject:[sender tag] forKey:@"addTraits"];
|
||||
|
||||
@@ -108,6 +108,18 @@
|
||||
[self assert:12.0 equals:[convertedFontB size] message:@"maintain size fontB with CPUnitalicFontMask"];
|
||||
}
|
||||
|
||||
- (void)testConvertFont_toFace_
|
||||
{
|
||||
fontB = [CPFont boldFontWithName:@"Helvetica" size:12.0 italic:YES];
|
||||
|
||||
convertedFontB = [[CPFontManager sharedFontManager] convertFont:fontB toFace:@"Arial"];
|
||||
|
||||
[self assertTrue:[convertedFontB isBold] message:@"maintain bold fontB"];
|
||||
[self assertTrue:[convertedFontB isItalic] message:@"maintain italic fontB"];
|
||||
[self assert:12.0 equals:[convertedFontB size] message:@"maintain size fontB"];
|
||||
[self assert:@"Arial" equals:[convertedFontB familyName] message:@"change face fontB"];
|
||||
}
|
||||
|
||||
- (@action)changeFont:(id)sender
|
||||
{
|
||||
convertedFontA = [sender convertFont:fontA];
|
||||
|
||||
Reference in new issue
Block a user