mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-05 10:23:39 +00:00
Ignore Xcode project user data, added fontinfo package
This commit is contained in:
@@ -5,3 +5,7 @@ Demos
|
||||
./Aristo
|
||||
WebSite
|
||||
.push-package
|
||||
*.xcodeproj/*.pbxuser
|
||||
*.xcodeproj/*.perspectivev3
|
||||
xcuserdata/
|
||||
!*.xcodeproj/project.pbxproj
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
var OS = require("os");
|
||||
|
||||
exports.fontinfo = function(name, size)
|
||||
{
|
||||
var p = OS.popen(["fontinfo", "-n", name, size || 12]);
|
||||
|
||||
if (p.wait() === 0)
|
||||
return JSON.parse(p.stdout.read());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
|
||||
require("../common.jake");
|
||||
|
||||
// nib2cib has to come before capp since capp uses nib2cib
|
||||
subtasks(["nib2cib", "capp", "NativeHost"], ["build"/*, "clean", "clobber"*/]);
|
||||
// nib2cib uses fontinfo and capp uses nib2cib
|
||||
subtasks(["fontinfo", "nib2cib", "capp", "NativeHost"], ["build"/*, "clean", "clobber"*/]);
|
||||
|
||||
subtasks(["fontinfo"], ["clean", "clobber"]);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
build/
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
require ("../../common.jake");
|
||||
|
||||
var OS = require("os"),
|
||||
task = require("jake").task;
|
||||
|
||||
task ("build", function()
|
||||
{
|
||||
if (executableExists("xcodebuild"))
|
||||
{
|
||||
var args = "-alltargets -configuration Release";
|
||||
|
||||
if (FILE.exists(FILE.join("/", "Developer", "SDKs", "MacOSX10.5.sdk")))
|
||||
args = "-sdk macosx10.5 " + args;
|
||||
|
||||
else
|
||||
args = "-sdk macosx " + args;
|
||||
|
||||
if (OS.system("xcodebuild " + args))
|
||||
OS.exit(1);
|
||||
|
||||
var binPath = FILE.join($BUILD_CJS_CAPPUCCINO_BIN, "fontinfo");
|
||||
|
||||
FILE.copy(FILE.join("build", "Release", "fontinfo"), binPath);
|
||||
FILE.chmod(binPath, 0755);
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Building fontinfo requires Xcode.");
|
||||
}
|
||||
});
|
||||
|
||||
task ("clean", function()
|
||||
{
|
||||
if (OS.system("xcodebuild clean"))
|
||||
OS.exit(1);
|
||||
});
|
||||
|
||||
task ("clobber", function()
|
||||
{
|
||||
if (OS.system("xcodebuild clean"))
|
||||
OS.exit(1);
|
||||
});
|
||||
|
||||
task ("default", ["build"]);
|
||||
@@ -0,0 +1,47 @@
|
||||
NAME
|
||||
fontinfo -- retrieve information about a font
|
||||
|
||||
SYNOPSIS
|
||||
fontinfo [-n] font [size]
|
||||
|
||||
DESCRIPTION
|
||||
fontinfo is a tiny utility that returns information about a font.
|
||||
The font name must be a full PostScript name, not a display name. So you would use something
|
||||
like "LucidaGrande-Bold", not "Lucida Grande Bold". The size can be any floating point number
|
||||
greater than zero. If no size is given, it defaults to 12.
|
||||
|
||||
If the -n option is passed, the output will not be terminated with a linefeed.
|
||||
|
||||
EXIT STATUS
|
||||
fontinfo exits with a return status of zero if there are no errors.
|
||||
fontinfo exits with a return status of 1 if any arguments are invalid, or a status of 2 if the font
|
||||
cannot be found.
|
||||
|
||||
OUTPUT
|
||||
fontinfo outputs a stringified JSON object with the following structure:
|
||||
|
||||
{
|
||||
familyName: <string>,
|
||||
bold: <boolean>,
|
||||
italic: <boolean>,
|
||||
ascender: <float>,
|
||||
descender: <float>,
|
||||
line-height: <float>
|
||||
}
|
||||
|
||||
If -n is not passed, the JSON is terminated with a linefeed. The fields of the object are as follows:
|
||||
|
||||
familyName: The display name of the font's family
|
||||
bold: Whether the font's stylistic traits are considered bold
|
||||
italic: Whether the font's stylistic traits are considered italic
|
||||
ascender: The offset from the baseline in points (not pixels!) of the longest ascender of the given font at
|
||||
the given size.
|
||||
descender: The negative offset from the baseline in points (not pixels!)
|
||||
of the longest descender of the given font at the given size.
|
||||
lineHeight: The height in points (not pixels!) of the largest glyph in the given font at the given size.
|
||||
Note that glyphs include diacritical marks that may appear above and below the largest ascender
|
||||
and descender, so the line height will almost always be greater than ascender + descender.
|
||||
|
||||
AUTHORS
|
||||
Aparajita Fishman, Victory-Heart Productions
|
||||
http://www.aparajita.com
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
font_info
|
||||
|
||||
Copyright 2010 Aparajita Fishman
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
enum {
|
||||
kErrInvalidArguments = 1,
|
||||
kErrInvalidFontName
|
||||
};
|
||||
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int exitCode = 0;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
BOOL appendLineFeed = YES;
|
||||
int nextArgument = 1;
|
||||
|
||||
if (argv[1][0] == '-')
|
||||
{
|
||||
if (argv[1][1] == 'n')
|
||||
{
|
||||
appendLineFeed = NO;
|
||||
++nextArgument;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
|
||||
if (exitCode == 0)
|
||||
{
|
||||
CGFloat fontSize = 12;
|
||||
|
||||
NSString* fontName = [NSString stringWithUTF8String:argv[nextArgument++]];
|
||||
|
||||
if (argc > 2)
|
||||
fontSize = atof(argv[nextArgument]);
|
||||
|
||||
if (fontSize > 0.0)
|
||||
{
|
||||
NSFont* font = [NSFont fontWithName:fontName size:fontSize];
|
||||
|
||||
if (font)
|
||||
{
|
||||
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];
|
||||
NSRect box = [font boundingRectForFont];
|
||||
NSMutableString* result = [NSMutableString stringWithFormat:@"{\"familyName\": \"%@\", \"bold\": %@, \"italic\": %@, \"ascender\": %g, \"descender\": %g, \"lineHeight\": %g}",
|
||||
familyName,
|
||||
isBold ? @"true" : @"false", isItalic ? @"true" : @"false",
|
||||
ascender, descender, box.size.height];
|
||||
|
||||
if (appendLineFeed)
|
||||
[result appendString:@"\n"];
|
||||
|
||||
printf("%s", [result UTF8String]);
|
||||
|
||||
[familyName release];
|
||||
[font release];
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidFontName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
|
||||
[fontName release];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exitCode = kErrInvalidArguments;
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
return exitCode;
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
E1C392BC133D513B0092D7CA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1C392BB133D513B0092D7CA /* Cocoa.framework */; };
|
||||
E1D3CFAA12AFFB7F00CBB79E /* fontinfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* fontinfo.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
08FB7796FE84155DC02AAC07 /* fontinfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fontinfo.m; sourceTree = "<group>"; };
|
||||
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
32A70AAB03705E1F00C91783 /* fontinfo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fontinfo_Prefix.pch; sourceTree = "<group>"; };
|
||||
E11C89CC1277CECE0012609B /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
E18587D81279B93100FB6A47 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
|
||||
E1C392BB133D513B0092D7CA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
E1E20D0B12B09283005A6A64 /* fontinfo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fontinfo; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
E1D3CF6912AFEE3800CBB79E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E1C392BC133D513B0092D7CA /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
08FB7794FE84155DC02AAC07 /* font_info */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB7795FE84155DC02AAC07 /* Source */,
|
||||
E18587DD1279B93600FB6A47 /* Documentation */,
|
||||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */,
|
||||
);
|
||||
name = font_info;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
32A70AAB03705E1F00C91783 /* fontinfo_Prefix.pch */,
|
||||
08FB7796FE84155DC02AAC07 /* fontinfo.m */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB779EFE84155DC02AAC07 /* Foundation.framework */,
|
||||
E11C89CC1277CECE0012609B /* AppKit.framework */,
|
||||
E1C392BB133D513B0092D7CA /* Cocoa.framework */,
|
||||
);
|
||||
name = "External Frameworks and Libraries";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E1E20D0B12B09283005A6A64 /* fontinfo */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E18587DD1279B93600FB6A47 /* Documentation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E18587D81279B93100FB6A47 /* README */,
|
||||
);
|
||||
name = Documentation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
E1D3CF6A12AFEE3800CBB79E /* fontinfo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = E1D3CF6F12AFEE3B00CBB79E /* Build configuration list for PBXNativeTarget "fontinfo" */;
|
||||
buildPhases = (
|
||||
E1D3CF6812AFEE3800CBB79E /* Sources */,
|
||||
E1D3CF6912AFEE3800CBB79E /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = fontinfo;
|
||||
productName = font_info;
|
||||
productReference = E1E20D0B12B09283005A6A64 /* fontinfo */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "fontinfo" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 08FB7794FE84155DC02AAC07 /* font_info */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
E1D3CF6A12AFEE3800CBB79E /* fontinfo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
E1D3CF6812AFEE3800CBB79E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E1D3CFAA12AFFB7F00CBB79E /* fontinfo.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1DEB927908733DD40010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = fontinfo_Prefix.pch;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = fontinfo;
|
||||
SDKROOT = macosx10.5;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB927A08733DD40010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
DEPLOYMENT_LOCATION = NO;
|
||||
DEPLOYMENT_POSTPROCESSING = NO;
|
||||
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INSTALL_PATH = "";
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = fontinfo;
|
||||
SDKROOT = macosx10.5;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
E1D3CF6D12AFEE3900CBB79E /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
E1D3CF6E12AFEE3900CBB79E /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "fontinfo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB927908733DD40010E9CD /* Debug */,
|
||||
1DEB927A08733DD40010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
E1D3CF6F12AFEE3B00CBB79E /* Build configuration list for PBXNativeTarget "fontinfo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
E1D3CF6D12AFEE3900CBB79E /* Debug */,
|
||||
E1D3CF6E12AFEE3900CBB79E /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:fontinfo.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'font_info' target in the 'font_info' project.
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
@@ -23,7 +23,7 @@
|
||||
@import <AppKit/CPFont.j>
|
||||
|
||||
var OS = require("os"),
|
||||
fontinfo = require("fontinfo").fontinfo;
|
||||
fontinfo = require("cappuccino/fontinfo").fontinfo;
|
||||
|
||||
var IBDefaultFontFace = @"Lucida Grande",
|
||||
IBDefaultFontSize = 13.0;
|
||||
|
||||
Reference in New Issue
Block a user