mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-11-19 16:39:20 +02:00
Fixes wrong unicode codepoints for Font Awesome glyphs (fixes #31)
* if conflict between Font Awesome and Octicons, Font Awesome takes presedence in positioning
This commit is contained in:
parent
d5a992a59a
commit
9620d47aed
36
font-patcher
36
font-patcher
@ -133,11 +133,17 @@ if args.fontawesome:
|
||||
if args.octicons:
|
||||
octicons = fontforge.open("glyph-source-fonts/octicons.ttf")
|
||||
octicons.em = sourceFont.em
|
||||
octiconsExactEncodingPosition = True
|
||||
|
||||
if args.pomicons:
|
||||
pomicons = fontforge.open("glyph-source-fonts/Pomicons.otf")
|
||||
pomicons.em = sourceFont.em
|
||||
|
||||
# Prevent glyph encoding position conflicts between glyph sets
|
||||
|
||||
if args.fontawesome and args.octicons:
|
||||
octiconsExactEncodingPosition = False
|
||||
|
||||
# Define the character ranges
|
||||
|
||||
# Symbol font ranges
|
||||
@ -248,13 +254,15 @@ def get_dim(glyph):
|
||||
'height': bbox[3] + (-bbox[1]),
|
||||
}
|
||||
|
||||
def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd):
|
||||
|
||||
sourceFontList = []
|
||||
sourceFontCounter = 0
|
||||
def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding=False):
|
||||
|
||||
for i in xrange(sourceFontStart, sourceFontEnd + 1):
|
||||
sourceFontList.append(format(i, 'X'))
|
||||
if exactEncoding is False:
|
||||
sourceFontList = []
|
||||
sourceFontCounter = 0
|
||||
|
||||
for i in xrange(sourceFontStart, sourceFontEnd + 1):
|
||||
sourceFontList.append(format(i, 'X'))
|
||||
|
||||
# Create glyphs from symbol font
|
||||
|
||||
@ -265,8 +273,14 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
|
||||
#sym_attr = SYM_ATTR[sym_glyph.unicode]
|
||||
if args.quiet == False:
|
||||
print "updating glyph: " + str(sym_glyph)
|
||||
# convince that this string really is a hex:
|
||||
currentSourceFontGlyph = int("0x" + sourceFontList[sourceFontCounter], 16)
|
||||
|
||||
if exactEncoding:
|
||||
# use the exact same hex values for the source font as for the symbol font
|
||||
currentSourceFontGlyph = sym_glyph.encoding
|
||||
else:
|
||||
# use source font defined hex values based on passed in start and end
|
||||
# convince that this string really is a hex:
|
||||
currentSourceFontGlyph = int("0x" + sourceFontList[sourceFontCounter], 16)
|
||||
|
||||
# Prepare symbol glyph dimensions
|
||||
sym_dim = get_dim(sym_glyph)
|
||||
@ -345,7 +359,9 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
|
||||
# Ensure the font is considered monospaced on Windows
|
||||
sourceFont[currentSourceFontGlyph].width = font_dim['width']
|
||||
|
||||
sourceFontCounter += 1
|
||||
if exactEncoding is False:
|
||||
sourceFontCounter += 1
|
||||
|
||||
# reset selection so iteration works propertly @todo fix? rookie misunderstanding?
|
||||
symbolFont.selection.select(("ranges","unicode"),symbolFontStart,symbolFontEnd)
|
||||
# end for
|
||||
@ -361,10 +377,10 @@ if args.powerline:
|
||||
|
||||
|
||||
if args.fontawesome:
|
||||
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd)
|
||||
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd, True)
|
||||
|
||||
if args.octicons:
|
||||
copy_glyphs(sourceFont, sourceFontOcticonsStart, sourceFontOcticonsEnd, octicons, symbolsOcticonsRangeStart, symbolsOcticonsRangeEnd)
|
||||
copy_glyphs(sourceFont, sourceFontOcticonsStart, sourceFontOcticonsEnd, octicons, symbolsOcticonsRangeStart, symbolsOcticonsRangeEnd, octiconsExactEncodingPosition)
|
||||
|
||||
if args.pomicons:
|
||||
copy_glyphs(sourceFont, sourceFontPomiconsStart, sourceFontPomiconsEnd, pomicons, symbolsPomiconsRangeStart, symbolsPomiconsRangeEnd)
|
||||
|
Loading…
Reference in New Issue
Block a user