def read(self, stream: Stream, version): version = binascii.hexlify(stream.read(1)) if version != b'01': raise UnsupportedVersionException( 'Unsupported Font version {}'.format(version)) self.charset = stream.read_ushort('charset') # Not exposed in ArcMap front end: attributes = stream.read_uchar('attributes') self.italic = attributes & self.Italic self.underline = attributes & self.Underline self.strikethrough = attributes & self.Strikethrough self.weight = stream.read_ushort('weight') # From https://docs.microsoft.com/en-us/windows/desktop/api/olectl/ns-olectl-tagfontdesc # Use the int64 member of the CY structure and scale your font size (in points) by 10000. self.size = stream.read_int('font size') / 10000 name_length = stream.read_uchar('font name size') self.font_name = stream.read(name_length).decode()
def read(self, stream: Stream, version): if version == 4: self.picture = stream.read_object('picture') elif version == 7: _ = stream.read_ushort('pic version?') _ = stream.read_uint('picture type?') self.picture = stream.read_object('picture') elif version == 8: self.picture = stream.read_picture('picture') self.color_background = stream.read_object('color bg') self.color_foreground = stream.read_object('color fg') self.color_transparent = stream.read_object('color trans') # either an entire LineSymbol or just a LineSymbolLayer outline = stream.read_object('outline') if outline is not None: if issubclass(outline.__class__, SymbolLayer): self.outline_layer = outline else: self.outline_symbol = outline self.angle = stream.read_double('angle') self.scale_x = stream.read_double('scale_x') self.scale_y = stream.read_double('scale_y') self.offset_x = stream.read_double('offset x') self.offset_y = stream.read_double('offset y') self.separation_x = stream.read_double('separation x') self.separation_y = stream.read_double('separation y') stream.read(16) stream.read_0d_terminator() self.swap_fb_gb = bool(stream.read_uchar('swap fgbg')) if version <= 4: return stream.read(6) if version < 8: stream.read(4)
def read(self, stream: Stream, version): if version in (4, 5): self.picture = stream.read_object('picture') elif version == 8: _ = stream.read_ushort('pic version?') _ = stream.read_uint('picture type?') self.picture = stream.read_object('picture') elif version == 9: self.picture = stream.read_picture('picture') if version <= 8: _ = stream.read_object() self.color_foreground = stream.read_object('color 1') self.color_background = stream.read_object('color 2') if version >= 9: self.color_transparent = stream.read_object('color 3') self.angle = stream.read_double('angle') self.size = stream.read_double('size') self.x_offset = stream.read_double('x offset') self.y_offset = stream.read_double('y offset') stream.read_double('unknown') stream.read_double('unknown') stream.read_0d_terminator() self.swap_fb_gb = bool(stream.read_uchar('swap fgbg')) check = binascii.hexlify(stream.read(2)) if check != b'ffff': raise UnreadableSymbolException('Expected ffff at {}, got {}'.format(check, hex(stream.tell() - 2))) if version < 6: return stream.read(6) if version <= 8: stream.read(4)