Skip to content

Commit

Permalink
[Tizen] Cherrypicks from flutter-3.3.0-tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-kim committed Feb 6, 2023
1 parent 800594f commit 1fa634f
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ vars = {
"checkout_llvm": False,

# Setup Git hooks by default.
"setup_githooks": True,
"setup_githooks": False,

# Upstream URLs for third party dependencies, used in
# determining common ancestor commit for vulnerability scanning
Expand Down
8 changes: 5 additions & 3 deletions third_party/txt/src/minikin/FontCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,9 @@ void FontCollection::itemize(const uint16_t* string,
if (!shouldContinueRun) {
const std::shared_ptr<FontFamily>& family = getFamilyForChar(
ch, isVariationSelector(nextCh) ? nextCh : 0, langListId, variant);
if (utf16Pos == 0 || family.get() != lastFamily) {
if (utf16Pos == 0 || family.get() != lastFamily ||
(!(U_GET_GC_MASK(prevCh) & U_GC_L_MASK) &&
(U_GET_GC_MASK(ch) & U_GC_L_MASK))) {
size_t start = utf16Pos;
// Workaround for combining marks and emoji modifiers until we implement
// per-cluster font selection: if a combining mark or an emoji modifier
Expand All @@ -528,8 +530,8 @@ void FontCollection::itemize(const uint16_t* string,
}
start -= prevChLength;
}
result->push_back(
{family->getClosestMatch(style), static_cast<int>(start), 0});
result->push_back({family->getClosestMatch(style, ch, variant),
static_cast<int>(start), 0});
run = &result->back();
lastFamily = family.get();
}
Expand Down
23 changes: 18 additions & 5 deletions third_party/txt/src/minikin/FontFamily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,28 @@ static FontFakery computeFakery(FontStyle wanted, FontStyle actual) {
return FontFakery(isFakeBold, isFakeItalic);
}

FakedFont FontFamily::getClosestMatch(FontStyle style) const {
FakedFont FontFamily::getClosestMatch(
FontStyle style,
uint32_t codepoint /* = 0 */,
uint32_t variationSelector /* = 0 */) const {
const Font* bestFont = nullptr;
int bestMatch = 0;
int bestMatch = INT_MAX;
for (size_t i = 0; i < mFonts.size(); i++) {
const Font& font = mFonts[i];
int match = computeMatch(font.style, style);
if (i == 0 || match < bestMatch) {
bestFont = &font;
bestMatch = match;
bool result = false;
if (codepoint != 0) {
hb_font_t* hbFont = getHbFontLocked(font.typeface.get());
uint32_t unusedGlyph = 0;
result =
hb_font_get_glyph(hbFont, codepoint, variationSelector, &unusedGlyph);
hb_font_destroy(hbFont);
}
if (codepoint == 0 || (codepoint != 0 && result)) {
if (match < bestMatch) {
bestFont = &font;
bestMatch = match;
}
}
}
if (bestFont != nullptr) {
Expand Down
4 changes: 3 additions & 1 deletion third_party/txt/src/minikin/FontFamily.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ class FontFamily {
static bool analyzeStyle(const std::shared_ptr<MinikinFont>& typeface,
int* weight,
bool* italic);
FakedFont getClosestMatch(FontStyle style) const;
FakedFont getClosestMatch(FontStyle style,
uint32_t codepoint = 0,
uint32_t variationSelector = 0) const;

uint32_t langId() const { return mLangId; }
int variant() const { return mVariant; }
Expand Down
21 changes: 21 additions & 0 deletions third_party/txt/src/txt/font_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,27 @@ void FontCollection::SortSkTypefaces(
std::sort(
sk_typefaces.begin(), sk_typefaces.end(),
[](const sk_sp<SkTypeface>& a, const sk_sp<SkTypeface>& b) {
{
// A workaround to prevent emoji fonts being selected for normal text
// when normal and emoji fonts are mixed in the same font family.
bool a_isEmojiFont = false;
bool b_isEmojiFont = false;
SkString postScriptName;
a->getPostScriptName(&postScriptName);
if (postScriptName.contains("Emoji")) {
a_isEmojiFont = true;
}
b->getPostScriptName(&postScriptName);
if (postScriptName.contains("Emoji")) {
b_isEmojiFont = true;
}
if (a_isEmojiFont && !b_isEmojiFont) {
return false;
} else if (!a_isEmojiFont && b_isEmojiFont) {
return true;
}
}

SkFontStyle a_style = a->fontStyle();
SkFontStyle b_style = b->fontStyle();

Expand Down
4 changes: 2 additions & 2 deletions third_party/txt/src/txt/platform_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
namespace txt {

std::vector<std::string> GetDefaultFontFamilies() {
return {"Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", "Arial"};
return {"TizenDefaultFont", "SamsungOneUI"};
}

sk_sp<SkFontMgr> GetDefaultFontManager(uint32_t font_initialization_data) {
#ifdef FLUTTER_USE_FONTCONFIG
return SkFontMgr_New_FontConfig(nullptr);
return SkFontMgr::RefDefault();
#else
return SkFontMgr_New_Custom_Directory("/usr/share/fonts/");
#endif
Expand Down
25 changes: 10 additions & 15 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,7 @@ def cpu_for_target_arch(arch):

def is_host_build(args):
# If target_os == None, then this is a host build.
if args.target_os is None:
return True
# For linux arm64 builds, we cross compile from x64 hosts, so the
# target_os='linux' and linux-cpu='arm64'
if args.target_os == 'linux' and args.linux_cpu == 'arm64':
return True
# The Mac and host targets are redundant. Again, necessary to disambiguate
# during cross-compilation.
if args.target_os == 'mac':
return True
return False
return args.target_os is None


# Determines whether a prebuilt Dart SDK can be used instead of building one.
Expand Down Expand Up @@ -435,7 +425,8 @@ def to_gn_args(args):
else:
gn_args['skia_use_gl'] = args.target_os != 'fuchsia'

if sys.platform == 'darwin' and args.target_os not in ['android', 'fuchsia']:
if sys.platform == 'darwin' and args.target_os not in ['android', 'fuchsia',
'linux']:
# OpenGL is deprecated on macOS > 10.11.
# This is not necessarily needed but enabling this until we have a way to
# build a macOS metal only shell and a gl only shell.
Expand Down Expand Up @@ -529,8 +520,8 @@ def to_gn_args(args):

# Enable pointer compression on 64-bit mobile targets. iOS is excluded due to
# its inability to allocate address space without allocating memory.
if args.target_os in ['android'] and gn_args['target_cpu'] in ['x64', 'arm64'
]:
if args.target_os in ['android', 'linux'
] and gn_args['target_cpu'] in ['x64', 'arm64']:
gn_args['dart_use_compressed_pointers'] = True

if args.fuchsia_target_api_level is not None:
Expand All @@ -541,6 +532,10 @@ def to_gn_args(args):
'fuchsia/target_api_level')) as file:
gn_args['fuchsia_target_api_level'] = int(file.read().strip())

# Don't use the default Linux sysroot when buliding for Linux on macOS.
if sys.platform == 'darwin' and args.target_os == 'linux':
gn_args['use_default_linux_sysroot'] = False

# Flags for Dart features:
if args.use_mallinfo2:
gn_args['dart_use_mallinfo2'] = args.use_mallinfo2
Expand All @@ -562,7 +557,7 @@ def to_gn_args(args):
# There is a special case for Android on Windows because there we _only_ build
# gen_snapshot, but the build defines otherwise make it look like the build is
# for a host Windows build and make GN think we will be building ANGLE.
if is_host_build(args) or (args.target_os == 'android' and
if is_host_build(args) or (args.target_os == 'linux' and
get_host_os() == 'win'):
# Do not build unnecessary parts of the ANGLE tree.
gn_args['angle_build_all'] = False
Expand Down

0 comments on commit 1fa634f

Please sign in to comment.