资源简介
已经在ubuntu linux 11.04 上编译测试无问题
代码片段和文件信息
#!/usr/bin/python
# -*- coding: utf-8 -*-
‘‘‘
This script converts a bdf-font to a c-source-file containing
selected glyphs in the format defined by the header.
‘‘‘
# (C) 2010 by Christian Vogel
#
# All Rights Reserved
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not write to the Free Software Foundation Inc.
# 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA.
from optparse import OptionParser
import sys
import os
import string
def unique_name(thisnameexistingnames) :
# return first of thisname thisname_1 thisname_2 ...
# that does not yet exist in existingnames. This is used
# because somethings glyphs with non-unique names exist
# in fonts!
retname=thisname
N=1
while retname in existingnames :
N=N+1
retname=‘%s_%d‘%(thisnameN)
return retname
# return number N (for a character) optionally including
# the ascii character
def ascii_charnum(n) :
if n >= 32 and n < 127 :
if n != 34 : # “““ looks stupid
return ‘(%d ASCII “%s“)‘%(nchr(n))
else :
return ‘(%d ASCII \‘%s\‘)‘%(nchr(n))
return ‘(%d)‘%(n)
def is_zeroes(s) :
# check if list s consists entirely of “00“ strings
# (used to detect empty lines in fonts)
for x in s :
if s != ‘00‘ :
return False
return True
def byte_to_bits(x) :
# convert byte x to a string representing the bits #=1 .=0
# used for drawing pretty pictures in the comments of the
# generated C-file
ret = ‘‘
for i in range(8) :
if x & 1<<(7-i) :
ret = ret + ‘#‘
else :
ret = ret + ‘.‘
return ret
class BDF_Font(object) :
# this class stores a read-in bdf font
def __init__(selffilename) :
self.filename = filename
self.glyphs = dict()
self.enc = dict()
self.height = None
self.registry = None
self.encoding = None
self.ascent = 0
self.descent = 0
self.read_font(filename)
def add_header(selfdata) :
#print ‘Header data: ‘data
self.registry = data.get(‘charset_registry‘‘none‘)
self.encoding = data.get(‘charset_encoding‘‘unknown‘)
self.ascent = int(data[‘font_ascent‘])
self.descent = int(data[‘font_descent‘])
bbx = data[‘fontboundingbox‘].split(None3)
self.height = int(bbx[1])
def add_glyph(selfcharnamedatabitmap) :
chnum = int(data[‘encoding‘])
# print ‘add_glyph(%s) -> %s‘%(charnameascii_charnum(chnum))
self.enc[chnum] = charname
self.glyphs[charname] = data
self.glyphs[charname][‘bitmap‘]=bitmap
def read_font(selffilename) :
f = fi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 333 2014-11-07 15:15 osmocom-bb\.git\config
文件 73 2014-11-07 15:15 osmocom-bb\.git\desc
文件 2509 2014-11-07 15:15 osmocom-bb\.git\FETCH_HEAD
文件 28 2014-11-07 15:15 osmocom-bb\.git\HEAD
文件 452 2014-11-07 15:15 osmocom-bb\.git\hooks\applypatch-msg.sample
文件 896 2014-11-07 15:15 osmocom-bb\.git\hooks\commit-msg.sample
文件 160 2014-11-07 15:15 osmocom-bb\.git\hooks\post-commit.sample
文件 552 2014-11-07 15:15 osmocom-bb\.git\hooks\post-receive.sample
文件 189 2014-11-07 15:15 osmocom-bb\.git\hooks\post-update.sample
文件 398 2014-11-07 15:15 osmocom-bb\.git\hooks\pre-applypatch.sample
文件 1578 2014-11-07 15:15 osmocom-bb\.git\hooks\pre-commit.sample
文件 4971 2014-11-07 15:15 osmocom-bb\.git\hooks\pre-reba
文件 1239 2014-11-07 15:15 osmocom-bb\.git\hooks\prepare-commit-msg.sample
文件 3611 2014-11-07 15:15 osmocom-bb\.git\hooks\update.sample
文件 64808 2014-11-07 15:15 osmocom-bb\.git\index
文件 240 2014-11-07 15:15 osmocom-bb\.git\info\exclude
文件 343 2014-11-07 15:15 osmocom-bb\.git\logs\HEAD
文件 165 2014-11-07 15:15 osmocom-bb\.git\logs\refs\heads\luca\gsmmap
文件 174 2014-11-07 15:15 osmocom-bb\.git\logs\refs\heads\master
文件 555472 2014-11-07 15:15 osmocom-bb\.git\ob
文件 3558554 2014-11-07 15:15 osmocom-bb\.git\ob
文件 1798 2014-11-07 15:15 osmocom-bb\.git\packed-refs
文件 41 2014-11-07 15:15 osmocom-bb\.git\refs\heads\luca\gsmmap
文件 41 2014-11-07 15:15 osmocom-bb\.git\refs\heads\master
文件 32 2014-11-07 15:15 osmocom-bb\.git\refs\remotes\origin\HEAD
文件 35568 2014-11-07 15:15 osmocom-bb\doc\calypso-block.svg
文件 63 2014-11-07 15:15 osmocom-bb\doc\calypso-gsm-notes.txt
文件 4822 2014-11-07 15:15 osmocom-bb\doc\calypso-signals.txt
文件 37771 2014-11-07 15:15 osmocom-bb\doc\gsmdevboard-block.svg
文件 7162 2014-11-07 15:15 osmocom-bb\include\l1ctl_proto.h
............此处省略2465个文件信息
评论
共有 条评论