SkShaper: Fix a couple of crashes when fonts aren't found
Change-Id: Id62bb0e0edde25fe90f63547d4dbedada2c09909 Reviewed-on: https://skia-review.googlesource.com/c/166803 Auto-Submit: Hal Canary <halcanary@google.com> Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
dd79121e8f
commit
0dfa208450
@ -71,6 +71,9 @@ HBBlob stream_to_blob(std::unique_ptr<SkStreamAsset> asset) {
|
||||
}
|
||||
|
||||
HBFont create_hb_font(SkTypeface* tf) {
|
||||
if (!tf) {
|
||||
return nullptr;
|
||||
}
|
||||
int index;
|
||||
HBBlob blob(stream_to_blob(std::unique_ptr<SkStreamAsset>(tf->openStream(&index))));
|
||||
HBFace face(hb_face_create(blob.get(), (unsigned)index));
|
||||
@ -601,6 +604,9 @@ SkPoint SkShaper::shape(SkTextBlobBuilder* builder,
|
||||
// TODO: language
|
||||
hb_buffer_guess_segment_properties(buffer);
|
||||
// TODO: features
|
||||
if (!font->currentHBFont()) {
|
||||
continue;
|
||||
}
|
||||
hb_shape(font->currentHBFont(), buffer, nullptr, 0);
|
||||
unsigned len = hb_buffer_get_length(buffer);
|
||||
if (len == 0) {
|
||||
|
@ -110,8 +110,11 @@ engines can easily be supported in a like manner.
|
||||
<span id="kerning">Does Skia shape text (kerning)?</span>
|
||||
---------------------------------------------------------
|
||||
|
||||
No. Skia provides interfaces to draw glyphs, but does not implement a
|
||||
text shaper. Skia's client's often use
|
||||
Shaping is the process that translates a span of Unicode text into a span of
|
||||
positioned glyphs with the apropriate typefaces.
|
||||
|
||||
Skia does not shape text. Skia provides interfaces to draw glyphs, but does
|
||||
not implement a text shaper. Skia's client's often use
|
||||
[HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to
|
||||
generate the glyphs and their positions, including kerning.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user