aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fonts
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-11-09 13:45:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-10 15:30:57 +0000
commitcb6940bf42e39271afe0fb3c2bfdd9e28d12f504 (patch)
tree9d600f8679a5694c3b4ff71166d67cf09a37d433 /src/fonts
parent35970ec0c861f7b5ee7cca2789b7dc5954cb6bb4 (diff)
DM FontMgr updates
- return nullptr for the various makeFromFoo() that we can't support, and tweak a few unit tests to bail out early when they do - create FontStyleSet and SkTypefaces once - abort early from FontHostStream if we can't openStream() - implement SkTestTypeface::onCreateFamilyNameIterator() with SkOTUtils::LocalizedStrings_SingleName() so FontNames passes - pin out-of-range glyph IDs to zero in SkTestTypeface Change-Id: Iac53265e331fc1c5c507513af3ab299063e6610a Reviewed-on: https://skia-review.googlesource.com/69501 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/fonts')
-rw-r--r--src/fonts/SkTestScalerContext.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/fonts/SkTestScalerContext.cpp b/src/fonts/SkTestScalerContext.cpp
index ec53c54fa2..34ec6af849 100644
--- a/src/fonts/SkTestScalerContext.cpp
+++ b/src/fonts/SkTestScalerContext.cpp
@@ -13,6 +13,7 @@
#include "SkGlyph.h"
#include "SkMakeUnique.h"
#include "SkMask.h"
+#include "SkOTUtils.h"
#include "SkPaintPriv.h"
#include "SkScalerContext.h"
#include "SkTestScalerContext.h"
@@ -133,13 +134,17 @@ void SkTestTypeface::getFontMetrics(SkPaint::FontMetrics* metrics) {
}
void SkTestTypeface::getMetrics(SkGlyph* glyph) {
+ SkGlyphID glyphID = glyph->getGlyphID();
+ glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0;
+
// TODO(benjaminwagner): Update users to use floats.
- glyph->fAdvanceX = SkFixedToFloat(fTestFont->fWidths[glyph->getGlyphID()]);
+ glyph->fAdvanceX = SkFixedToFloat(fTestFont->fWidths[glyphID]);
glyph->fAdvanceY = 0;
}
-void SkTestTypeface::getPath(SkGlyphID glyph, SkPath* path) {
- *path = *fTestFont->fPaths[glyph];
+void SkTestTypeface::getPath(SkGlyphID glyphID, SkPath* path) {
+ glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0;
+ *path = *fTestFont->fPaths[glyphID];
}
void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const {
@@ -183,9 +188,7 @@ void SkTestTypeface::onGetFamilyName(SkString* familyName) const {
SkTypeface::LocalizedStrings* SkTestTypeface::onCreateFamilyNameIterator() const {
SkString familyName(fTestFont->fName);
SkString language("und"); //undetermined
-//SkASSERT(0); // incomplete
- return nullptr;
-// return new SkOTUtils::LocalizedStrings_SingleName(familyName, language);
+ return new SkOTUtils::LocalizedStrings_SingleName(familyName, language);
}
class SkTestScalerContext : public SkScalerContext {