Permalink
Browse files

fixed issue which causes fontprep not to start on various systems, i.…

…e. don't load unused themes and use json gem over multi_json gem
  • Loading branch information...
briangonzalez committed Mar 18, 2014
1 parent 327c617 commit b9586a414ade4a9a5b633f238a54ccad7b54b091
View
@@ -1,7 +1,8 @@
fontprep/server/public/
-FontPrep.xcodeproj/project.xcworkspace/xcuserdata/
-FontPrep.xcodeproj/xcuserdata/
+FontPrep.xcodeproj/project.xcworkspace/xcuserdata
+FontPrep.xcodeproj/project.xcworkspace/xcshareddata
+FontPrep.xcodeproj/xcuserdata
.sass-cache
.DS_Store
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>3.1.0</string>
+ <string>3.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>3.1.0</string>
+ <string>3.1.1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
View
@@ -6,4 +6,4 @@
# Created by Brian M. Gonzalez on 6/11/13.
# Copyright (c) 2013 gnzlz. All rights reserved
-cd ../server && /usr/bin/ruby ./app.rb $1
+cd ../server && ruby ./app.rb $1
View
@@ -5,8 +5,8 @@
# Load in gems
####################################################
-Dir.glob(File.join(File.dirname(__FILE__), "vendor", "gems", "*","lib")).each do |lib|
- $LOAD_PATH.unshift File.expand_path(lib)
+Dir.glob(File.join(File.dirname(__FILE__), "vendor", "gems", "*","lib")).each do |lib|
+ $LOAD_PATH.unshift File.expand_path(lib)
end
####################################################
@@ -23,7 +23,7 @@
require 'sprockets-sass'
require 'sprockets-helpers'
require 'uglifier'
-require 'multi_json'
+require 'json'
Dir.glob('./application/**/*.rb') do |file|
require file
@@ -36,7 +36,6 @@
####################################################
FontPrep.initialize_app!
-FontPrep.themes
####################################################
# Main FontPrep Sinatra Class.
@@ -62,15 +61,15 @@ class FPApp < Sinatra::Base
set :javascripts, './application/assets/javascripts'
set :fonts, './application/assets/fonts'
set :logging, true
- set :static, true
+ set :static, true
set :haml, :format => :html5
set :port, ENV['PORT'] || 7500
app = YAML.load(File.read("app.yaml"))
set :app_values, app
before do
- cache_control 'no-cache'
+ cache_control 'no-cache'
end
get '/' do
@@ -103,17 +102,17 @@ class FPApp < Sinatra::Base
# Trap signals to invoke the shutdown procedure cleanly
['INT', 'TERM'].each { |signal|
- trap(signal){
- WEBRICK_HANDLER.shutdown
+ trap(signal){
+ WEBRICK_HANDLER.shutdown
exit!
- }
+ }
}
########################################################
# Use FontPrep Runner to conditionally run FontPrep.
########################################################
-FontPrepRunner.run do
+FontPrepRunner.run do
puts " [FONTPREP] Fontprep is now running on port #{FONTPREP_PORT}."
WEBRICK_HANDLER.run app, :Port => FONTPREP_PORT, :Host => "0.0.0.0"
exit!
@@ -19,36 +19,6 @@ def self.valid_license?(email, license)
true
end
- def self.themes
- themes = []
- Dir.glob('./application/assets/stylesheets/partials/themes/*.scss').each do |theme_file|
- name = File.basename(theme_file, ".scss")
- name.gsub!('_theme_', '')
- themes << name
- end
- themes
- end
-
- def self.set_theme(theme)
- begin
- FileUtils.rm_rf self.default_theme_path
- File.symlink self.theme_path(theme), self.default_theme_path
- FP::Database.set_setting( :theme, theme)
- rescue Exception => e
- FileUtils.rm_rf self.default_theme_path
- File.symlink self.theme_path('ember'), self.default_theme_path
- FP::Database.set_setting( :theme, 'ember')
- end
- end
-
- def self.default_theme_path
- File.join('application', 'assets', 'stylesheets', 'partials', '_variables_theme.scss')
- end
-
- def self.theme_path(name)
- "themes/_theme_#{name}.scss"
- end
-
def self.port
FONTPREP_PORT || 7500
end
@@ -8,7 +8,7 @@
GENERATED_PATH = File.join(APPLICATION_SUPPORT_PATH, 'generated')
DATABASE_PATH = File.join(APPLICATION_SUPPORT_PATH, 'db', 'db.yaml')
DATABASE_DIR = File.join(APPLICATION_SUPPORT_PATH, 'db')
-
+
FUSION_PATH = File.join('external', 'bin', 'fontforge')
TITO_PATH = File.join('external', 'bin', 'ttf2eot')
PYTHON_PATH = File.join('/', 'usr', 'bin', 'python')
@@ -18,7 +18,7 @@
CONVERT_SCRIPT_PATH = File.join('external', 'scripts', 'convert')
CHARS_SCRIPT_PATH = File.join('external', 'scripts', 'chars')
FAMILY_SCRIPT_PATH = File.join('external', 'scripts', 'family')
-WEBFONT_SCRIPT_PATH = File.join('external', 'scripts', 'webfont')
+WEBFONT_SCRIPT_PATH = File.join('external', 'scripts', 'webfont.pe')
NAME_SCRIPT_PATH = File.join('external', 'scripts', 'name')
SVGS_SCRIPT_PATH = File.join('external', 'scripts', 'svgs')
SUBSET_SCRIPT_PATH = File.join('external', 'scripts', 'subset')
@@ -56,7 +56,7 @@ def id
id = metadata[:id]
set_data(:id, Sinatra::AppHelpers.random) if not id
- @id = id
+ @id = id
end
def path
@@ -99,7 +99,7 @@ def autohinted_path
end
def name_normalized_path
- File.join(base, "#{name}-name-normlized.ttf")
+ File.join(base, "#{name}-name-normalized.ttf")
end
def woff_path
@@ -149,14 +149,14 @@ def otf?
def web_friendly?
File.exists?(web_friendly_path)
end
-
+
def woff?
File.exists?(woff_path)
end
def eot?
File.exists?(eot_path)
- end
+ end
def svg?
File.exists?(svg_path)
@@ -174,10 +174,10 @@ def average_size
return metadata[:avg_size] if metadata && metadata[:avg_size]
sizes = [0]
sizes << File.size(ttf_path) if ttf?
- sizes << File.size(otf_path) if otf?
+ sizes << File.size(otf_path) if otf?
sizes << File.size(woff_path) if woff?
- sizes << File.size(eot_path) if eot?
- sizes << File.size(svg_path) if svg?
+ sizes << File.size(eot_path) if eot?
+ sizes << File.size(svg_path) if svg?
avg_b = sizes.inject{ |sum, el| sum + el }.to_f / sizes.size
avg_size = avg_b/1024
set_data(:avg_size, avg_size)
@@ -202,10 +202,10 @@ def characters
def process!(except=[])
puts " ** Processing #{name}"
make_metadata unless metadata?
- make_ttf_clean
+ make_ttf_clean
make_ttf unless ttf?
make_otf unless otf?
- make_web_friendly!
+ make_web_friendly!
make_woff unless woff?
make_eot unless eot?
make_svg unless svg?
@@ -264,13 +264,13 @@ def subset!(selections=false)
script = File.read(SUBSET_SCRIPT_PATH)
# Assign unicode values to all glyphs.
- u = selections.map{ |c|
+ u = selections.map{ |c|
uni = "0x" + c.to_i.to_s(16)
[ "SelectIf(", uni, ");", "SetUnicodeValue(", uni, ");"].join('')
}.join("\n");
- # Add gylphs to selection.
- s = selections.map{ |c|
+ # Add gylphs to selection.
+ s = selections.map{ |c|
uni = "0x" + c.to_i.to_s(16)
[ "SelectMoreIf(", uni, ");" ].join('')
}.join("\n");
@@ -318,7 +318,7 @@ def make_svgs
def make_css
css = File.read(FONT_EXPORT_TEMPLATE_PATH)
-
+
css_family = FP::Database.data[:settings][:use_font_family] ? family : fontname
css.gsub!('[family]', css_family)
@@ -347,10 +347,10 @@ def write_metadata(data)
end
def base_metadata
- {
- :timestamp => Time.now().strftime('%A, %B %l, %Y'),
- :name => name,
- :id => id
+ {
+ :timestamp => Time.now().strftime('%A, %B %l, %Y'),
+ :name => name,
+ :id => id
}
end
@@ -367,7 +367,7 @@ def cleanup_afm
def destroy!
FileUtils.rm_rf( File.join(TRASH_PATH,rawname) ) if File.exists?(File.join(TRASH_PATH,rawname))
FileUtils.mv(path, TRASH_PATH, :force => true)
- end
+ end
def install!
path = ttf_clean? ? ttf_path_clean : ttf_path
@@ -376,24 +376,24 @@ def install!
def self.all
fonts = {}
- Dir.entries( GENERATED_PATH ).select do |dir|
- next if ['.', '..'].include?(dir)
- next if !File.directory?(File.join(GENERATED_PATH, dir))
+ Dir.entries( GENERATED_PATH ).select do |dir|
+ next if ['.', '..'].include?(dir)
+ next if !File.directory?(File.join(GENERATED_PATH, dir))
font = InstalledFont.new(dir)
next if !font.metadata?
fonts[font.id] = font
end
- fonts
+ fonts
end
def self.all_as_array
a = all.map{ |k,v| v }
a = a.sort{ |a,b|
b_name = b.display_name.downcase
a_name = a.display_name.downcase
- a_name <=> b_name
+ a_name <=> b_name
}
a
end
@@ -422,10 +422,10 @@ def blacklisted?
def with_path(dir, keep_ttf=true, keep_ttf_clean=false, &block)
make_ttf_clean unless ttf_clean?
old_base = base
- ttf = ttf_path
- ttf_c = ttf_path_clean
+ ttf = ttf_path
+ ttf_c = ttf_path_clean
- @base = dir
+ @base = dir
FileUtils.cp ttf, base
FileUtils.cp ttf_c, base
@@ -470,9 +470,9 @@ def style
@style = 'normal'
if normalized_name =~ /italic/ or normalized_fontname =~ /italic/
- @style = "italic"
+ @style = "italic"
elsif normalized_name =~ /oblique/ or normalized_fontname =~ /oblique/
- @style = "oblique"
+ @style = "oblique"
end
set_data(:style, @style)
@@ -1,50 +0,0 @@
-# webfonts.pe font-in.ttf font-out.ttf
-
-# Generates webfont-ready files as per http://goo.gl/0qowi
-# Author: Brian Zick <http://21326.info>
-# Version: 1
-# Date: 27 September 2011
-/*
-
-DESCRIPTION
- webfonts.pe saves a source file, cleans glyph outlines, coverts to tt outlines,
- and hints fonts before saving hinted and unhinted variants in both .sfd and .ttf.
- You may need to change the path variable in this script for your project;
- by default it is set to ../Release.
-
-BUGS
- Some functions are used twice in a row. This is because they
- (for some reason) did not work properly when used once.
-
- On my system, the generated *-TTF-hints.ttf has no hints? I don't know why.
- *-TTF-hints.sfd does, however, have hints. A workaround was found by
- Alexei Vanyashin <alexei.vanyashin@gmail.com>: split the script into two
- parts - one with hints, one without.
-
- I have not found a way to set "Really use Typo Metrics", and reportedly,
- fontforge doesn't export it to the TTF files anyway.
-
- It would be nice if fontforge could create a sub-folder for each version.
-
-TODO
- Options to enable or disable hinted/not hinted versions.
-*/
-
-Open($1)
-
-# Glyph cleanup
- SelectAll()
- UnlinkReference()
- RemoveOverlap()
- CorrectDirection()
- ScaleToEm(2048)
-
-# Convert splines to quadratic
- SetFontOrder(2)
- Simplify(128,2.05)
- Simplify(128,2.05)
- RoundToInt()
- RoundToInt()
-
-# Save.
-Generate($2)
Oops, something went wrong.

0 comments on commit b9586a4

Please sign in to comment.