Commit f24b4f45 authored by dmMaze's avatar dmMaze
Browse files

set detected_font_size as property func of TextBlock

parent a92e54d8
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ class TextBlock:
    shadow_color: Tuple = (0, 0, 0)
    shadow_offset: List = field(default_factory = lambda : [0., 0.])
    src_is_vertical: bool = None
    detected_font_size: int = -1
    _detected_font_size: int = -1

    region_mask: np.ndarray = None
    region_inpaint_dict: Dict = None
@@ -71,8 +71,12 @@ class TextBlock:
            self.vec = np.array(self.vec, np.float32)
        if self.src_is_vertical is None:
            self.src_is_vertical = self.vertical
        if self.detected_font_size == -1:
            self.detected_font_size = self.font_size

    @property
    def detected_font_size(self):
        if self._detected_font_size > 0:
            return self._detected_font_size
        return self.font_size

    def adjust_bbox(self, with_bbox=False, x_range=None, y_range=None):
        lines = self.lines_array().astype(np.int32)
@@ -573,7 +577,7 @@ def group_output(blks, lines, im_w, im_h, mask=None, sort_blklist=True) -> List[
            lines[..., 1] = np.clip(lines[..., 1], 0, im_h-1)
            blk.lines = lines.astype(np.int64).tolist()
            blk.font_size += expand_size
        blk.detected_font_size = blk.font_size
        blk._detected_font_size = blk.font_size
            
    return final_blk_list