File size: 950 Bytes
c8a32e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from typing import List
from marker.schema.page import Page
def find_bold_italic(pages: List[Page], bold_min_weight=600):
font_weights = []
for page in pages:
for block in page.blocks:
# We don't want to bias our font stats
if block.block_type in ["Title", "Section-header"]:
continue
for line in block.lines:
for span in line.spans:
if "bold" in span.font.lower():
span.bold = True
if "ital" in span.font.lower():
span.italic = True
font_weights.append(span.font_weight)
if len(font_weights) == 0:
return
for page in pages:
for block in page.blocks:
for line in block.lines:
for span in line.spans:
if span.font_weight >= bold_min_weight:
span.bold = True |