diff --git a/browser/confvars.sh b/browser/confvars.sh index 6935e05fa..212bbec9f 100644 --- a/browser/confvars.sh +++ b/browser/confvars.sh @@ -27,6 +27,10 @@ fi # Enable building ./signmar and running libmar signature tests MOZ_ENABLE_SIGNMAR=1 +if test "$OS_TARGET" = "WINNT"; then + MOZ_BUNDLED_FONTS=1 +fi + MOZ_CHROME_FILE_FORMAT=omni MOZ_DISABLE_EXPORT_JS=1 MOZ_SAFE_BROWSING=1 diff --git a/browser/fonts/README.txt b/browser/fonts/README.txt new file mode 100644 index 000000000..bf5cb7e6e --- /dev/null +++ b/browser/fonts/README.txt @@ -0,0 +1,9 @@ +Twemoji Mozilla +================ + +The upstream repository of Twemoji Mozilla can be found at + + https://github.com/mozilla/twemoji-colr + +Please refer commit history for the current version of the font. +This file purposely omits the version, so there is no need to update it here. diff --git a/browser/fonts/TwemojiMozilla.ttf b/browser/fonts/TwemojiMozilla.ttf new file mode 100644 index 000000000..28d484988 Binary files /dev/null and b/browser/fonts/TwemojiMozilla.ttf differ diff --git a/browser/fonts/moz.build b/browser/fonts/moz.build new file mode 100644 index 000000000..314d41bd0 --- /dev/null +++ b/browser/fonts/moz.build @@ -0,0 +1,11 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +if CONFIG['OS_ARCH'] in ('WINNT'): + DIST_SUBDIR = '' + FINAL_TARGET_FILES.fonts += [ + 'TwemojiMozilla.ttf' + ] diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 57247f17e..30c62c6a1 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -51,6 +51,9 @@ @RESPATH@/browser/defaults/profile/localstore.rdf @RESPATH@/browser/defaults/profile/mimeTypes.rdf @RESPATH@/dictionaries/* +#if defined(XP_WIN) +@RESPATH@/fonts/* +#endif @RESPATH@/hyphenation/* @RESPATH@/browser/@PREF_DIR@/firefox-l10n.js #ifdef HAVE_MAKENSISU diff --git a/browser/moz.build b/browser/moz.build index 571f51567..d4eaf26ef 100644 --- a/browser/moz.build +++ b/browser/moz.build @@ -12,6 +12,7 @@ DIRS += [ 'base', 'components', 'experiments', + 'fonts', 'fuel', 'locales', 'modules', diff --git a/build/valgrind/x86_64-redhat-linux-gnu.sup b/build/valgrind/x86_64-redhat-linux-gnu.sup index 45917e9ab..6feb8fade 100644 --- a/build/valgrind/x86_64-redhat-linux-gnu.sup +++ b/build/valgrind/x86_64-redhat-linux-gnu.sup @@ -179,6 +179,30 @@ fun:gdk_display_open ... } +# With older versions of fontconfig (e.g. 2.8.0 on taskcluster systems), +# there's an uninitialized memory usage and leak when loading app fonts. +{ + Bug 1231701 + Memcheck:Param + write(buf) + ... + fun:FcDirCacheWrite + fun:FcDirCacheScan + fun:FcConfigAddDirList + fun:FcConfigAppFontAddDir + ... +} +{ + Bug 1231701 + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:FcDirScanConfig + fun:FcDirCacheScan + fun:FcConfigAddDirList + fun:FcConfigAppFontAddDir + ... +} ################################### # Leaks in short lived precesses # diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index a4672e1d5..c96e107d9 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -383,6 +383,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, FallibleTArray &aBuffer) { gfxDWriteFontList *pFontList = gfxDWriteFontList::PlatformFontList(); + const uint32_t tagBE = NativeEndian::swapToBigEndian(aTableTag); // Don't use GDI table loading for symbol fonts or for // italic fonts in Arabic-script system locales because of @@ -393,24 +394,19 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, !mFont->IsSymbolFont()) { LOGFONTW logfont = { 0 }; - if (!InitLogFont(mFont, &logfont)) - return NS_ERROR_FAILURE; - - AutoDC dc; - AutoSelectFont font(dc.GetDC(), &logfont); - if (font.IsValid()) { - uint32_t tableSize = - ::GetFontData(dc.GetDC(), - NativeEndian::swapToBigEndian(aTableTag), 0, - nullptr, 0); - if (tableSize != GDI_ERROR) { - if (aBuffer.SetLength(tableSize, fallible)) { - ::GetFontData(dc.GetDC(), - NativeEndian::swapToBigEndian(aTableTag), 0, - aBuffer.Elements(), aBuffer.Length()); - return NS_OK; + if (InitLogFont(mFont, &logfont)) { + AutoDC dc; + AutoSelectFont font(dc.GetDC(), &logfont); + if (font.IsValid()) { + uint32_t tableSize = + ::GetFontData(dc.GetDC(), tagBE, 0, nullptr, 0); + if (tableSize != GDI_ERROR) { + if (aBuffer.SetLength(tableSize, fallible)) { + ::GetFontData(dc.GetDC(), tagBE, 0, + aBuffer.Elements(), aBuffer.Length()); + return NS_OK; + } } - return NS_ERROR_OUT_OF_MEMORY; } } return NS_ERROR_FAILURE; @@ -427,8 +423,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, void *tableContext = nullptr; BOOL exists; HRESULT hr = - fontFace->TryGetFontTable(NativeEndian::swapToBigEndian(aTableTag), - (const void**)&tableData, &len, + fontFace->TryGetFontTable(tagBE, (const void**)&tableData, &len, &tableContext, &exists); if (FAILED(hr) || !exists) { return NS_ERROR_FAILURE; @@ -648,7 +643,10 @@ gfxDWriteFontEntry::InitLogFont(IDWriteFont *aFont, LOGFONTW *aLogFont) IDWriteGdiInterop *gdi = gfxDWriteFontList::PlatformFontList()->GetGDIInterop(); hr = gdi->ConvertFontToLOGFONT(aFont, aLogFont, &isInSystemCollection); - return (FAILED(hr) ? false : true); + // If the font is not in the system collection, GDI will be unable to + // select it and load its tables, so we return false here to indicate + // failure, and let CopyFontTable fall back to DWrite native methods. + return (SUCCEEDED(hr) && isInSystemCollection); } bool diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 8cd03ede3..5569a2eef 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -850,6 +850,7 @@ static const char kFontSegoeUIEmoji[] = "Segoe UI Emoji"; static const char kFontSegoeUISymbol[] = "Segoe UI Symbol"; static const char kFontSylfaen[] = "Sylfaen"; static const char kFontTraditionalArabic[] = "Traditional Arabic"; +static const char kFontTwemojiMozilla[] = "Twemoji Mozilla"; static const char kFontUtsaah[] = "Utsaah"; static const char kFontYuGothic[] = "Yu Gothic"; @@ -860,6 +861,7 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, { if (aNextCh == 0xfe0fu) { aFontList.AppendElement(kFontSegoeUIEmoji); + aFontList.AppendElement(kFontTwemojiMozilla); } // Arial is used as the default fallback for system fallback @@ -871,9 +873,11 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, if (aNextCh == 0xfe0eu) { aFontList.AppendElement(kFontSegoeUISymbol); aFontList.AppendElement(kFontSegoeUIEmoji); + aFontList.AppendElement(kFontTwemojiMozilla); } else { if (aNextCh != 0xfe0fu) { aFontList.AppendElement(kFontSegoeUIEmoji); + aFontList.AppendElement(kFontTwemojiMozilla); } aFontList.AppendElement(kFontSegoeUISymbol); } diff --git a/layout/reftests/text/reftest.list b/layout/reftests/text/reftest.list index 7e2c4c5a6..cd405dd0b 100644 --- a/layout/reftests/text/reftest.list +++ b/layout/reftests/text/reftest.list @@ -183,10 +183,11 @@ HTTP(..) != 1170688.html 1170688-ref.html # Bug 727276: tests with variation selectors 15 and 16 to control emoji rendering style == emoji-03.html emoji-03-ref.html -# the next two will fail on OS X 10.6 and on Windows prior to 8.1 because no color emoji font is present, -# and also on Linux/Android/B2G platforms until we have color emoji fonts there -fails-if(OSX==1006||/^Windows\x20NT\x20(5|6\.[0-2])/.test(http.oscpu)||gtkWidget||Android) != emoji-03.html emoji-03-notref.html -fails-if(OSX==1006||/^Windows\x20NT\x20(5|6\.[0-2])/.test(http.oscpu)||gtkWidget||Android) == emoji-04.html emoji-04-ref.html +# the next two will fail on OS X 10.6 because no color emoji font is present, +# and also on Android/B2G platforms until we have color emoji fonts there. +# Tests rely on bundled EmojiOne Mozilla to pass on Windows <8.1 and Linux. +fails-if(OSX==1006||B2G||Android) != emoji-03.html emoji-03-notref.html +fails-if(OSX==1006||B2G||Android) == emoji-04.html emoji-04-ref.html != emoji-05.html emoji-05-notref.html # check that Graphite shaping (bug 631479) is working diff --git a/toolkit/content/license.html b/toolkit/content/license.html index 2ed3b36fa..4823ff7af 100644 --- a/toolkit/content/license.html +++ b/toolkit/content/license.html @@ -140,6 +140,9 @@ #endif
  • SunSoft License
  • SuperFastHash License
  • +#if defined(XP_WIN) +
  • Twemoji License
  • +#endif
  • Unicode License
  • University of California License
  • URL Validation Regexp License
  • @@ -4928,6 +4931,50 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    +#if defined(XP_WIN) +

    Twemoji License

    + +

    This license applies to the emoji art contained within the bundled +emoji font file.

    + +
    +Copyright (c) 2018 Twitter, Inc and other contributors.
    +
    +Creative Commons Attribution 4.0 International (CC BY 4.0)
    +
    +See https://creativecommons.org/licenses/by/4.0/legalcode or
    +for the human readable summary: https://creativecommons.org/licenses/by/4.0/
    +
    +You are free to:
    +
    +Share  copy and redistribute the material in any medium or format
    +
    +Adapt  remix, transform, and build upon the material for any purpose, even commercially.
    +
    +The licensor cannot revoke these freedoms as long as you follow the license terms.
    +
    +Under the following terms:
    +
    +Attribution  You must give appropriate credit, provide a link to the license,
    +and indicate if changes were made. You may do so in any reasonable manner,
    +but not in any way that suggests the licensor endorses you or your use.
    +
    +No additional restrictions  You may not apply legal terms or technological
    +measures that legally restrict others from doing anything the license permits.
    +
    +Notices:
    +
    +You do not have to comply with the license for elements of the material in
    +the public domain or where your use is permitted by an applicable exception or
    +limitation. No warranties are given. The license may not give you all of the
    +permissions necessary for your intended use. For example, other rights such as
    +publicity, privacy, or moral rights may limit how you use the material.
    +
    + + +
    + +#endif

    Unicode License

    This license applies to certain files in the directories