mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09:00
Font fallback should detect emoji range for color emoji font.
This commit is contained in:
parent
826e420144
commit
1aa30f609c
6 changed files with 47 additions and 50 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsIScreenManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsUnicodeProperties.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "cairo.h"
|
||||
#include "VsyncSource.h"
|
||||
|
|
@ -32,6 +33,7 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::unicode;
|
||||
|
||||
static FT_Library gPlatformFTLibrary = nullptr;
|
||||
|
||||
|
|
@ -168,19 +170,17 @@ gfxAndroidPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
static const char kNotoSansCJKJP[] = "Noto Sans CJK JP";
|
||||
static const char kNotoColorEmoji[] = "Noto Color Emoji";
|
||||
|
||||
if (aNextCh == 0xfe0fu) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
aFontList.AppendElement(kNotoColorEmoji);
|
||||
EmojiPresentation emoji = GetEmojiPresentation(aCh);
|
||||
if (emoji != EmojiPresentation::TextOnly) {
|
||||
if (aNextCh == kVariationSelector16 ||
|
||||
(aNextCh != kVariationSelector15 &&
|
||||
emoji == EmojiPresentation::EmojiDefault)) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
aFontList.AppendElement(kNotoColorEmoji);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IS_IN_BMP(aCh)) {
|
||||
uint32_t p = aCh >> 16;
|
||||
if (p == 1) { // try color emoji font, unless VS15 (text style) present
|
||||
if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
|
||||
aFontList.AppendElement(kNotoColorEmoji);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (IS_IN_BMP(aCh)) {
|
||||
// try language-specific "Droid Sans *" and "Noto Sans *" fonts for
|
||||
// certain blocks, as most devices probably have these
|
||||
uint8_t block = (aCh >> 8) & 0xff;
|
||||
|
|
|
|||
|
|
@ -240,9 +240,14 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
Script aRunScript,
|
||||
nsTArray<const char*>& aFontList)
|
||||
{
|
||||
if (aNextCh == 0xfe0fu) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
aFontList.AppendElement(kFontTwemojiMozilla);
|
||||
EmojiPresentation emoji = GetEmojiPresentation(aCh);
|
||||
if (emoji != EmojiPresentation::TextOnly) {
|
||||
if (aNextCh == kVariationSelector16 ||
|
||||
(aNextCh != kVariationSelector15 &&
|
||||
emoji == EmojiPresentation::EmojiDefault)) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
aFontList.AppendElement(kFontTwemojiMozilla);
|
||||
}
|
||||
}
|
||||
|
||||
aFontList.AppendElement(kFontDejaVuSerif);
|
||||
|
|
@ -250,15 +255,6 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
aFontList.AppendElement(kFontDejaVuSans);
|
||||
aFontList.AppendElement(kFontFreeSans);
|
||||
|
||||
if (!IS_IN_BMP(aCh)) {
|
||||
uint32_t p = aCh >> 16;
|
||||
if (p == 1) { // try color emoji font, unless VS15 (text style) present
|
||||
if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
|
||||
aFontList.AppendElement(kFontTwemojiMozilla);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add fonts for CJK ranges
|
||||
// xxx - this isn't really correct, should use the same CJK font ordering
|
||||
// as the pref font code
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/VsyncDispatcher.h"
|
||||
#include "nsUnicodeProperties.h"
|
||||
#include "qcms.h"
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::unicode;
|
||||
|
||||
// cribbed from CTFontManager.h
|
||||
enum {
|
||||
|
|
@ -195,23 +197,24 @@ gfxPlatformMac::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
Script aRunScript,
|
||||
nsTArray<const char*>& aFontList)
|
||||
{
|
||||
if (aNextCh == 0xfe0f) {
|
||||
aFontList.AppendElement(kFontAppleColorEmoji);
|
||||
EmojiPresentation emoji = GetEmojiPresentation(aCh);
|
||||
if (emoji != EmojiPresentation::TextOnly) {
|
||||
if (aNextCh == kVariationSelector16 ||
|
||||
(aNextCh != kVariationSelector15 &&
|
||||
emoji == EmojiPresentation::EmojiDefault)) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
aFontList.AppendElement(kFontAppleColorEmoji);
|
||||
}
|
||||
}
|
||||
|
||||
aFontList.AppendElement(kFontLucidaGrande);
|
||||
|
||||
if (!IS_IN_BMP(aCh)) {
|
||||
uint32_t p = aCh >> 16;
|
||||
uint32_t b = aCh >> 8;
|
||||
if (p == 1) {
|
||||
if (b >= 0x1f0 && b < 0x1f7) {
|
||||
aFontList.AppendElement(kFontAppleColorEmoji);
|
||||
} else {
|
||||
aFontList.AppendElement(kFontAppleSymbols);
|
||||
aFontList.AppendElement(kFontSTIXGeneral);
|
||||
aFontList.AppendElement(kFontGeneva);
|
||||
}
|
||||
aFontList.AppendElement(kFontAppleSymbols);
|
||||
aFontList.AppendElement(kFontSTIXGeneral);
|
||||
aFontList.AppendElement(kFontGeneva);
|
||||
} else if (p == 2) {
|
||||
// OSX installations with MS Office may have these fonts
|
||||
aFontList.AppendElement(kFontMingLiUExtB);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ using mozilla::services::GetObserverService;
|
|||
static const char16_t kEllipsisChar[] = { 0x2026, 0x0 };
|
||||
static const char16_t kASCIIPeriodsChar[] = { '.', '.', '.', 0x0 };
|
||||
|
||||
const uint32_t kVariationSelector15 = 0xFE0E; // text presentation
|
||||
const uint32_t kVariationSelector16 = 0xFE0F; // emoji presentation
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
#define DEBUG_TEXT_RUN_STORAGE_METRICS
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "gfxWindowsSurface.h"
|
||||
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsUnicodeProperties.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
|
@ -81,6 +82,7 @@ using namespace mozilla::gfx;
|
|||
using namespace mozilla::layers;
|
||||
using namespace mozilla::widget;
|
||||
using namespace mozilla::image;
|
||||
using namespace mozilla::unicode;
|
||||
|
||||
IDWriteRenderingParams* GetDwriteRenderingParams(bool aGDI)
|
||||
{
|
||||
|
|
@ -683,9 +685,15 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
Script aRunScript,
|
||||
nsTArray<const char*>& aFontList)
|
||||
{
|
||||
if (aNextCh == 0xfe0fu) {
|
||||
aFontList.AppendElement(kFontSegoeUIEmoji);
|
||||
aFontList.AppendElement(kFontTwemojiMozilla);
|
||||
EmojiPresentation emoji = GetEmojiPresentation(aCh);
|
||||
if (emoji != EmojiPresentation::TextOnly) {
|
||||
if (aNextCh == kVariationSelector16 ||
|
||||
(aNextCh != kVariationSelector15 &&
|
||||
emoji == EmojiPresentation::EmojiDefault)) {
|
||||
// if char is followed by VS16, try for a color emoji glyph
|
||||
// XXX: For Win8+ native, aFontList.AppendElement(kFontSegoeUIEmoji);
|
||||
aFontList.AppendElement(kFontTwemojiMozilla);
|
||||
}
|
||||
}
|
||||
|
||||
// Arial is used as the default fallback for system fallback
|
||||
|
|
@ -694,17 +702,7 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
|||
if (!IS_IN_BMP(aCh)) {
|
||||
uint32_t p = aCh >> 16;
|
||||
if (p == 1) { // SMP plane
|
||||
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);
|
||||
}
|
||||
aFontList.AppendElement(kFontSegoeUISymbol);
|
||||
aFontList.AppendElement(kFontEbrima);
|
||||
aFontList.AppendElement(kFontNirmalaUI);
|
||||
aFontList.AppendElement(kFontCambriaMath);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ enum EmojiPresentation {
|
|||
EmojiDefault = 2
|
||||
};
|
||||
|
||||
const uint32_t kVariationSelector15 = 0xFE0E; // text presentation
|
||||
const uint32_t kVariationSelector16 = 0xFE0F; // emoji presentation
|
||||
|
||||
// ICU is available, so simply forward to its API
|
||||
|
||||
extern const hb_unicode_general_category_t sICUtoHBcategory[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue