зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1256678 - Account for truncated font names in ScaledFontWin::GetFontFileData() - r=jfkthame
This commit is contained in:
Родитель
aab6e566af
Коммит
4a167320a0
|
@ -204,11 +204,20 @@ SFNTData::GetU16FullNames(Vector<mozilla::u16string>& aU16FullNames)
|
|||
|
||||
bool
|
||||
SFNTData::GetIndexForU16Name(const mozilla::u16string& aU16FullName,
|
||||
uint32_t* aIndex)
|
||||
uint32_t* aIndex, size_t aTruncatedLen)
|
||||
{
|
||||
for (size_t i = 0; i < mFonts.length(); ++i) {
|
||||
mozilla::u16string name;
|
||||
if (mFonts[i]->GetU16FullName(name) && name == aU16FullName) {
|
||||
if (!mFonts[i]->GetU16FullName(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aTruncatedLen) {
|
||||
MOZ_ASSERT(aU16FullName.length() <= aTruncatedLen);
|
||||
name = name.substr(0, aTruncatedLen);
|
||||
}
|
||||
|
||||
if (name == aU16FullName) {
|
||||
*aIndex = i;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,11 @@ public:
|
|||
*
|
||||
* @param aU16FullName full name to find.
|
||||
* @param aIndex out param for the index if found.
|
||||
* @param aTruncatedLen length to truncate the compared font name to.
|
||||
* @return true if the full name is successfully read.
|
||||
*/
|
||||
bool GetIndexForU16Name(const mozilla::u16string& aU16FullName, uint32_t* aIndex);
|
||||
bool GetIndexForU16Name(const mozilla::u16string& aU16FullName, uint32_t* aIndex,
|
||||
size_t aTruncatedLen = 0);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
|
|||
// We cast here because for VS2015 char16_t != wchar_t, even though they are
|
||||
// both 16 bit.
|
||||
if (!sfntData->GetIndexForU16Name(
|
||||
reinterpret_cast<char16_t*>(mLogFont.lfFaceName), &index)) {
|
||||
reinterpret_cast<char16_t*>(mLogFont.lfFaceName), &index, LF_FACESIZE - 1)) {
|
||||
gfxWarning() << "Failed to get index for face name.";
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче