From 87346193d6935ba659a76a9e461694da79ffe749 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Thu, 4 Jun 2015 23:24:55 +0900 Subject: [PATCH] Bug 1171357 - log font matching for textruns. r=m_kato --- gfx/thebes/gfxTextRun.cpp | 47 ++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index e00defe16ad..dd5a41896fb 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -2986,16 +2986,43 @@ void gfxFontGroup::ComputeRanges(nsTArray& aRanges, aRanges[lastRangeIndex].end = aLength; -#if 0 - // dump out font matching info - if (mStyle.systemFont) return; - for (size_t i = 0, i_end = aRanges.Length(); i < i_end; i++) { - const gfxTextRange& r = aRanges[i]; - printf("fontmatch %zd:%zd font: %s (%d)\n", - r.start, r.end, - (r.font.get() ? - NS_ConvertUTF16toUTF8(r.font->GetName()).get() : ""), - r.matchType); +#ifndef RELEASE_BUILD + PRLogModuleInfo *log = (mStyle.systemFont ? + gfxPlatform::GetLog(eGfxLog_textrunui) : + gfxPlatform::GetLog(eGfxLog_textrun)); + + if (MOZ_UNLIKELY(PR_LOG_TEST(log, PR_LOG_DEBUG))) { + nsAutoCString lang; + mStyle.language->ToUTF8String(lang); + nsAutoString families; + mFamilyList.ToString(families); + + // collect the font matched for each range + nsAutoCString fontMatches; + for (size_t i = 0, i_end = aRanges.Length(); i < i_end; i++) { + char match[256]; + const gfxTextRange& r = aRanges[i]; + sprintf(match, " [%u:%u] %.200s (%s)", + r.start, r.end, + (r.font.get() ? + NS_ConvertUTF16toUTF8(r.font->GetName()).get() : ""), + (r.matchType == gfxTextRange::kFontGroup ? + "list" : + (r.matchType == gfxTextRange::kPrefsFallback) ? + "prefs" : "sys")); + fontMatches.Append(match); + } + MOZ_LOG(log, PR_LOG_DEBUG,\ + ("(%s-fontmatching) fontgroup: [%s] default: %s lang: %s script: %d" + "%s\n", + (mStyle.systemFont ? "textrunui" : "textrun"), + NS_ConvertUTF16toUTF8(families).get(), + (mFamilyList.GetDefaultFontType() == eFamily_serif ? + "serif" : + (mFamilyList.GetDefaultFontType() == eFamily_sans_serif ? + "sans-serif" : "none")), + lang.get(), aRunScript, + fontMatches.get())); } #endif }