예제 #1
0
 def begin_text(self, text_type):
     self.in_text = 1
     self.text_type = text_type
     self.text_string = []
     if text_type == 1:
         self.add_message(_("Area text not supported"))
     if text_type == 2:
         GenericLoader.begin_group(self)
예제 #2
0
 def begin_text(self, text_type):
     self.in_text = 1
     self.text_type = text_type
     self.text_string = []
     if text_type == 1:
         self.add_message(_("Area text not supported"))
     if text_type == 2:
         GenericLoader.begin_group(self)
예제 #3
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     self.file = file
     self.curstyle = Style()
     self.verbosity = 0
     self.gdiobjects = []
     self.dcstack = []
     self.curpoint = Point(0, 0)
예제 #4
0
    def __init__(self, file, filename, match):
	GenericLoader.__init__(self, file, filename, match)
	self.file = file
	self.curstyle = Style()
	self.verbosity = 0
	self.gdiobjects = []
        self.dcstack = []
        self.curpoint = Point(0, 0)
예제 #5
0
 def bezier(self):
     if self.guess_continuity:
         self.path.guess_continuity()
     if self.path.len > 0:
         if self.compound_path is not None:
             self.compound_path.append(self.path)
         else:
             GenericLoader.bezier(self, paths=(self.path,))
     self.path = CreatePath()
예제 #6
0
 def bezier(self):
     if self.guess_continuity:
         self.path.guess_continuity()
     if self.path.len > 0:
         if self.compound_path is not None:
             self.compound_path.append(self.path)
         else:
             GenericLoader.bezier(self, paths=(self.path, ))
     self.path = CreatePath()
예제 #7
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     self.file = file
     self.verbosity = 15
     self.IntF = (self.i8, self.i16, self.i24, self.i32)
     self.CardF = (self.u8, self.u16, self.u24, self.u32)
     self.FloatF = (self.flp32, self.flp64)
     self.FixedF = (self.fip32, self.fip64)
     self.RealF = self.FixedF + self.FloatF
     self.VDCF = (self.IntF, self.RealF)
예제 #8
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     self.file = file
     self.verbosity = 15
     self.IntF = (self.i8, self.i16, self.i24, self.i32)
     self.CardF = (self.u8, self.u16, self.u24, self.u32)
     self.FloatF = (self.flp32, self.flp64)
     self.FixedF = (self.fip32, self.fip64)
     self.RealF = self.FixedF + self.FloatF
     self.VDCF = (self.IntF, self.RealF)
예제 #9
0
 def begin_group(self):
     if self.compound_path is None:
         # a normal group
         if self.treat_toplevel_groups_as_layers:
             if self.composite_class == Document:
                 self.begin_layer()
                 return
         GenericLoader.begin_group(self)
     else:
         # a `compound group'. Ignored since Sketch doesn't have this.
         pass
예제 #10
0
 def begin_group(self):
     if self.compound_path is None:
         # a normal group
         if self.treat_toplevel_groups_as_layers:
             if self.composite_class == Document:
                 self.begin_layer()
                 return
         GenericLoader.begin_group(self)
     else:
         # a `compound group'. Ignored since Sketch doesn't have this.
         pass
예제 #11
0
    def end_text(self):
        # we don't support area text (text_type 1) at all. Return
        # immediately in that case.
        if self.text_type == 1:
            return

        # first, turn the text accumulated in the list text_string into
        # a single string and unify line endings to newline characters.
        text = string.join(self.text_string, '')
        text = string.replace(text, '\r\n', '\n')
        text = string.replace(text, '\r', '\n')

        # remove a trailing newline. Many Illustrator files contain a
        # trailing newline as 'overflow' text, there's probably a better
        # way to deal with this...
        if text[-1:] == "\n":
            text = text[:-1]

        # Re-encode to Latin1
        text = self.text_font.Reencode(text)

        if not string.strip(text):
            if self.text_type == 2:
                self.end_composite()
                del self.composite_items[-1]
                if len(self.composite_items) > 0:
                    self.object = self.composite_items[-1]
            return

        # first create a simple text object
        self.fs()
        self.style.font = GetFont(self.text_font.psname)
        self.style.font_size = self.text_size
        self.simple_text(text,
                         self.text_trafo,
                         halign=_ai_text_align[self.text_align])

        # if we're actually supposed to create a path-text object, turn
        # the text object just created into a path-text object
        if self.text_type == 2:
            GenericLoader.end_group(self)
            group = self.pop_last()
            objects = group.GetObjects()
            if len(objects) == 2:
                path, text = objects
                self.append_object(
                    PathText(text, path, start_pos=self.text_start_pos))
                #self.composite_items[-1] = self.object

        # we've finished the text object
        self.in_text = 0
예제 #12
0
 def end_compound_path(self):
     paths = tuple(self.compound_path)
     self.compound_path = None
     if paths:
         # XXX ugly
         if self.gradient_geo:
             rect = paths[0].accurate_rect()
             for path in paths[1:]:
                 rect = UnionRects(rect, path.accurate_rect())
             self.gradient_rect = rect
         else:
             self.gradient_rect = None
         getattr(self, self.compound_render)()
         GenericLoader.bezier(self, paths=paths)
예제 #13
0
 def end_compound_path(self):
     paths = tuple(self.compound_path)
     self.compound_path = None
     if paths:
         # XXX ugly
         if self.gradient_geo:
             rect = paths[0].accurate_rect()
             for path in paths[1:]:
                 rect = UnionRects(rect, path.accurate_rect())
             self.gradient_rect = rect
         else:
             self.gradient_rect = None
         getattr(self, self.compound_render)()
         GenericLoader.bezier(self, paths=paths)
예제 #14
0
    def end_text(self):
        # we don't support area text (text_type 1) at all. Return
        # immediately in that case.
        if self.text_type == 1:
            return

        # first, turn the text accumulated in the list text_string into
        # a single string and unify line endings to newline characters.
        text = string.join(self.text_string, "")
        text = string.replace(text, "\r\n", "\n")
        text = string.replace(text, "\r", "\n")

        # remove a trailing newline. Many Illustrator files contain a
        # trailing newline as 'overflow' text, there's probably a better
        # way to deal with this...
        if text[-1:] == "\n":
            text = text[:-1]

        # Re-encode to Latin1
        text = self.text_font.Reencode(text)

        if not string.strip(text):
            if self.text_type == 2:
                self.end_composite()
                del self.composite_items[-1]
                if len(self.composite_items) > 0:
                    self.object = self.composite_items[-1]
            return

        # first create a simple text object
        self.fs()
        self.style.font = GetFont(self.text_font.psname)
        self.style.font_size = self.text_size
        self.simple_text(text, self.text_trafo, halign=_ai_text_align[self.text_align])

        # if we're actually supposed to create a path-text object, turn
        # the text object just created into a path-text object
        if self.text_type == 2:
            GenericLoader.end_group(self)
            group = self.pop_last()
            objects = group.GetObjects()
            if len(objects) == 2:
                path, text = objects
                self.append_object(PathText(text, path, start_pos=self.text_start_pos))
                # self.composite_items[-1] = self.object

        # we've finished the text object
        self.in_text = 0
예제 #15
0
    def __init__(self,
                 file,
                 filename,
                 match,
                 treat_toplevel_groups_as_layers=1,
                 flatten_groups=1):
        GenericLoader.__init__(self, file, filename, match)
        self.line_color = StandardColors.black
        self.fill_color = StandardColors.black
        self.line_width = 0.0
        self.line_join = const.JoinMiter
        self.line_cap = const.CapButt
        self.line_dashes = ()
        self.cur_x = self.cur_y = 0.0
        self.treat_toplevel_groups_as_layers = treat_toplevel_groups_as_layers
        self.flatten_groups = flatten_groups
        self.guess_continuity = 1
        self.path = CreatePath()
        self.compound_path = None  # If compound_path is None, we're
        # outside of a compound path,
        # otherwise it's a possibly empty list
        # of paths
        self.compound_render = ''
        self.stack = []
        self.gradients = {}
        self.in_gradient_instance = 0
        self.gradient_geo = None  # set to a true value after Bg, and set
        # to false by make_gradient_pattern
        self.gradient_rect = None
        self.in_palette = 0
        self.in_text = 0
        self.ignore_fill = 0
        self.text_type = 0  # 0: point text, 1: area text, 2 = path text
        self.text_render = 0  # filled
        self.text_font = None
        self.text_size = 12

        # Test alignment. Possible values: 0: left, 1: center, 2:right,
        # 3: justified, 4: justified including last line
        self.text_align = 0

        self.text_string = []
        self.standard_encoding = encoding.adobe_standard
        self.font_map = {}
        self.guides = []
        self.format_version = 0.0
예제 #16
0
 def end_group(self):
     if self.compound_path is None:
         # a normal group
         if self.composite_class == Layer:
             self.end_composite()
         else:
             try:
                 GenericLoader.end_group(self)
                 if self.flatten_groups:
                     if self.object.NumObjects() == 1:
                         obj = self.object.GetObjects()[0]
                         del self.composite_items[-1]
                         self.append_object(obj)
             except EmptyCompositeError:
                 pass
     else:
         # a `compound group'. Ignored since Sketch doesn't have this.
         pass
예제 #17
0
 def end_group(self):
     if self.compound_path is None:
         # a normal group
         if self.composite_class == Layer:
             self.end_composite()
         else:
             try:
                 GenericLoader.end_group(self)
                 if self.flatten_groups:
                     if self.object.NumObjects() == 1:
                         obj = self.object.GetObjects()[0]
                         del self.composite_items[-1]
                         self.append_object(obj)
             except EmptyCompositeError:
                 pass
     else:
         # a `compound group'. Ignored since Sketch doesn't have this.
         pass
예제 #18
0
    def __init__(self, file, filename, match):
	GenericLoader.__init__(self, file, filename, match)
        if atoi(match.group('minor')) > 2:
            self.add_message(_("The file was created by a newer version of "
                          "Skencil or Sketch, there might be inaccuracies."))
	if self.filename:
	    self.directory = os.path.split(filename)[0]
	else:
	    self.directory = ''
	self.style_dict = {}
	self.id_dict = {}
	self.page_layout = None
	self.pattern = None
	self.gradient = None
	self.arrow1 = None
	self.arrow2 = None
	self.font = None
	self.font_size = 1.0
	self.color_cache = {}
예제 #19
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     if atoi(match.group('minor')) > 2:
         self.add_message(
             _("The file was created by a newer version of "
               "Skencil or Sketch, there might be inaccuracies."))
     if self.filename:
         self.directory = os.path.split(filename)[0]
     else:
         self.directory = ''
     self.style_dict = {}
     self.id_dict = {}
     self.page_layout = None
     self.pattern = None
     self.gradient = None
     self.arrow1 = None
     self.arrow2 = None
     self.font = None
     self.font_size = 1.0
     self.color_cache = {}
예제 #20
0
    def __init__(self, file, filename, match, treat_toplevel_groups_as_layers=1, flatten_groups=1):
        GenericLoader.__init__(self, file, filename, match)
        self.line_color = StandardColors.black
        self.fill_color = StandardColors.black
        self.line_width = 0.0
        self.line_join = const.JoinMiter
        self.line_cap = const.CapButt
        self.line_dashes = ()
        self.cur_x = self.cur_y = 0.0
        self.treat_toplevel_groups_as_layers = treat_toplevel_groups_as_layers
        self.flatten_groups = flatten_groups
        self.guess_continuity = 1
        self.path = CreatePath()
        self.compound_path = None  # If compound_path is None, we're
        # outside of a compound path,
        # otherwise it's a possibly empty list
        # of paths
        self.compound_render = ""
        self.stack = []
        self.gradients = {}
        self.in_gradient_instance = 0
        self.gradient_geo = None  # set to a true value after Bg, and set
        # to false by make_gradient_pattern
        self.gradient_rect = None
        self.in_palette = 0
        self.in_text = 0
        self.ignore_fill = 0
        self.text_type = 0  # 0: point text, 1: area text, 2 = path text
        self.text_render = 0  # filled
        self.text_font = None
        self.text_size = 12

        # Test alignment. Possible values: 0: left, 1: center, 2:right,
        # 3: justified, 4: justified including last line
        self.text_align = 0

        self.text_string = []
        self.standard_encoding = encoding.adobe_standard
        self.font_map = {}
        self.guides = []
        self.format_version = 0.0
예제 #21
0
    def __init__(self, file, filename, match):

        GenericLoader.__init__(self, file, filename, match)
예제 #22
0
    def __init__(self, file, filename, match):

        GenericLoader.__init__(self, file, filename, match)
예제 #23
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     if self.filename:
         self.directory = os.path.split(filename)[0]
     else:
         self.directory = ''
예제 #24
0
 def __init__(self, file, filename, match):
     GenericLoader.__init__(self, file, filename, match)
     if self.filename:
         self.directory = os.path.split(filename)[0]
     else:
         self.directory = ''