@@ -23,8 +23,8 @@ def print_transform(tr: QTransform):
23
23
24
24
# https://www.w3.org/TR/2022/DNOTE-clreq-20220801/#tables_of_chinese_punctuation_marks
25
25
# https://www.w3.org/TR/2022/DNOTE-clreq-20220801/#glyphs_sizes_and_positions_in_character_faces_of_punctuation_marks
26
- PUNSET_PAUSEORSTOP = {'。' , '.' , ',' , '、' , ':' , ';' , '!' , '?' } # dont need to rotate,
27
- PUNSET_ALIGNTOP = {'。' , '.' , ',' , '、' }
26
+ PUNSET_PAUSEORSTOP = {'。' , '.' , ',' , '、' , '·' , ' :' , ';' , '!' , '?' } # dont need to rotate,
27
+ PUNSET_ALIGNCENTER = {'。' , '.' , ',' , '、' , '· ' }
28
28
PUNSET_BRACKETL = {'「' , '『' , '“' , '‘' , '(' , '《' , '〈' , '【' , '〖' , '〔' , '[' , '{' , '(' }
29
29
PUNSET_BRACKETR = {'」' , '』' , '”' , '’' , ')' , '》' , '〉' , '】' , '〗' , '〕' , ']' , '}' }
30
30
PUNSET_BRACKET = PUNSET_BRACKETL .union (PUNSET_BRACKETR )
@@ -124,14 +124,14 @@ def br(self) -> QRectF:
124
124
# return get_punc_rect('啊', self.family, self.size, self.weight, self.font.italic())[1]
125
125
_ , br1 = get_punc_rect ('啊' , self .family , self .size , self .weight , self .font .italic ())
126
126
_ , br2 = get_punc_rect ('木' , self .family , self .size , self .weight , self .font .italic ())
127
- return QRectF (br2 .left (), br2 .top (), br1 .right () - br2 .left (), br2 .height ())
127
+ return QRectF (br2 .left (), br2 .top (), max ( br1 .right (), br2 . right ()) - min ( br1 . left (), br2 .left () ), br2 .height ())
128
128
129
129
@cached_property
130
130
def tbr (self ) -> QRectF :
131
131
# return get_punc_rect('啊', self.family, self.size, self.weight, self.font.italic())[0]
132
132
br1 , _ = get_punc_rect ('啊' , self .family , self .size , self .weight , self .font .italic ())
133
133
br2 , _ = get_punc_rect ('木' , self .family , self .size , self .weight , self .font .italic ())
134
- return QRectF (br2 .left (), br2 .top (), br1 .right () - br2 .left (), br2 .height ())
134
+ return QRectF (br2 .left (), br2 .top (), max ( br1 .right (), br2 . right ()) - min ( br1 . left (), br2 .left () ), br2 .height ())
135
135
136
136
@cached_property
137
137
def space_width (self ) -> int :
@@ -431,6 +431,11 @@ def updateDrawOffsets(self):
431
431
xoff -= natral_shifted
432
432
yoff += natral_shifted
433
433
434
+ if char in PUNSET_ALIGNCENTER :
435
+ tbr , br = cfmt .punc_rect (char )
436
+ yoff += (tbr .height () + cfmt .font_metrics .descent () - act_rect [3 ]) / 2
437
+ # yoff = 0
438
+
434
439
else :
435
440
empty_spacing = num_lspaces * cfmt .space_width
436
441
if TEXTLAYOUT_QTVERSION :
@@ -684,7 +689,7 @@ def layoutBlock(self, block: QTextBlock):
684
689
tbr_h -= let_sp_offset
685
690
tbr_h += let_sp_offset
686
691
elif vertical_force_aligncentel (char ):
687
- if char not in PUNSET_ALIGNTOP :
692
+ if char not in PUNSET_ALIGNCENTER :
688
693
tbr_h = cfmt .punc_actual_rect (line , char , cache = True )[3 ]
689
694
else :
690
695
tbr , br = cfmt .punc_rect (char )
0 commit comments