SkFontHost_FreeType: better debugging info
Change-Id: I53d4ef096437346c3cb1c74e9b9bad329b2cabee Reviewed-on: https://skia-review.googlesource.com/100180 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
1260f7a85a
commit
2bcd843162
@ -364,7 +364,7 @@ static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
|
||||
FT_Face rawFace;
|
||||
FT_Error err = FT_Open_Face(gFTLibrary->library(), &args, data->getIndex(), &rawFace);
|
||||
if (err) {
|
||||
SkDEBUGF(("ERROR: unable to open font '%x'\n", fontID));
|
||||
SK_TRACEFTR(err, "unable to open font '%x'", fontID);
|
||||
return nullptr;
|
||||
}
|
||||
rec->fFace.reset(rawFace);
|
||||
@ -852,7 +852,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
|
||||
FT_Size size;
|
||||
FT_Error err = FT_New_Size(fFaceRec->fFace.get(), &size);
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("FT_New_Size(%s) returned 0x%x.\n", fFaceRec->fFace->family_name, err));
|
||||
SK_TRACEFTR(err, "FT_New_Size(%s) failed.", fFaceRec->fFace->family_name);
|
||||
return nullptr;
|
||||
}
|
||||
return size;
|
||||
@ -864,15 +864,15 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
|
||||
|
||||
FT_Error err = FT_Activate_Size(ftSize.get());
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("FT_Activate_Size(%s) returned 0x%x.\n", fFaceRec->fFace->family_name, err));
|
||||
SK_TRACEFTR(err, "FT_Activate_Size(%s) failed.", fFaceRec->fFace->family_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FT_IS_SCALABLE(fFaceRec->fFace)) {
|
||||
err = FT_Set_Char_Size(fFaceRec->fFace.get(), scaleX, scaleY, 72, 72);
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("FT_Set_CharSize(%s, %f, %f) returned 0x%x.\n",
|
||||
fFaceRec->fFace->family_name, fScale.fX, fScale.fY, err));
|
||||
SK_TRACEFTR(err, "FT_Set_CharSize(%s, %f, %f) failed.",
|
||||
fFaceRec->fFace->family_name, fScale.fX, fScale.fY);
|
||||
return;
|
||||
}
|
||||
} else if (FT_HAS_FIXED_SIZES(fFaceRec->fFace)) {
|
||||
@ -885,8 +885,8 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
|
||||
|
||||
err = FT_Select_Size(fFaceRec->fFace.get(), fStrikeIndex);
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("FT_Select_Size(%s, %d) returned 0x%x.\n",
|
||||
fFaceRec->fFace->family_name, fStrikeIndex, err));
|
||||
SK_TRACEFTR(err, "FT_Select_Size(%s, %d) failed.",
|
||||
fFaceRec->fFace->family_name, fStrikeIndex);
|
||||
fStrikeIndex = -1;
|
||||
return;
|
||||
}
|
||||
@ -1210,8 +1210,10 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
|
||||
|
||||
FT_Error err = FT_Load_Glyph(fFace, glyph.getGlyphID(), fLoadGlyphFlags);
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph:%d width:%d height:%d rb:%d flags:%d) returned 0x%x\n",
|
||||
glyph.getGlyphID(), glyph.fWidth, glyph.fHeight, glyph.rowBytes(), fLoadGlyphFlags, err));
|
||||
SK_TRACEFTR(err, "SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph:%d "
|
||||
"width:%d height:%d rb:%d flags:%d) failed.",
|
||||
glyph.getGlyphID(), glyph.fWidth, glyph.fHeight, glyph.rowBytes(),
|
||||
fLoadGlyphFlags);
|
||||
clear_glyph_image(glyph);
|
||||
return;
|
||||
}
|
||||
@ -1246,8 +1248,8 @@ void SkScalerContext_FreeType::generatePath(SkGlyphID glyphID, SkPath* path) {
|
||||
FT_Error err = FT_Load_Glyph(fFace, glyphID, flags);
|
||||
|
||||
if (err != 0) {
|
||||
SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n",
|
||||
glyphID, flags, err));
|
||||
SK_TRACEFTR(err, "SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d "
|
||||
"flags:%d) failed.", glyphID, flags);
|
||||
path->reset();
|
||||
return;
|
||||
}
|
||||
|
@ -32,6 +32,22 @@
|
||||
|
||||
//#define SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
const char* SkTraceFtrGetError(int e) {
|
||||
switch ((FT_Error)e) {
|
||||
#undef FTERRORS_H_
|
||||
#define FT_ERRORDEF( e, v, s ) case v: return s;
|
||||
#define FT_ERROR_START_LIST
|
||||
#define FT_ERROR_END_LIST
|
||||
#include FT_ERRORS_H
|
||||
#undef FT_ERRORDEF
|
||||
#undef FT_ERROR_START_LIST
|
||||
#undef FT_ERROR_END_LIST
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
#endif // SK_DEBUG
|
||||
|
||||
namespace {
|
||||
|
||||
FT_Pixel_Mode compute_pixel_mode(SkMask::Format format) {
|
||||
@ -346,42 +362,6 @@ inline SkColorType SkColorType_for_SkMaskFormat(SkMask::Format format) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
||||
# define SK_STRING(X) SK_STRING_IMPL(X)
|
||||
# define SK_STRING_IMPL(X) #X
|
||||
|
||||
# undef __FTERRORS_H__
|
||||
# define FT_ERROR_START_LIST
|
||||
# define FT_ERRORDEF(e, v, s) { SK_STRING(e), s },
|
||||
# define FT_ERROR_END_LIST
|
||||
|
||||
const struct {
|
||||
const char* err_code;
|
||||
const char* err_msg;
|
||||
} sk_ft_errors[] = {
|
||||
# include FT_ERRORS_H
|
||||
};
|
||||
|
||||
void SkTraceFTR(const char* file, unsigned long line, FT_Error err, const char* msg) {
|
||||
SkString s;
|
||||
s.printf("%s:%lu:1: error: 0x%x ", file, line, err);
|
||||
if (0 <= err && (unsigned)err < SK_ARRAY_COUNT(sk_ft_errors)) {
|
||||
s.appendf("%s '%s' ", sk_ft_errors[err].err_code, sk_ft_errors[err].err_msg);
|
||||
} else {
|
||||
s.appendf("<unknown> ");
|
||||
}
|
||||
if (msg) {
|
||||
s.appendf("%s", msg);
|
||||
}
|
||||
SkDebugf("%s\n", s.c_str());
|
||||
}
|
||||
|
||||
# define SK_TRACEFTR(_err, _msg) SkTraceFTR(__FILE__, __LINE__, _err, _msg)
|
||||
#else
|
||||
# define SK_TRACEFTR(_err, _msg) sk_ignore_unused_variable(_err)
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
void SkScalerContext_FreeType_Base::generateGlyphImage(
|
||||
@ -411,7 +391,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(
|
||||
FT_Error err = FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V :
|
||||
FT_RENDER_MODE_LCD);
|
||||
if (err) {
|
||||
SK_TRACEFTR(err, "Could not render glyph.");
|
||||
SK_TRACEFTR(err, "Could not render glyph %x.", face->glyph);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,17 @@ typedef struct FT_FaceRec_* FT_Face;
|
||||
typedef struct FT_StreamRec_* FT_Stream;
|
||||
typedef signed long FT_Pos;
|
||||
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
const char* SkTraceFtrGetError(int);
|
||||
#define SK_TRACEFTR(ERR, MSG, ...) \
|
||||
SkDebugf("%s:%lu:1: error: 0x%x '%s' " MSG "\n", __FILE__, __LINE__, ERR, \
|
||||
SkTraceFtrGetError((int)(ERR)), __VA_ARGS__)
|
||||
#else
|
||||
#define SK_TRACEFTR(ERR, ...) do { sk_ignore_unused_variable(ERR); } while (false)
|
||||
#endif
|
||||
|
||||
|
||||
class SkScalerContext_FreeType_Base : public SkScalerContext {
|
||||
protected:
|
||||
// See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden
|
||||
|
Loading…
Reference in New Issue
Block a user