mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove more unused code
This commit is contained in:
parent
e430bf3312
commit
5ca83285fb
@ -697,57 +697,6 @@ def add_pagenum_toc(root, toc, opts, page_number_display_map):
|
|||||||
# Fonts {{{
|
# Fonts {{{
|
||||||
|
|
||||||
|
|
||||||
class Range(object):
|
|
||||||
|
|
||||||
__slots__ = ('first', 'last', 'widths', 'sort_order')
|
|
||||||
|
|
||||||
def __init__(self, first, last, widths):
|
|
||||||
self.first, self.last, self.widths = first, last, widths
|
|
||||||
# Sort by first with larger ranges coming before smaller ones
|
|
||||||
self.sort_order = self.first, -self.last
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '({}, {}, {})'.format(self.first, self.last, self.widths)
|
|
||||||
|
|
||||||
def merge(self, r):
|
|
||||||
if r.last <= self.last:
|
|
||||||
return # is a subset
|
|
||||||
if r.first > self.last:
|
|
||||||
if r.first == self.last + 1 and self.has_single_width == r.has_single_width:
|
|
||||||
if self.has_single_width:
|
|
||||||
if r.widths[0] == self.widths[0]:
|
|
||||||
self.last = r.last
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.last = r.last
|
|
||||||
delta = self.last - self.first + 1 - len(self.widths)
|
|
||||||
self.widths.extend(r.widths[-delta:])
|
|
||||||
return
|
|
||||||
return r
|
|
||||||
if self.has_single_width != r.has_single_width:
|
|
||||||
# make r disjoint
|
|
||||||
delta = self.last + 1 - r.first
|
|
||||||
r.first = self.last + 1
|
|
||||||
if len(r.widths) > 1:
|
|
||||||
del r.widths[:delta]
|
|
||||||
return r if r.widths else None
|
|
||||||
# subsume r into self
|
|
||||||
self.last = r.last
|
|
||||||
if not self.has_single_width:
|
|
||||||
delta = self.last - self.first + 1 - len(self.widths)
|
|
||||||
self.widths.extend(r.widths[-delta:])
|
|
||||||
|
|
||||||
@property
|
|
||||||
def as_item(self):
|
|
||||||
if self.has_single_width:
|
|
||||||
return self.first, self.last, self.widths[0]
|
|
||||||
return self.first, self.widths
|
|
||||||
|
|
||||||
@property
|
|
||||||
def has_single_width(self):
|
|
||||||
return len(self.widths) == 1
|
|
||||||
|
|
||||||
|
|
||||||
def all_glyph_ids_in_w_arrays(arrays, as_set=False):
|
def all_glyph_ids_in_w_arrays(arrays, as_set=False):
|
||||||
ans = set()
|
ans = set()
|
||||||
for w in arrays:
|
for w in arrays:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user