Nerd-fonts: Vertical offset

Created on 16 Jun 2016  ·  11Comments  ·  Source: ryanoasis/nerd-fonts

Vertical offset(font dropped down)

  • FuraMonoForPowerline Nerd Font
  • iTerm2 v3, neovim
  • OSX

image

and airline config

image

⚠ bug ❲⌖❳glyph positioning

Most helpful comment

I managed to tweak the output of font-patcher to fit my terminal. I used some helper scripts to preview all the characters. The script below relies on 1 zsh-specific feature. The feature is indexing the "$@" arguments as an array. I gave up figuring out how to do it in bash.

# Given a decimal number start and end print all unicode codepoint.
# If $3 is specified, it's used as the current column number.
function print-decimal-unicode-range() {
    local start="$1"
    local end="$2"
    local continuedCount="$3"
    local count="${continuedCount:-0}"
    # Use alternating colors to see which symbols extend out of the bounding
    # box.
    local bgColor='\x1b[48;2;54;11;0m'
    local alternateBgColor='\x1b[48;2;0;54;11m'
    local currentColor="${bgColor}"

    local allChars="${currentColor}"
    local wrapAt=25
    for decimalCode in $(seq "${start}" "${end}"); do
        local hexCode=$(printf '%x ' "${decimalCode}")
        allChars+="\u${hexCode} "
        count=$(( (count + 1) % $wrapAt))
        if [[ count -eq 0 ]]; then
            if [[ "${currentColor}" = "${alternateBgColor}" ]]; then
                currentColor="${bgColor}"
            else
                currentColor="${alternateBgColor}"
            fi
            allChars+="\n${currentColor}"
        fi
    done
    printf "${allChars}${reset_color}"
}

function print-unicode-ranges() {
    local count=0
    for ((i=1; i<=$#; i+=2)); do
        local start="$@[i]"
        local end="$@[i+1]"
        local startDecimal=$((16#$start))
        local endDecimal=$((16#$end))
        print-decimal-unicode-range "${startDecimal}" "${endDecimal}" "${count}"
        count=$(($count + $endDecimal - $startDecimal))
    done
}

function test-fonts() {
    echo "Nerd - Pomicons:"
    print-unicode-ranges e000 e00a
    echo; echo

    echo "Nerd - Powerline"
    print-unicode-ranges e0a0 e0a2 e0b0 e0b3
    echo; echo

    echo "Nerd - Powerline Extra"
    print-unicode-ranges e0a3 e0a3 e0b4 e0c8
    echo; echo

    echo "Nerd - Symbols original"
    print-unicode-ranges e5fa e62a
    echo; echo

    echo "Nerd - Devicons"
    print-unicode-ranges e700 e7c5
    echo; echo

    echo "Nerd - Font awesome"
    print-unicode-ranges f000 f295
    echo; echo

    echo "Nerd - Octicons"
    print-unicode-ranges f400 f4ae
    echo; echo

    echo "Nerd - Font Linux"
    print-unicode-ranges f300 f315
    echo

}

Then, I manually tweaked the font-patcher script to produce good results.

def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding=False):
    # Snip...

    for sym_glyph in symbolFont.selection.byGlyphs:

        # snip...

        if symbolFont.fontname == 'Pomicons':
            sourceFont.transform(psMat.scale(1.2))
            sourceFont.transform(psMat.translate(0, -490))
        elif symbolFont.fontname == 'PowerlineSymbols':
            sourceFont.transform(psMat.scale(1.8))
            sourceFont.transform(psMat.translate(0, -240))
        # Powerline extras
        elif symbolFont.fontname == 'DroidSansMonoForPowerlinePlusNerdFileTypesMono':
            sourceFont.transform(psMat.scale(0.83))
            sourceFont.transform(psMat.translate(0, -100))
        # set ui
        elif symbolFont.fontname == 'NerdFileTypes':
            sourceFont.transform(psMat.scale(0.9))
            sourceFont.transform(psMat.translate(0, -200))
        # devicons
        elif symbolFont.fontname == 'icomoon':
            sourceFont.transform(psMat.scale(1.2))
            sourceFont.transform(psMat.translate(0, -450))
        elif symbolFont.fontname == 'FontAwesome':
            sourceFont.transform(psMat.translate(0, -270))
        elif symbolFont.fontname == 'octicons':
            sourceFont.transform(psMat.translate(0, -200))
        elif symbolFont.fontname == 'font-linux':
            sourceFont.transform(psMat.translate(0, -300))
        else:
            pass

Then, I ran this script to quickly preview the results in a new terminal

cd nerd-font
./font-patcher --quiet --fontawesome --fontlinux --octicons --pomicons --powerline --powerlineextra --outputdir ~/.dotfiles/fonts ~/.dotfiles/fonts/consola.ttf && ~/.dotfiles/fonts/install.sh && st zsh -c '. ~/.zshrc; test-fonts; $SHELL'

All 11 comments

Ouch, thanks I'll try to look into this

@ryanoasis thanks for check this, if you want more info, ping me :)

I managed to tweak the output of font-patcher to fit my terminal. I used some helper scripts to preview all the characters. The script below relies on 1 zsh-specific feature. The feature is indexing the "$@" arguments as an array. I gave up figuring out how to do it in bash.

# Given a decimal number start and end print all unicode codepoint.
# If $3 is specified, it's used as the current column number.
function print-decimal-unicode-range() {
    local start="$1"
    local end="$2"
    local continuedCount="$3"
    local count="${continuedCount:-0}"
    # Use alternating colors to see which symbols extend out of the bounding
    # box.
    local bgColor='\x1b[48;2;54;11;0m'
    local alternateBgColor='\x1b[48;2;0;54;11m'
    local currentColor="${bgColor}"

    local allChars="${currentColor}"
    local wrapAt=25
    for decimalCode in $(seq "${start}" "${end}"); do
        local hexCode=$(printf '%x ' "${decimalCode}")
        allChars+="\u${hexCode} "
        count=$(( (count + 1) % $wrapAt))
        if [[ count -eq 0 ]]; then
            if [[ "${currentColor}" = "${alternateBgColor}" ]]; then
                currentColor="${bgColor}"
            else
                currentColor="${alternateBgColor}"
            fi
            allChars+="\n${currentColor}"
        fi
    done
    printf "${allChars}${reset_color}"
}

function print-unicode-ranges() {
    local count=0
    for ((i=1; i<=$#; i+=2)); do
        local start="$@[i]"
        local end="$@[i+1]"
        local startDecimal=$((16#$start))
        local endDecimal=$((16#$end))
        print-decimal-unicode-range "${startDecimal}" "${endDecimal}" "${count}"
        count=$(($count + $endDecimal - $startDecimal))
    done
}

function test-fonts() {
    echo "Nerd - Pomicons:"
    print-unicode-ranges e000 e00a
    echo; echo

    echo "Nerd - Powerline"
    print-unicode-ranges e0a0 e0a2 e0b0 e0b3
    echo; echo

    echo "Nerd - Powerline Extra"
    print-unicode-ranges e0a3 e0a3 e0b4 e0c8
    echo; echo

    echo "Nerd - Symbols original"
    print-unicode-ranges e5fa e62a
    echo; echo

    echo "Nerd - Devicons"
    print-unicode-ranges e700 e7c5
    echo; echo

    echo "Nerd - Font awesome"
    print-unicode-ranges f000 f295
    echo; echo

    echo "Nerd - Octicons"
    print-unicode-ranges f400 f4ae
    echo; echo

    echo "Nerd - Font Linux"
    print-unicode-ranges f300 f315
    echo

}

Then, I manually tweaked the font-patcher script to produce good results.

def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFontStart, symbolFontEnd, exactEncoding=False):
    # Snip...

    for sym_glyph in symbolFont.selection.byGlyphs:

        # snip...

        if symbolFont.fontname == 'Pomicons':
            sourceFont.transform(psMat.scale(1.2))
            sourceFont.transform(psMat.translate(0, -490))
        elif symbolFont.fontname == 'PowerlineSymbols':
            sourceFont.transform(psMat.scale(1.8))
            sourceFont.transform(psMat.translate(0, -240))
        # Powerline extras
        elif symbolFont.fontname == 'DroidSansMonoForPowerlinePlusNerdFileTypesMono':
            sourceFont.transform(psMat.scale(0.83))
            sourceFont.transform(psMat.translate(0, -100))
        # set ui
        elif symbolFont.fontname == 'NerdFileTypes':
            sourceFont.transform(psMat.scale(0.9))
            sourceFont.transform(psMat.translate(0, -200))
        # devicons
        elif symbolFont.fontname == 'icomoon':
            sourceFont.transform(psMat.scale(1.2))
            sourceFont.transform(psMat.translate(0, -450))
        elif symbolFont.fontname == 'FontAwesome':
            sourceFont.transform(psMat.translate(0, -270))
        elif symbolFont.fontname == 'octicons':
            sourceFont.transform(psMat.translate(0, -200))
        elif symbolFont.fontname == 'font-linux':
            sourceFont.transform(psMat.translate(0, -300))
        else:
            pass

Then, I ran this script to quickly preview the results in a new terminal

cd nerd-font
./font-patcher --quiet --fontawesome --fontlinux --octicons --pomicons --powerline --powerlineextra --outputdir ~/.dotfiles/fonts ~/.dotfiles/fonts/consola.ttf && ~/.dotfiles/fonts/install.sh && st zsh -c '. ~/.zshrc; test-fonts; $SHELL'

Hey good stuff. Sorry I haven't replied until now. This is clever and helpful. I particularly want to steal the print ranges for testing 😄

@lisposter Please try the fonts in 0.9.0 branch if you don't mind. Thanks

@jschaf I would love to use what you have or at least the general idea to build some scripts that help with testing the fonts :smile:

Sure, the script should "just work" if you have zsh. Once you source it, test-fonts should print everything. I think automated testing would be hard.

The script at the end just builds the project and then opens up a new terminal-emulator (st for me), sources the startup up script for zsh and runs test-fonts.

@jschaf Yeah I agree fully automated would be hard but having some test scripts like this would help a lot for testing :smile:

By the way I took your script and updated it with the latest changes in 0.9.0 and also I made changes to get it to work with straight bash :smile:

Would you like to submit your current version as a PR to get proper contribution? If not I will reference you in the release notes and in the script as an author if you want. Let me know.

Thanks again.

Glad you it found useful! Don't worry about a PR, go with your working version.

@lisposter any chance you'd be willing to test this out again to see if the issue is solved for you? :smile:

@ryanoasis sorry for the late, thank you for your effort. seems better. 😄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fornwall picture fornwall  ·  5Comments

parkerbxyz picture parkerbxyz  ·  4Comments

logarytm picture logarytm  ·  5Comments

audioscavenger picture audioscavenger  ·  3Comments

Scrumplex picture Scrumplex  ·  3Comments