Exemple #1
0
 def __init__(self, spec):
     firstchar = int_value(spec.get("FirstChar", 0))
     lastchar = int_value(spec.get("LastChar", 0))
     widths = list_value(spec.get("Widths", [0] * 256))
     widths = dict((i + firstchar, w) for (i, w) in enumerate(widths))
     if "FontDescriptor" in spec:
         descriptor = dict_value(spec["FontDescriptor"])
     else:
         descriptor = {"FontName": spec.get("Name"), "Ascent": 0, "Descent": 0, "FontBBox": spec["FontBBox"]}
     PDFSimpleFont.__init__(self, descriptor, widths, spec)
     return
Exemple #2
0
 def __init__(self, spec):
     try:
         self.basefont = literal_name(spec["BaseFont"])
     except KeyError:
         if STRICT:
             raise PDFFontError("BaseFont is missing")
         self.basefont = "unknown"
     try:
         (descriptor, widths) = FontMetricsDB.get_metrics(self.basefont)
     except KeyError:
         descriptor = dict_value(spec.get("FontDescriptor", {}))
         firstchar = int_value(spec.get("FirstChar", 0))
         lastchar = int_value(spec.get("LastChar", 255))
         widths = list_value(spec.get("Widths", [0] * 256))
         widths = dict((i + firstchar, w) for (i, w) in enumerate(widths))
     PDFSimpleFont.__init__(self, descriptor, widths, spec)
     return