[canvaskit] Deprecate measureText

After discussion on https://skia-review.googlesource.com/c/skia/+/334096
we decided to remove this misleading API.

Bug: skia:10480
Change-Id: I3daeb6251d5fed829742cfe39c7cade4f19e5a43
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334101
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
Kevin Lubick 2020-11-11 13:03:06 -05:00
parent 15d7a38b04
commit 59bafeeaa7
3 changed files with 7 additions and 5 deletions

View File

@ -40,6 +40,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `CanvasKit.MakePathFromCmds`; Was deprecated in favor of `CanvasKit.Path.MakeFromCmds`.
- `new CanvasKit.Path(path)` in favor of existing `path.copy()`.
- Unused internal APIs (_getRasterN32PremulSurface, Drawable)
- `measureText` from the CanvasContext2D emulation layer du to deprecation of measureText.
### Deprecated
- `Font.getWidths` in favor of `Font.getGlyphIDs` and `Font.getGlyphWidths`.
- `Font.measureText` in favor of the Paragraph APIs (which actually do shaping).
### Type Changes (index.d.ts)
- Return value for MakeFromCmds correctly reflects the possibility of null.

View File

@ -1152,7 +1152,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
return true;
}))
.function("measureText", optional_override([](SkFont& self, std::string text) {
// TODO(kjlubick): This does not work well for non-ascii
// TODO(kjlubick): Remove this API
// Need to maybe add a helper in interface.js that supports UTF-8
// Otherwise, go with std::wstring and set UTF-32 encoding.
return self.measureText(text.c_str(), text.length(), SkTextEncoding::kUTF8);

View File

@ -808,10 +808,7 @@ function CanvasRenderingContext2D(skcanvas) {
};
this.measureText = function(text) {
return {
width: this._font.measureText(text),
// TODO other measurements?
}
throw new Error('Clients wishing to properly measure text should use the Paragraph API').
};
this.moveTo = function(x, y) {