Commit bdbbc016 authored by dmMaze's avatar dmMaze
Browse files

fix re-lettering (#268)

parent d0b5d9e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ data/models
data/testpacks/eng_dontupload
data/testpacks/testpacks
data/*.png
data/testpacks
ballontranslator/ui/pagesources/gallery-dl
ballontranslator/gallery-dl
release
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ if os.environ.get('BALLOONTRANS_DEBUG', ''):
            return copy.copy(src_list)
        
    def transhook_copy_original(translations: List[str] = None, textblocks: List[TextBlock] = None, translator: BaseTranslator = None, **kwargs):
        if textblocks is not None:
        if textblocks is not None and isinstance(translator, TransOriginal):
            for ii, _ in enumerate(translations):
                translations[ii] = textblocks[ii].translation

+6 −3
Original line number Diff line number Diff line
@@ -861,7 +861,7 @@ class MainWindow(FramelessWindow):
                else:
                    blk.translation = half_len(blk.translation)
                    blk.translation = re.sub(r'([?.!"])\s+', r'\1', blk.translation)    # remove spaces following punctuations
        elif src_is_cjk:
        else:
            for blk in blk_list:
                if blk.vertical:
                    blk._alignment = 1
@@ -870,6 +870,8 @@ class MainWindow(FramelessWindow):

        for blk in blk_list:
            blk.translation = self.mtSubWidget.sub_text(blk.translation)
            if pcfg.let_uppercase_flag:
                blk.translation = blk.translation.upper()

    def on_pagtrans_finished(self, page_index: int):
        blk_list = self.imgtrans_proj.get_blklist_byidx(page_index)
@@ -910,7 +912,8 @@ class MainWindow(FramelessWindow):
            if sw > 0 and pcfg.module.enable_ocr and pcfg.module.enable_detect:
                blk.font_size = int(blk.font_size / (1 + sw))

        self.st_manager.auto_textlayout_flag = pcfg.let_autolayout_flag and pcfg.module.enable_detect
        self.st_manager.auto_textlayout_flag = pcfg.let_autolayout_flag and \
            (pcfg.module.enable_detect or pcfg.module.enable_translate)
        
        if page_index != self.pageList.currentIndex().row():
            self.pageList.setCurrentRow(page_index)
@@ -1000,7 +1003,7 @@ class MainWindow(FramelessWindow):
                        textblk.set_font_colors((0, 0, 0), (0, 0, 0), True)
                    if pcfg.module.enable_translate or all_disabled or pcfg.module.enable_ocr:
                        textblk.rich_text = ''
                        textblk.font_size = textblk.detected_font_size
                        # textblk.font_size = textblk.detected_font_size ???
                    textblk.vertical = textblk.src_is_vertical
        self.module_manager.runImgtransPipeline()

+3 −6
Original line number Diff line number Diff line
@@ -647,9 +647,6 @@ class SceneTextManager(QObject):
            text = blkitem.toPlainText()
            restore_charfmts = True

        if pcfg.let_uppercase_flag:
            text = text.upper()

        if mask is None:
            im_h, im_w = img.shape[:2]
            bounding_rect = blkitem.absBoundingRect(max_h=im_h, max_w=im_w)
@@ -679,7 +676,7 @@ class SceneTextManager(QObject):
        delimiter_len = text_size_func(delimiter)[0]
 
        adaptive_fntsize = False
        if self.auto_textlayout_flag and pcfg.let_fntsize_flag == 0:
        if self.auto_textlayout_flag and pcfg.let_fntsize_flag == 0 and pcfg.module.enable_detect:
            if not tgt_is_cjk:
                adaptive_fntsize = True
            
@@ -723,7 +720,7 @@ class SceneTextManager(QObject):
        if max_central_width != np.inf:
            max_central_width = max(int(max_central_width * text_w), 0.75 * region_rect[2])

        padding = pt2px(blk_font.pointSize()) + 20   # dummpy padding variable
        padding = pt2px(blk_font.pointSizeF()) + 20   # dummpy padding variable
        if fmt.alignment == 1:
            if len(blkitem.blk) > 0:
                centroid = blkitem.blk.center().astype(np.int64).tolist()