Skip to content

Commit f5336c4

Browse files
committed
wip
1 parent 144d6a6 commit f5336c4

File tree

2 files changed

+17
-39
lines changed

2 files changed

+17
-39
lines changed

src/Typeset/Boxes/Basic/text_boxes.cpp

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ text_box_rep::text_box_rep (path ip, int pos2, string s, font fn2, pencil p2,
9595
: box_rep (ip), pos (pos2), str (s), fn (fn2), pen (p2), xk (xk2),
9696
bg_color (bg) {
9797

98-
// 调试日志:检查字符串内容
99-
bool all_spaces = is_all_spaces(s);
100-
if (all_spaces) {
101-
cout << "DEBUG text_box_rep: string='" << s << "', length=" << N(s)
102-
<< ", all spaces\n";
103-
}
98+
bool all_spaces= is_all_spaces (s);
10499

105100
metric ex;
106101
fn->get_extents (str, ex);
@@ -114,27 +109,15 @@ text_box_rep::text_box_rep (path ip, int pos2, string s, font fn2, pencil p2,
114109
y4= ex->y4;
115110

116111
// 特殊处理:如果字符串全部由空格组成,手动计算宽度
117-
if (all_spaces && N(s) > 0) {
112+
if (all_spaces && N (s) > 0) {
118113
// 获取单个空格的宽度
119114
metric space_ex;
120115
fn->get_extents (" ", space_ex);
121-
SI single_space_width = space_ex->x2 - space_ex->x1;
116+
SI single_space_width= space_ex->x2 - space_ex->x1;
122117

123118
// 计算总宽度
124-
SI total_width = single_space_width * N(s);
125-
x2 = x1 + total_width;
126-
127-
cout << "DEBUG text_box_rep: all spaces string, N(s)=" << N(s)
128-
<< ", single_space_width=" << single_space_width
129-
<< ", total_width=" << total_width
130-
<< ", adjusted x2=" << x2 << "\n";
131-
}
132-
133-
// 调试日志:显示尺寸信息
134-
if (all_spaces) {
135-
cout << "DEBUG text_box_rep: extents - x1=" << x1 << ", x2=" << x2
136-
<< ", width=" << (x2 - x1) << ", y1=" << y1 << ", y2=" << y2
137-
<< ", height=" << (y2 - y1) << "\n";
119+
SI total_width= single_space_width * N (s);
120+
x2 = x1 + total_width;
138121
}
139122

140123
// 特殊处理:对于全空格字符串,确保有最小高度以便背景色可见
@@ -145,27 +128,25 @@ text_box_rep::text_box_rep (path ip, int pos2, string s, font fn2, pencil p2,
145128

146129
if (m_ex->y1 != m_ex->y2) {
147130
// 如果"M"有有效的高度,使用它的y1和y2
148-
y1 = m_ex->y1;
149-
y2 = m_ex->y2;
150-
cout << "DEBUG text_box_rep: using 'M' height, y1=" << y1
151-
<< ", y2=" << y2 << ", height=" << (y2 - y1) << "\n";
152-
} else {
131+
y1= m_ex->y1;
132+
y2= m_ex->y2;
133+
}
134+
else {
153135
// 如果"M"的高度也无效,使用字体的上升和下降值
154136
SI font_ascender = fn->y1;
155-
SI font_descender = fn->y2;
137+
SI font_descender= fn->y2;
156138

157139
if (font_ascender == 0 && font_descender == 0) {
158140
// 如果字体没有提供上升/下降值,使用默认比例
159-
SI font_height = fn->yx;
160-
y1 = -font_height / 4; // 基线以下1/4高度
161-
y2 = font_height * 3 / 4; // 基线以上3/4高度
162-
} else {
141+
SI font_height= fn->yx;
142+
y1 = -font_height / 4; // 基线以下1/4高度
143+
y2 = font_height * 3 / 4; // 基线以上3/4高度
144+
}
145+
else {
163146
// 使用字体的实际上升和下降值
164-
y1 = font_descender;
165-
y2 = font_ascender;
147+
y1= font_descender;
148+
y2= font_ascender;
166149
}
167-
cout << "DEBUG text_box_rep: using font metrics, y1=" << y1
168-
<< ", y2=" << y2 << ", height=" << (y2 - y1) << "\n";
169150
}
170151
}
171152

src/Typeset/Concat/concat_text.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ concater_rep::typeset_substring (string s, path ip, int pos) {
3030
tree bg_color_tree= env->read (BG_COLOR);
3131
string bg_color_str = as_string (bg_color_tree);
3232

33-
3433
if (bg_color_tree != "" && bg_color_str != "white") {
3534
// 有背景色设置,使用 typeset_background_substring
3635
typeset_background_substring (s, ip, pos, bg_color_str);
@@ -191,7 +190,6 @@ concater_rep::typeset_background_text_string (tree t, path ip, int pos, int end,
191190
// 收集整个文本块
192191
string full_text= s (pos, end);
193192

194-
195193
// 创建带有背景色的文本框
196194
box b= text_box_with_bg (ip, pos, full_text, env->fn, env->pen,
197195
named_color (bg_color, env->alpha), xkerning ());
@@ -211,7 +209,6 @@ concater_rep::typeset_normal_text_string (tree t, path ip, int pos, int end) {
211209
string bg_color_str = as_string (bg_color_tree);
212210
bool has_background= (bg_color_tree != "" && bg_color_str != "white");
213211

214-
215212
do {
216213
start = pos;
217214
text_property tp= env->lan->advance (t, pos);

0 commit comments

Comments
 (0)