mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-16 03:30:42 +00:00
Whitespace, comment tweak.
This commit is contained in:
1 parent
dbb10f69f6
commit
2952070698
2 files changed
+75
-75
No files matched your search
+2
-2
@@ -56,8 +56,8 @@ var _CPFonts = {},
|
||||
|
||||
Note that in either case, you can specify a comma-delimited list of fonts as the font face.
|
||||
The browser will use the first available font in the list. CPFont always ensures that Arial
|
||||
and sans-serif are always in the generated CSS string, so there is no need to add them to
|
||||
the end of your font list.
|
||||
and sans-serif are in the generated CSS string, so there is no need to add them to the end
|
||||
of your font list.
|
||||
|
||||
If you are using nib2cib, you should use the second method (using Info.plist),
|
||||
and be sure to run nib2cib again any time you modify the CPSystemFontFace or CPSystemFontSize items.
|
||||
|
||||
+73
-73
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
font_info
|
||||
font_info
|
||||
|
||||
Copyright 2010 Aparajita Fishman
|
||||
Copyright 2010 Aparajita Fishman
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -10,104 +10,104 @@
|
||||
#define resultFormat @"{\"familyName\":\"%@\", \"bold\":%@, \"italic\":%@, \"ascender\":%g, \"descender\":%g, \"lineHeight\":%g, \"width\":%g}"
|
||||
|
||||
enum {
|
||||
kErrInvalidArguments = 1,
|
||||
kErrInvalidFontName
|
||||
kErrInvalidArguments = 1,
|
||||
kErrInvalidFontName
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int exitCode = 0;
|
||||
NSString* stringToMeasure = nil;
|
||||
int exitCode = 0;
|
||||
NSString* stringToMeasure = nil;
|
||||
|
||||
// usage: fontinfo [-n] face [size [string]]
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
BOOL appendLineFeed = YES;
|
||||
int nextArgument = 1;
|
||||
{
|
||||
BOOL appendLineFeed = YES;
|
||||
int nextArgument = 1;
|
||||
|
||||
if (argv[1][0] == '-')
|
||||
{
|
||||
if (argv[1][1] == 'n')
|
||||
{
|
||||
appendLineFeed = NO;
|
||||
++nextArgument;
|
||||
}
|
||||
else
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
if (argv[1][0] == '-')
|
||||
{
|
||||
if (argv[1][1] == 'n')
|
||||
{
|
||||
appendLineFeed = NO;
|
||||
++nextArgument;
|
||||
}
|
||||
else
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
|
||||
if (exitCode == 0)
|
||||
{
|
||||
CGFloat fontSize = 12;
|
||||
if (exitCode == 0)
|
||||
{
|
||||
CGFloat fontSize = 12;
|
||||
|
||||
NSString* fontName = [NSString stringWithUTF8String:argv[nextArgument++]];
|
||||
NSString* fontName = [NSString stringWithUTF8String:argv[nextArgument++]];
|
||||
|
||||
if (argc > nextArgument)
|
||||
fontSize = atof(argv[nextArgument++]);
|
||||
if (argc > nextArgument)
|
||||
fontSize = atof(argv[nextArgument++]);
|
||||
|
||||
if (fontSize > 0.0)
|
||||
{
|
||||
NSFont* font = [NSFont fontWithName:fontName size:fontSize];
|
||||
if (fontSize > 0.0)
|
||||
{
|
||||
NSFont* font = [NSFont fontWithName:fontName size:fontSize];
|
||||
|
||||
if (font)
|
||||
{
|
||||
if (argc > nextArgument)
|
||||
stringToMeasure = [NSString stringWithUTF8String:argv[nextArgument]];
|
||||
if (font)
|
||||
{
|
||||
if (argc > nextArgument)
|
||||
stringToMeasure = [NSString stringWithUTF8String:argv[nextArgument]];
|
||||
|
||||
NSString* familyName = [font familyName];
|
||||
NSFontDescriptor* descriptor = [font fontDescriptor];
|
||||
NSFontSymbolicTraits traits = [descriptor symbolicTraits];
|
||||
BOOL isBold = traits & NSFontBoldTrait;
|
||||
BOOL isItalic = traits & NSFontItalicTrait;
|
||||
CGFloat ascender = [font ascender];
|
||||
CGFloat descender = [font descender];
|
||||
NSString* familyName = [font familyName];
|
||||
NSFontDescriptor* descriptor = [font fontDescriptor];
|
||||
NSFontSymbolicTraits traits = [descriptor symbolicTraits];
|
||||
BOOL isBold = traits & NSFontBoldTrait;
|
||||
BOOL isItalic = traits & NSFontItalicTrait;
|
||||
CGFloat ascender = [font ascender];
|
||||
CGFloat descender = [font descender];
|
||||
|
||||
NSLayoutManager* layout = [NSLayoutManager new];
|
||||
CGFloat lineHeight = [layout defaultLineHeightForFont:font];
|
||||
NSLayoutManager* layout = [NSLayoutManager new];
|
||||
CGFloat lineHeight = [layout defaultLineHeightForFont:font];
|
||||
[layout release];
|
||||
|
||||
CGFloat width = 0.0;
|
||||
CGFloat width = 0.0;
|
||||
|
||||
if (stringToMeasure)
|
||||
{
|
||||
NSDictionary* attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
|
||||
NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:stringToMeasure attributes:attributes];
|
||||
if (stringToMeasure)
|
||||
{
|
||||
NSDictionary* attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
|
||||
NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:stringToMeasure attributes:attributes];
|
||||
|
||||
if (attrString)
|
||||
width = [attrString size].width;
|
||||
if (attrString)
|
||||
width = [attrString size].width;
|
||||
|
||||
[attrString release];
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableString* result = [NSMutableString stringWithFormat:resultFormat,
|
||||
familyName,
|
||||
isBold ? @"true" : @"false", isItalic ? @"true" : @"false",
|
||||
ascender, descender, lineHeight,
|
||||
width];
|
||||
NSMutableString* result = [NSMutableString stringWithFormat:resultFormat,
|
||||
familyName,
|
||||
isBold ? @"true" : @"false", isItalic ? @"true" : @"false",
|
||||
ascender, descender, lineHeight,
|
||||
width];
|
||||
|
||||
if (appendLineFeed)
|
||||
[result appendString:@"\n"];
|
||||
if (appendLineFeed)
|
||||
[result appendString:@"\n"];
|
||||
|
||||
printf("%s", [result UTF8String]);
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidFontName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
printf("%s", [result UTF8String]);
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidFontName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
return exitCode;
|
||||
|
||||
Reference in new issue
Block a user