Skip to content

Commit 278163b

Browse files
committed
[web] Pass hyphenCharacter to CanvasKit
CanvasKit's ParagraphStyle gained softHyphenString in Skia 1bd2b0627c, which rolled into Flutter in flutter#195339. CkParagraphStyle now sets it from ParagraphStyle.hyphenCharacter, so the hyphenCharacter test runs on CanvasKit too. Part of flutter#189617.
1 parent c7cda41 commit 278163b

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

‎engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ extension type SkParagraphStyleProperties._(JSObject _) implements JSObject {
19301930
external set replaceTabCharacters(bool? bool);
19311931
external set applyRoundingHack(bool applyRoundingHack);
19321932
external set renderSoftHyphens(bool renderSoftHyphens);
1933+
external set softHyphenString(String? softHyphenString);
19331934
}
19341935

19351936
extension type SkTextStyle(JSObject _) implements JSObject {}

‎engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/text.dart‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ SkParagraphStyle _toSkParagraphStyle(EngineParagraphStyle style, CkFontCollectio
8686
properties.applyRoundingHack = false;
8787
// Like the native engine, render soft hyphens unless they are hidden.
8888
properties.renderSoftHyphens = style.hyphens != ui.Hyphens.hidden;
89-
// TODO(dbebawy): Pass style.hyphenCharacter once CanvasKit's softHyphenString
90-
// rolls in. https://github.com/flutter/flutter/issues/189617
89+
final String? hyphenCharacter = style.hyphenCharacter;
90+
if (hyphenCharacter != null) {
91+
properties.softHyphenString = hyphenCharacter;
92+
}
9193

9294
return canvasKit.ParagraphStyle(properties);
9395
}

‎engine/src/flutter/lib/web_ui/test/ui/paragraph_builder_test.dart‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:ui/ui.dart';
88
import 'package:ui/ui_web/src/ui_web.dart' as ui_web;
99

1010
import '../common/test_initialization.dart';
11-
import 'utils.dart';
1211

1312
void main() {
1413
internalBootstrapBrowserTest(() => testMain);
@@ -236,16 +235,10 @@ Future<void> testMain() async {
236235
return (builder.build()..layout(const ParagraphConstraints(width: 65))).longestLine;
237236
}
238237

239-
test(
240-
'is drawn at a soft hyphen line break',
241-
() {
242-
expect(longestLine(null), 50);
243-
expect(longestLine('--'), 60);
244-
expect(longestLine(''), 40);
245-
},
246-
// TODO(dbebawy): Enable on CanvasKit once its softHyphenString rolls in.
247-
// https://github.com/flutter/flutter/issues/189617
248-
skip: isCanvasKit,
249-
);
238+
test('is drawn at a soft hyphen line break', () {
239+
expect(longestLine(null), 50);
240+
expect(longestLine('--'), 60);
241+
expect(longestLine(''), 40);
242+
});
250243
});
251244
}

0 commit comments

Comments
 (0)