Skip to content

Commit

Permalink
fixed issue which causes fontprep not to start on various systems, i.…
Browse files Browse the repository at this point in the history
…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 b9586a4
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 125 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions fontprep/FontPrep-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion fontprep/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 9 additions & 10 deletions fontprep/server/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

####################################################
Expand All @@ -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
Expand All @@ -36,7 +36,6 @@
####################################################

FontPrep.initialize_app!
FontPrep.themes

####################################################
# Main FontPrep Sinatra Class.
Expand All @@ -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
Expand Down Expand Up @@ -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!
Expand Down
30 changes: 0 additions & 30 deletions fontprep/server/application/lib/fontprep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fontprep/server/application/lib/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
56 changes: 28 additions & 28 deletions fontprep/server/application/lib/installed_font.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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?
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
50 changes: 0 additions & 50 deletions fontprep/server/external/scripts/webfont

This file was deleted.

Loading

0 comments on commit b9586a4

Please sign in to comment.