Commit 7f641a68 authored by dmMaze's avatar dmMaze
Browse files

add pause or stop punctuation position rule

parent cc4aae87
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ class SourceTextEdit(QTextEdit):
        self.setMinimumHeight(75)
        self.document().contentsChanged.connect(self.on_content_changed)
        self.document().documentLayout().documentSizeChanged.connect(self.adjustSize)
        self.setAcceptRichText(False)

    def adjustSize(self):
        h = self.document().documentLayout().documentSize().toSize().height()
+3 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ def pixmap2ndarray(pixmap: Union[QPixmap, QImage], keep_alpha=True):
    h = size.width()
    w = size.height()
    if isinstance(pixmap, QPixmap):
        qimg = pixmap.toImage().convertToFormat(QImage.Format_RGBA8888)
        qimg = pixmap.toImage().convertToFormat(QImage.Format.Format_RGBA8888)
    else:
        qimg = pixmap

@@ -51,9 +51,9 @@ def ndarray2pixmap(img):
    height, width, channel = img.shape
    bytesPerLine = channel * width
    if channel == 4:
        img_format = QImage.Format_RGBA8888
        img_format = QImage.Format.Format_RGBA8888
    else:
        img_format = QImage.Format_RGB888
        img_format = QImage.Format.Format_RGB888
    img = np.ascontiguousarray(img)
    qImg = QImage(img.data, width, height, bytesPerLine, img_format).rgbSwapped()
    return QPixmap(qImg)
+5 −4
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class TextBlkItem(QGraphicsTextItem):
        self.oldPos = QPointF()
        self.oldRect = QRectF()

        self.document().setDocumentMargin(0)
        self.setVertical(False)
        self.initTextBlock(blk, set_format=set_format)
        self.setBoundingRegionGranularity(0)
@@ -209,6 +210,7 @@ class TextBlkItem(QGraphicsTextItem):
            self.blk.vertical = vertical
        self.setTextInteractionFlags(Qt.NoTextInteraction)
        doc = self.document()
        doc_margin = doc.documentMargin()
        doc.disconnect()
        doc.documentLayout().disconnect()
        html = doc.toHtml()
@@ -216,6 +218,7 @@ class TextBlkItem(QGraphicsTextItem):
        rect = self.rect()

        doc = QTextDocument()
        doc.setDocumentMargin(doc_margin)
        if vertical:
            layout = VerticalTextDocumentLayout(doc)
        else:
@@ -226,7 +229,6 @@ class TextBlkItem(QGraphicsTextItem):
        doc.setDocumentLayout(layout)
        doc.setDefaultFont(default_font)
        doc.setHtml(html)
        doc.setDocumentMargin(0)
        self.setDocument(doc)
        doc.contentsChanged.connect(self.documentContentChanged)
        
@@ -276,6 +278,7 @@ class TextBlkItem(QGraphicsTextItem):
            self.background_pixmap = None
    
        sw = self.stroke_width * pt2px(self.document().defaultFont().pointSizeF())
        
        self.document().setDocumentMargin(sw/2)
        self.documentLayout().updateDocumentMargin(sw/2)
        self.on_document_enlarged()
@@ -488,7 +491,6 @@ class TextBlkItem(QGraphicsTextItem):
        return font_format

    def set_fontformat(self, ffmat: FontFormat, set_char_format=False):

        if self.is_vertical != ffmat.vertical:
            self.setVertical(ffmat.vertical)
        cursor = self.textCursor()
@@ -517,7 +519,6 @@ class TextBlkItem(QGraphicsTextItem):
        # https://stackoverflow.com/questions/37160039/set-default-character-format-in-qtextdocument
        cursor.movePosition(QTextCursor.Start)
        self.setTextCursor(cursor)

        self.stroke_width = ffmat.stroke_width
        self.setStrokeWidth(ffmat.stroke_width)
        self.setStrokeColor(ffmat.srgb)
+163 −93

File changed.

Preview size limit exceeded, changes collapsed.