Commit c3decce3 authored by dmMaze's avatar dmMaze
Browse files

try to fix weird vtextlayout shift (#160)

parent 602c5ea9
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ index_url = os.environ.get('INDEX_URL', "")
QT_APIS = ['pyqt5', 'pyqt6']
stored_commit_hash = None

REQ_WIN = [
    'pywin32'
]

parser = argparse.ArgumentParser()
parser.add_argument("--reinstall-torch", action='store_true', help="launch.py argument: install the appropriate version of torch even if you have some version already installed")
parser.add_argument("--proj-dir", default='', type=str, help='Open project directory on startup')
@@ -65,7 +69,7 @@ def run_pip(args, desc=None):
        return

    index_url_line = f' --index-url {index_url}' if index_url != '' else ''
    return run(f'"{python}" -m pip {args} --no-cache-dir --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=True)
    return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=True)


def commit_hash():
@@ -160,15 +164,29 @@ def main():
    sys.exit(app.exec())

def prepare_environment():
    torch_command = os.environ.get('TORCH_COMMAND', "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118")

    req_updated = False
    if sys.platform == 'win32':
        for req in REQ_WIN:
            try:
                pkg_resources.require(req)
            except Exception:
                run_pip(f"install {req}", req)
                req_updated = True

    torch_command = os.environ.get('TORCH_COMMAND', "pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118")
    if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
        run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)

        req_updated = True
    try:
        pkg_resources.require(open(args.requirements,mode='r', encoding='utf8'))
    except Exception:
        run_pip(f"install -r {args.requirements}", "requirements")
        req_updated = True

    if req_updated:
        import site
        importlib.reload(site)

if __name__ == '__main__':

+3 −4
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

PyQt6-Qt6<=6.4.2    # framelesswindow is broken for qt>=6.4.3
PyQt6<=6.4.2   #PyQt5>=5.15.9

numpy
urllib3==1.25.11 # https://github.com/psf/requests/issues/5740
jaconv
@@ -13,8 +12,6 @@ fugashi
unidic_lite
tqdm
opencv-python

pywin32
shapely
pyclipper
einops
@@ -36,3 +33,5 @@ Pillow
beautifulsoup4
colorama
gallery-dl

# pywin32 required on windows
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ class SceneTextLayout(QAbstractTextDocumentLayout):
                    char_idx += 1
                it += 1
                frag_idx += 1

            self.block_charfmt_lst.append(charfmt_lst)
            self.block_ideal_width.append(ideal_width)
            self.block_ideal_height.append(ideal_height)
@@ -394,7 +395,9 @@ class VerticalTextDocumentLayout(SceneTextLayout):

                else:
                    yoff = -cfmt.tbr.top() - fm.ascent() + natral_shifted
                    self.line_draw(painter, line, -natral_shifted, yoff, selected, selection)
                    # print(natral_shifted, char, line.naturalTextWidth(), line.textLength())
                    # self.line_draw(painter, line, -natral_shifted, yoff, selected, selection)
                    self.line_draw(painter, line, 0, yoff, selected, selection)

            block = block.next()

+1 −1
Original line number Diff line number Diff line
branch = 'master'
branch = 'dev'
version = '1.4.0'
 No newline at end of file