From 203339a2aa88bb31576233220d7ced73920a596f Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Thu, 23 Aug 2018 20:58:14 +0000 Subject: Fix shadowed variables This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison Reviewed-by: Tom Sepez Reviewed-by: Henrique Nakashima --- core/fxge/cfx_fontmapper.cpp | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'core/fxge/cfx_fontmapper.cpp') diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index c7a7015680..461094d81e 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -149,6 +149,14 @@ const AltFontFamily g_AltFontFamilies[] = { {"ForteMT", "Forte"}, }; +#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_ +const char kNarrowFamily[] = "LiberationSansNarrow"; +#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_ +const char kNarrowFamily[] = "RobotoCondensed"; +#else +const char kNarrowFamily[] = "ArialNarrow"; +#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_ + ByteString TT_NormalizeName(const char* family) { ByteString norm(family); norm.Remove(' '); @@ -415,14 +423,16 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, ByteString style; bool bHasComma = false; bool bHasHyphen = false; - auto pos = SubstName.Find(",", 0); - if (pos.has_value()) { - family = SubstName.Left(pos.value()); - PDF_GetStandardFontName(&family); - style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1)); - bHasComma = true; - } else { - family = SubstName; + { + Optional pos = SubstName.Find(",", 0); + if (pos.has_value()) { + family = SubstName.Left(pos.value()); + PDF_GetStandardFontName(&family); + style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1)); + bHasComma = true; + } else { + family = SubstName; + } } for (; iBaseFont < 12; iBaseFont++) { if (family == ByteStringView(g_Base14FontNames[iBaseFont])) @@ -443,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, } else { iBaseFont = kNumStandardFonts; if (!bHasComma) { - pos = family.ReverseFind('-'); + Optional pos = family.ReverseFind('-'); if (pos.has_value()) { style = family.Right(family.GetLength() - (pos.value() + 1)); family = family.Left(pos.value()); @@ -540,19 +550,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, bItalic = italic_angle != 0; weight = old_weight; } -#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_ - const char* narrow_family = "LiberationSansNarrow"; -#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_ - const char* narrow_family = "RobotoCondensed"; -#else - const char* narrow_family = "ArialNarrow"; -#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_ - auto pos = SubstName.Find("Narrow"); + Optional pos = SubstName.Find("Narrow"); if (pos.has_value() && pos.value() != 0) - family = narrow_family; + family = kNarrowFamily; pos = SubstName.Find("Condensed"); if (pos.has_value() && pos.value() != 0) - family = narrow_family; + family = kNarrowFamily; } else { pSubstFont->m_bSubstCJK = true; if (nStyle) -- cgit v1.2.3