mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +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
1 changed files with 26 additions and 10 deletions
22
font-patcher
22
font-patcher
|
@ -133,11 +133,17 @@ if args.fontawesome:
|
||||||
if args.octicons:
|
if args.octicons:
|
||||||
octicons = fontforge.open("glyph-source-fonts/octicons.ttf")
|
octicons = fontforge.open("glyph-source-fonts/octicons.ttf")
|
||||||
octicons.em = sourceFont.em
|
octicons.em = sourceFont.em
|
||||||
|
octiconsExactEncodingPosition = True
|
||||||
|
|
||||||
if args.pomicons:
|
if args.pomicons:
|
||||||
pomicons = fontforge.open("glyph-source-fonts/Pomicons.otf")
|
pomicons = fontforge.open("glyph-source-fonts/Pomicons.otf")
|
||||||
pomicons.em = sourceFont.em
|
pomicons.em = sourceFont.em
|
||||||
|
|
||||||
|
# Prevent glyph encoding position conflicts between glyph sets
|
||||||
|
|
||||||
|
if args.fontawesome and args.octicons:
|
||||||
|
octiconsExactEncodingPosition = False
|
||||||
|
|
||||||
# Define the character ranges
|
# Define the character ranges
|
||||||
|
|
||||||
# Symbol font ranges
|
# Symbol font ranges
|
||||||
|
@ -248,8 +254,10 @@ def get_dim(glyph):
|
||||||
'height': bbox[3] + (-bbox[1]),
|
'height': bbox[3] + (-bbox[1]),
|
||||||
}
|
}
|
||||||
|
|
||||||
def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd):
|
|
||||||
|
|
||||||
|
def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding=False):
|
||||||
|
|
||||||
|
if exactEncoding is False:
|
||||||
sourceFontList = []
|
sourceFontList = []
|
||||||
sourceFontCounter = 0
|
sourceFontCounter = 0
|
||||||
|
|
||||||
|
@ -265,6 +273,12 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
|
||||||
#sym_attr = SYM_ATTR[sym_glyph.unicode]
|
#sym_attr = SYM_ATTR[sym_glyph.unicode]
|
||||||
if args.quiet == False:
|
if args.quiet == False:
|
||||||
print "updating glyph: " + str(sym_glyph)
|
print "updating glyph: " + str(sym_glyph)
|
||||||
|
|
||||||
|
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:
|
# convince that this string really is a hex:
|
||||||
currentSourceFontGlyph = int("0x" + sourceFontList[sourceFontCounter], 16)
|
currentSourceFontGlyph = int("0x" + sourceFontList[sourceFontCounter], 16)
|
||||||
|
|
||||||
|
@ -345,7 +359,9 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
|
||||||
# Ensure the font is considered monospaced on Windows
|
# Ensure the font is considered monospaced on Windows
|
||||||
sourceFont[currentSourceFontGlyph].width = font_dim['width']
|
sourceFont[currentSourceFontGlyph].width = font_dim['width']
|
||||||
|
|
||||||
|
if exactEncoding is False:
|
||||||
sourceFontCounter += 1
|
sourceFontCounter += 1
|
||||||
|
|
||||||
# reset selection so iteration works propertly @todo fix? rookie misunderstanding?
|
# reset selection so iteration works propertly @todo fix? rookie misunderstanding?
|
||||||
symbolFont.selection.select(("ranges","unicode"),symbolFontStart,symbolFontEnd)
|
symbolFont.selection.select(("ranges","unicode"),symbolFontStart,symbolFontEnd)
|
||||||
# end for
|
# end for
|
||||||
|
@ -361,10 +377,10 @@ if args.powerline:
|
||||||
|
|
||||||
|
|
||||||
if args.fontawesome:
|
if args.fontawesome:
|
||||||
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd)
|
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd, True)
|
||||||
|
|
||||||
if args.octicons:
|
if args.octicons:
|
||||||
copy_glyphs(sourceFont, sourceFontOcticonsStart, sourceFontOcticonsEnd, octicons, symbolsOcticonsRangeStart, symbolsOcticonsRangeEnd)
|
copy_glyphs(sourceFont, sourceFontOcticonsStart, sourceFontOcticonsEnd, octicons, symbolsOcticonsRangeStart, symbolsOcticonsRangeEnd, octiconsExactEncodingPosition)
|
||||||
|
|
||||||
if args.pomicons:
|
if args.pomicons:
|
||||||
copy_glyphs(sourceFont, sourceFontPomiconsStart, sourceFontPomiconsEnd, pomicons, symbolsPomiconsRangeStart, symbolsPomiconsRangeEnd)
|
copy_glyphs(sourceFont, sourceFontPomiconsStart, sourceFontPomiconsEnd, pomicons, symbolsPomiconsRangeStart, symbolsPomiconsRangeEnd)
|
||||||
|
|
Loading…
Reference in a new issue