This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
loadfontfromlist should send fontchange message to framework #14805
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
47f8e04
loadfontfromlist should send fontchange message to framework
chunhtai 18a2aef
update
chunhtai aefa41c
fix test
chunhtai d828b0f
clean up
chunhtai 7e62f5d
addressing comment
chunhtai 65b958b
add line at the end
chunhtai 585a7a0
clean up future chain
chunhtai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1498,5 +1498,18 @@ abstract class ParagraphBuilder { | |
/// * `fontFamily`: The family name used to identify the font in text styles. | ||
/// If this is not provided, then the family name will be extracted from the font file. | ||
Future<void> loadFontFromList(Uint8List list, {String fontFamily}) { | ||
return _fontCollection.loadFontFromList(list, fontFamily: fontFamily); | ||
return _fontCollection.loadFontFromList(list, fontFamily: fontFamily).then( | ||
(_) => _sendFontChangeMessage() | ||
); | ||
} | ||
|
||
final ByteData _fontChangeMessage = engine.JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'}); | ||
|
||
FutureOr<void> _sendFontChangeMessage() async { | ||
if (window.onPlatformMessage != null) | ||
window.onPlatformMessage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it out to a final variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! |
||
'flutter/system', | ||
_fontChangeMessage, | ||
(_) {}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be static, to prevent creating multiple instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not in a class. Do you mean put this field to be a static member for some class? I am not familiar with how dart compile the code, I thought define it in the scope of this file is the same thing as a static member of a class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, reading fail on my part. it is fine as a top level