MCPcopy Index your code
hub / github.com/clips/pattern / getdict

Function getdict

pattern/web/pdf/pdffont.py:120–159  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

118##
119NIBBLES = ('0','1','2','3','4','5','6','7','8','9','.','e','e-',None,'-')
120def getdict(data):
121 d = {}
122 fp = StringIO(data)
123 stack = []
124 while 1:
125 c = fp.read(1)
126 if not c: break
127 b0 = ord(c)
128 if b0 <= 21:
129 d[b0] = stack
130 stack = []
131 continue
132 if b0 == 30:
133 s = ''
134 loop = True
135 while loop:
136 b = ord(fp.read(1))
137 for n in (b >> 4, b & 15):
138 if n == 15:
139 loop = False
140 else:
141 s += NIBBLES[n]
142 value = float(s)
143 elif 32 <= b0 and b0 <= 246:
144 value = b0-139
145 else:
146 b1 = ord(fp.read(1))
147 if 247 <= b0 and b0 <= 250:
148 value = ((b0-247)<<8)+b1+108
149 elif 251 <= b0 and b0 <= 254:
150 value = -((b0-251)<<8)-b1-108
151 else:
152 b2 = ord(fp.read(1))
153 if 128 <= b1: b1 -= 256
154 if b0 == 28:
155 value = b1<<8 | b2
156 else:
157 value = b1<<24 | b2<<16 | struct.unpack('>H', fp.read(2))[0]
158 stack.append(value)
159 return d
160
161class CFFFont(object):
162

Callers 1

__init__Method · 0.85

Calls 2

readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…