分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

fontTools.ttLib.html

发布时间:2023-09-06 02:33责任编辑:林大明关键词:暂无标签
Package Contents
__init__-- fontTools.ttLib -- a package for dealing with TrueType fonts.
macUtils
sfnt-- ttLib/sfnt.py -- low-level module to deal with the sfnt file format.
standardGlyphOrder
tables(package)
test(package)
xmlImport

Classes
Exception(BaseException)
TTLibError
GlyphOrder
TTFont
_TTGlyph
_TTGlyphSet

classGlyphOrder
Apseudotable.Theglyphorderisn‘tinthefontasaseparate
table,butit‘snicetopresentitassuchintheTTXformat.
Methods defined here:
__init__(self, tag)
fromXML(self, (name, attrs, content), ttFont)
toXML(self, writer, ttFont)

classTTFont
Themainfontobject.Itmanagesfileinputandoutput,andoffers
aconvenientwayofaccessingtables.
Tableswillbeonlydecompiledwhenneccesary,ie.whenthey‘reactually
accessed.Thismeansthatsimpleoperationscanbeextremelyfast.
Methods defined here:
__contains__=has_key(self, tag)
__delitem__(self, tag)
__getitem__(self, tag)
__init__(self, file=None, res_name_or_index=None, sfntVersion=‘\x00\x01\x00\x00‘, checkChecksums=0, verbose=0, recalcBBoxes=1, allowVID=0, ignoreDecompileErrors=False)
Theconstructorcanbecalledwithafewdifferentarguments.
Whenreadingafontfromdisk,‘file‘shouldbeeitherapathname
pointingtoafile,orareadablefileobject.

Itwe‘rerunningonaMacintosh,‘res_name_or_index‘maybeansfnt
resourcenameoransfntresourceindexnumberorzero.Thelatter
casewillcauseTTLibtoautodetectwhetherthefileisaflatfile
orasuitcase.(Ifit‘sasuitcase,onlythefirst‘sfnt‘resource
willberead!)

The‘checkChecksums‘argumentisusedtospecifyhowsfnt
checksumsaretreateduponreadingafilefromdisk:
0:don‘tcheck(default)
1:check,printwarningsifawrongchecksumisfound
2:check,raiseanexceptionifawrongchecksumisfound.

TheTTFontconstructorcanalsobecalledwithouta‘file‘
argument:thisisthewaytocreateanewemptyfont.
Inthiscaseyoucanoptionallysupplythe‘sfntVersion‘argument.

IftherecalcBBoxesargumentisfalse,anumberofthingswill*not*
berecalculateduponsave/compile:
1)glyphboundingboxes
2)maxpfontboundingbox
3)hheamin/maxvalues
(1)isneededforcertainkindsofCJKfonts(askWernerLemberg;-).
Additionally,uponimportinganTTXfile,thisoptioncauseglyphs
tobecompiledrightaway.Thisshouldreducememoryconsumption
greatly,andthereforeshouldhavesomeimpactonthetimeneeded
toparse/compilelargefonts.

IftheallowVIDargumentissettotrue,thenvirtualGID‘sare
supported.AskingforaglyphIDwithaglyphnameorGIDthatisnotin
thefontwillreturnavirtualGID.ThisisvalidforGSUBandcmap
tables.ForSINGglyphlets,thecmaptableisusedtospecifyUnicode
valuesforvirtualGI‘susedinGSUB/GPOSrules.IfthegidNisrequested
anddoesnotexistinthefont,ortheglyphnamehastheformglyphN
anddoesnotexistinthefont,thenNisusedasthevirtualGID.
Else,thefirstvirtualGIDisassignedas0x1000-1;forsubsequentnew
virtualGIDs,thenextisonelessthantheprevious.

IfignoreDecompileErrorsissettoTrue,exceptionsraisedin
individualtablesduringdecompilationwillbeignored,falling
backtotheDefaultTableimplementation,whichsimplykeepsthe
binarydata.
__len__(self)
__setitem__(self, tag, table)
close(self)
Ifwestillhaveareaderobject,closeit.
getGlyphID(self, glyphName, requireReal=0)
getGlyphName(self, glyphID, requireReal=0)
getGlyphNames(self)
Getalistofglyphnames,sortedalphabetically.
getGlyphNames2(self)
Getalistofglyphnames,sortedalphabetically,
butnotcasesensitive.
getGlyphOrder(self)
getGlyphSet(self, preferCFF=1)
ReturnagenericGlyphSet,whichisadict-likeobject
mappingglyphnamestoglyphobjects.Thereturnedglyphobjects
havea.draw()methodthatsupportsthePenprotocol,andwill
haveanattributenamed‘width‘,butonly*after*the.draw()method
hasbeencalled.

IfthefontisCFF-based,theoutlineswillbetakenfromthe‘CFF‘
table.Otherwisetheoutlineswillbetakenfromthe‘glyf‘table.
Ifthefontcontainsbotha‘CFF‘anda‘glyf‘table,youcanuse
the‘preferCFF‘argumenttospecifywhichoneshouldbetaken.
getReverseGlyphMap(self, rebuild=0)
getTableData(self, tag)
Returnsrawtabledata,whethercompiledordirectlyreadfromdisk.
has_key(self, tag)
importXML(self, file, progress=None)
ImportaTTXfile(anXML-basedtextformat),soastorecreate
afontobject.
isLoaded(self, tag)
Returntrueifthetableidentifiedby‘tag‘hasbeen
decompiledandloadedintomemory.
keys(self)
save(self, file, makeSuitcase=0, reorderTables=1)
Savethefonttodisk.Similarlytotheconstructor,
the‘file‘argumentcanbeeitherapathnameorawritable
fileobject.

OntheMac,ifmakeSuitcaseistrue,asuitcase(resourcefork)
filewillwemadeinsteadofaflat.ttffile.
saveXML(self, fileOrPath, progress=None, tables=None, skipTables=None, splitTables=0, disassembleInstructions=1)
ExportthefontasTTX(anXML-basedtextfile),orasaseriesoftext
fileswhensplitTablesistrue.Inthelattercase,the‘fileOrPath‘
argumentshouldbeapathtoadirectory.
The‘tables‘argumentmusteitherbefalse(dumpalltables)ora
listoftablestodump.The‘skipTables‘argumentmaybealistoftables
toskip,butonlywhenthe‘tables‘argumentisfalse.
setGlyphOrder(self, glyphOrder)

classTTLibError(Exception)
Method resolution order:
TTLibError
Exception
BaseException
object

Data descriptors defined here:
__weakref__
listofweakreferencestotheobject(ifdefined)

Methods inherited fromException:
__init__(...)
x.__init__(...)initializesx;seex.__class__.__doc__forsignature

Data and other attributes inherited fromException:
__new__= <built-in method __new__ of type object at 0x8108c0>
T.__new__(S,...)->anewobjectwithtypeS,asubtypeofT

Methods inherited fromBaseException:
__delattr__(...)
x.__delattr__(‘name‘)<==>delx.name
__getattribute__(...)
x.__getattribute__(‘name‘)<==>x.name
__getitem__(...)
x.__getitem__(y)<==>x[y]
__getslice__(...)
x.__getslice__(i,j)<==>x[i:j]

Useofnegativeindicesisnotsupported.
__reduce__(...)
__repr__(...)
x.__repr__()<==>repr(x)
__setattr__(...)
x.__setattr__(‘name‘,value)<==>x.name=value
__setstate__(...)
__str__(...)
x.__str__()<==>str(x)
__unicode__(...)

Data descriptors inherited fromBaseException:
__dict__
args
message

class_TTGlyph
WrapperforaTrueTypeglyphthatsupportsthePenprotocol,meaning
thatithasa.draw()methodthattakesapenobjectasitsonly
argument.Additionallythereisa‘width‘attribute.
Methods defined here:
__init__(self, glyphName, ttFont)
draw(self, pen)
DrawtheglyphontoPen.SeefontTools.pens.basePenfordetails
howthatworks.

class_TTGlyphSet
Genericdict-likeGlyphSetclass,meantasaTrueTypecounterpart
toCFF‘sCharStringdict.SeeTTFont.getGlyphSet().
Methods defined here:
__contains__=has_key(self, glyphName)
__getitem__(self, glyphName)
__init__(self, ttFont)
get(self, glyphName, default=None)
has_key(self, glyphName)
keys(self)

Functions
_escapechar(c)
HelperfunctionfortagToIdentifier()
debugmsg(msg)
getTableClass(tag)
Fetchthepacker/unpackerclassforatable.
ReturnNonewhennoclassisfound.
getTableModule(tag)
Fetchthepacker/unpackermoduleforatable.
ReturnNonewhennomoduleisfound.
identifierToTag(ident)
theoppositeoftagToIdentifier()
newTable(tag)
Returnanewinstanceofatable.
reorderFontTables(inFile, outFile, tableOrder=None, checkChecksums=0)
Rewriteafontfile,orderingthetablesasrecommendedbythe
OpenTypespecification1.4.
sortedTagList(tagList, tableOrder=None)
ReturnasortedcopyoftagList,sortedaccordingtotheOpenType
specification,oraccordingtoacustomtableOrder.Ifgivenandnot
None,tableOrderneedstobealistoftagnames.
tagToIdentifier(tag)
Convertatabletagtoavalid(butUGLY)pythonidentifier,
aswellasafilenamethat‘sguaranteedtobeuniqueevenona
caselessfilesystem.Eachcharacterismappedtotwocharacters.
Lowercaselettersgetanunderscorebeforetheletter,uppercase
lettersgetanunderscoreaftertheletter.Trailingspacesare
trimmed.Illegalcharactersareescapedastwohexbytes.Ifthe
resultstartswithanumber(astheresultofahexescape),an
extraunderscoreisprepended.Examples:
‘glyf‘->‘_g_l_y_f‘
‘cvt‘->‘_c_v_t‘
‘OS/2‘->‘O_S_2f_2‘
tagToXML(tag)
SimilarlytotagToIdentifier(),thisconvertsaTTtag
toavalidXMLelementname.SinceXMLelementnamesare
casesensitive,thisisafairlysimple/readabletranslation.
xmlToTag(tag)
TheoppositeoftagToXML()

Data
OTFTableOrder= [‘head‘, ‘hhea‘, ‘maxp‘, ‘OS/2‘, ‘name‘, ‘cmap‘, ‘post‘, ‘CFF ‘]
TTFTableOrder= [‘head‘, ‘hhea‘, ‘maxp‘, ‘OS/2‘, ‘hmtx‘, ‘LTSH‘, ‘VDMX‘, ‘hdmx‘, ‘cmap‘, ‘fpgm‘, ‘prep‘, ‘cvt ‘, ‘loca‘, ‘glyf‘, ‘kern‘, ‘name‘, ‘post‘, ‘gasp‘, ‘PCLT‘]
__file__= ‘/home/mcfletch/pylive/fontTools/ttLib/__init__.pyc‘
__name__= ‘fontTools.ttLib‘
__package__= ‘fontTools.ttLib‘
__path__= [‘/home/mcfletch/pylive/fontTools/ttLib‘]
haveMacSupport= 0

fontTools.ttLib.html

原文地址:https://www.cnblogs.com/supremetech/p/10406365.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved