mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More refined algorithm to calculate base font size.
This commit is contained in:
parent
f3080a42b0
commit
a6e884a53e
@ -556,8 +556,19 @@ class Book(Delegator):
|
||||
text_blocks.append(obj)
|
||||
|
||||
text_styles = set([t.textStyle for t in text_blocks])
|
||||
fonts = {}
|
||||
important_text_styles = []
|
||||
for ts in text_styles:
|
||||
temp = [len(tb.contents) for tb in text_blocks if tb.textStyle == ts]
|
||||
avg_content_length = 0
|
||||
if len(temp) > 0:
|
||||
avg_content_length = sum(temp)/len(temp)
|
||||
if avg_content_length > 4:
|
||||
important_text_styles.append(ts)
|
||||
|
||||
fonts = {}
|
||||
if not important_text_styles:
|
||||
important_text_styles = text_styles
|
||||
for ts in important_text_styles:
|
||||
fs = int(ts.attrs['fontsize'])
|
||||
if fonts.has_key(fs):
|
||||
fonts[fs] += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user