• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            runsisi

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              45 隨筆 :: 15 文章 :: 26 評(píng)論 :: 0 Trackbacks

            Powerline字體補(bǔ)丁

            runsisi AT hust

             @2013/05/03

            接上一篇。

             

            使用spf13vim插件,如果當(dāng)前系統(tǒng)的vim支持python的話,會(huì)安裝 powerline插件,如果不支持的話則會(huì)安裝vim-powerlinepowerline相當(dāng)于vim-powerline的升級(jí)版,后者的效果可以參看上一篇,前者的效果可以看下圖:


            看的出powerlinevim-power的效果要炫的多,但是使用powerline的話需要對終端使用的字體打補(bǔ)丁,不然會(huì)顯示亂碼(當(dāng)然亂碼的原因也可能是終端編碼設(shè)置不對,這里只考慮字體的原因)。

            使用gnome-terminalkonsolelinux原生的終端也可以不給使用的字體打補(bǔ)丁,具體可以參考官方的文檔,但如果使用puttysecurecrt等遠(yuǎn)程終端工具的話必須打補(bǔ)丁。

             

            Powerline插件自帶了補(bǔ)丁工具,如果直接使用spf13的腳本安裝的powerline插件,該工具在spf13-vim/.vim/bundle/powerline/font文件夾下:fontpatcher.py

            使用類似下面的命令,就可以給consola.ttf字體打補(bǔ)丁:

            ./fontpatcher.py consola.ttf

             

            我在使用該工具對consolas字體打補(bǔ)丁時(shí)遇到了一些問題:

            1.       The required FontForge modules could not be loaded.

            該工具依賴fontforge,但使用系統(tǒng)的包管理工具安裝了fontforge之后可能仍然出現(xiàn)該問題(至少在我的opensuse12.2 64bit下不能用),可以通過下載源碼重新編譯(configure時(shí)注意加上--enable-pyextension選項(xiàng));

            2.       雖然重新編譯、安裝了fontforge,執(zhí)行該工具時(shí)仍然可能出現(xiàn)1中的問題

            切換到fontforge源代碼目錄下的pyhook目錄,然后執(zhí)行python setup.py install安裝fontforgepython模塊(不知道為什么fontforgemakefile會(huì)缺這一步)

            3.         打了補(bǔ)丁的字體puttysecurecrt等工具不認(rèn)識(shí),在字體設(shè)置無法選擇打了補(bǔ)丁的字體,或者使用了打了補(bǔ)丁的字體后powerline插件顯示的仍然是亂碼

            Github上有打了補(bǔ)丁的consolas等字體,但都有這個(gè)問題,可能只適用于linux下的原生終端使用,在網(wǎng)上找到了一個(gè)該字體工具的補(bǔ)丁,但是是針對老版的vim-powerline的,和新版工具差異太大,已經(jīng)不能用了,參考它的思路,對新版的powerline字體工具打了個(gè)補(bǔ)丁如下:

            --- fontpatcher/old/fontpatcher.py    2013-05-03 23:23:11.788069924 +0800
            +++ fontpatcher/new/fontpatcher.py    2013-05-03 23:23:53.145073351 +0800
            @@ -22,14 +22,16 @@
             parser.add_argument('target_fonts', help='font files to patch', metavar='font', nargs='+', type=argparse.FileType('rb'))
             parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='store_false', dest='rename_font')
             parser.add_argument('--source-font', help='source symbol font', metavar='font', dest='source_font', default='{0}/fontpatcher-symbols.sfd'.format(sys.path[0]), type=argparse.FileType('rb'))
            +parser.add_argument('--fix-mono', help='fixes some mono-fonts which have glyphs of 0 widths', default=False, action='store_true', dest='fix_mono')
             args = parser.parse_args()
             
             
             class FontPatcher(object):
            -    def __init__(self, source_font, target_fonts, rename_font=True):
            +    def __init__(self, source_font, target_fonts, rename_font=True, fix_mono=False):
                     self.source_font = fontforge.open(source_font.name)
                     self.target_fonts = (fontforge.open(target_font.name) for target_font in target_fonts)
                     self.rename_font = rename_font
            +        self.fix_mono = fix_mono
             
                 def patch(self):
                     for target_font in self.target_fonts:
            @@ -40,10 +42,10 @@
             
                         # Rename font
                         if self.rename_font:
            -                target_font.familyname += ' for Powerline'
            -                target_font.fullname += ' for Powerline'
            +                target_font.familyname = 'Powerline ' + target_font.familyname
            +                target_font.fullname = 'Powerline ' + target_font.fullname
                             fontname, style = re.match("^([^-]*)(?:(-.*))?$", target_font.fontname).groups()
            -                target_font.fontname = fontname + 'ForPowerline'
            +                target_font.fontname = 'Powerline ' + fontname
                             if style is not None:
                                 target_font.fontname += style
                             target_font.appendSFNTName('English (US)''Preferred Family', target_font.familyname)
            @@ -102,6 +104,11 @@
                             # Reset the font's glyph width so it's still considered monospaced
                             target_font[source_glyph.unicode].width = target_font_width
             
            +            if self.fix_mono:
            +                for target_glyph in target_font.glyphs():
            +                    if target_glyph.width == 0:
            +                        target_glyph.width = target_font_width
            +
                         target_font.em = target_font_em_original
             
                         # Generate patched font
            @@ -111,5 +118,5 @@
                             extension = '.otf'
                         target_font.generate('{0}{1}'.format(target_font.fullname, extension))
             
            -fp = FontPatcher(args.source_font, args.target_fonts, args.rename_font)
            +fp = FontPatcher(args.source_font, args.target_fonts, args.rename_font, args.fix_mono)
             fp.patch()

            使用如下的命令對consola字體打補(bǔ)丁,然后安裝字體就可以在puttysecurecrt等工具中使用了:

            ./fontpatcher.py –fix-mono consola.ttf

             

            我在github上傳了一份打了補(bǔ)丁的consolas字體,下載之后可以直接使用:

            https://github.com/runsisi/consolas-font-for-powerline

             

            同時(shí)我也在github上上傳了一份打包好了的spf13插件,只需要解壓然后執(zhí)行./install.sh即可(注意要求vim7.3,且vim支持python):

            https://github.com/runsisi/a-ready-to-use-vimrc

            /Files/runsisi/powerline_fontpatcher.pdf
            /Files/runsisi/fontpatcher.rar
            /Files/runsisi/fontpatcher_diff.rar
            posted on 2013-05-04 00:32 runsisi 閱讀(7771) 評(píng)論(2)  編輯 收藏 引用

            評(píng)論

            # re: Powerline字體補(bǔ)丁 2014-07-19 16:58 Xana
            您好,請問您的FontForge怎么編譯的=。=我編譯的都快哭了  回復(fù)  更多評(píng)論
              

            # re: Powerline字體補(bǔ)丁 2014-08-12 19:53 runsisi
            @Xana
            我剛特意又編譯了一遍,沒任何問題啊,這回是在Centos 7.0上編譯的。如果缺什么包的話用包管理器搜索一下具體的軟件包名字,然后安裝一下就好了(注意如果是centos,fedora之類的系統(tǒng)選擇后綴為-devel的開發(fā)包,如果是ubuntu,linuxmint之類的系統(tǒng)選擇后綴為-dev的開發(fā)包)~  回復(fù)  更多評(píng)論
              


            只有注冊用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久www免费人成看国产片| 国产精品视频久久| 欧美久久一区二区三区| 久久久久久国产a免费观看黄色大片 | 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久这里只有精品首页| 国产精品久久网| 久久精品中文字幕一区| 夜夜亚洲天天久久| 欧美亚洲色综久久精品国产| 国产精品成人99久久久久 | 精品久久久久久无码人妻蜜桃| 久久久综合香蕉尹人综合网| 婷婷久久综合九色综合九七| 久久精品国产亚洲AV香蕉| 精品国产青草久久久久福利| 日韩精品国产自在久久现线拍| 久久久久香蕉视频| 亚洲一区中文字幕久久| 亚洲国产精品久久久久久| 久久99国产亚洲高清观看首页 | 精品久久人妻av中文字幕| 国产精品对白刺激久久久| 日韩精品久久久久久久电影蜜臀| 午夜精品久久久久久99热| 伊人久久综合无码成人网| 久久精品aⅴ无码中文字字幕重口| 人妻精品久久久久中文字幕69| 91精品国产综合久久精品| 久久99精品国产麻豆不卡| 精品久久久一二三区| 2021久久精品国产99国产精品| 亚洲成av人片不卡无码久久| 精品国际久久久久999波多野| 国产毛片久久久久久国产毛片 | 99久久精品国产麻豆| 伊人热热久久原色播放www| 成人国内精品久久久久一区| 久久人人爽人爽人人爽av| 国产精品一久久香蕉产线看| 久久人人爽人人爽人人片AV麻烦|