Skip to content

Merge FontAwesome with any other font

Arturs Jansons edited this page Feb 16, 2015 · 2 revisions

It is possible to merge FontAwesome to any other font, because all characters belongs to unicode-range="U+0020-F500 - which is different cells neither popular chars at other fonts.

First of all You need to install FontForge opensource programm. As described on http://fontforge.github.io/scripting.html#Example - use following command sfddiff.sh FontAwesome.sfd --merge FontAwesome.sfd to merge two font files together.

#!/usr/local/bin/fontforge
#This is the sfddiff script which compares two fonts

if ( Strtol($version) < 20060330 )
  Error( "Please upgrade to a more recent version of fontforge" )
endif

flags=0x789
outfile=""

while ( $argc > 1 && Strsub($1,0,1)=="-" )
  temp = $1
  if ( Strsub(temp,1,2)=='-' )
    temp = Strsub(temp,1)
  endif

  if ( temp=="-ignorehints" )
    flags = flags & ~0x8
  elseif ( temp=="-ignorenames" )
    flags = flags & ~0x100
  elseif ( temp=="-ignoregpos" )
    flags = flags & ~0x200
  elseif ( temp=="-ignoregsub" )
    flags = flags & ~0x400
  elseif ( temp=="-ignorebitmaps" )
    flags = flags & ~0x80
  elseif ( temp=="-exact" )
    flags = flags | 0x2
  elseif ( temp=="-warn" )
    flags = flags | 0x44
  elseif ( temp=="-merge" )
    flags = flags | 0x1800
    shift
    outfile = $1
  elseif ( temp=="-help" )
    Print( "sfddiff: [--version] [--help] [--usage] [--ignorehints] [--ignorenames] [--ignoregpos] [--ignoregsup] [--ignorebitmaps] [--warn] [--exact] fontfile1 fontfile2" )
    Print( " Compares two fontfiles" )
    Print( " --ignorehints: Do not compare postscript hints or truetype instructions" )
    Print( " --ignorenames: Do not compare font names" )
    Print( " --ignoregpos:  Do not compare kerning, etc." )
    Print( " --ignoregsub:  Do not compare ligatures, etc." )
    Print( " --ignorebitmaps: Do not compare bitmap strikes" )
    Print( " --exact:       Normally sfddiff will match contours which are not exact" )
    Print( "                but where the differences are slight (so you could compare" )
    Print( "                truetype and postscript and get reasonable answers). Also" )
    Print( "                normally sfddiff will unlink references before it compares" )
    Print( "                (so you can compare a postscript font (with no references)" )
    Print( "                to the original source (which does have references)). Setting")
    Print( "                this flag means glyphs must match exactly.")
    Print( " --warn:        Provides a warning when an exact match is not found" )
    Print( " --merge outfile: Put any outline differences in the backgrounds of" )
    Print( "                appropriate glyphs" )
return(0)
  elseif ( temp=="-version" )
    Print( "Version 1.0" )
return(0)
  else
break
  endif
  shift
endloop

if ( $argc!=3 || $1=="--usage" || $1=="-usage" )
  Print( "sfddiff: [--version] [--help] [--usage] [--ignorehints] [--ignorenames] [--ignoregpos] [--ignoregsup] [--ignorebitmaps] [--warn] [--exact] [--merge outfile] fontfile1 fontfile2" )
return(0)
endif

Open($2)
Open($1)
CompareFonts($2,"-",flags)
if ( outfile!="" )
  Save(outfile)
endif

https://github.com/FortAwesome/Font-Awesome/issues/4339