Skip to content

Commit

Permalink
New setting to decide whether we want the engine to load ICU mapping. (
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetf authored Feb 22, 2019
1 parent 36d495d commit 204e7da
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions common/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ std::string Settings::ToString() const {
stream << "enable_software_rendering: " << enable_software_rendering
<< std::endl;
stream << "log_tag: " << log_tag << std::endl;
stream << "icu_initialization_required: " << icu_initialization_required
<< std::endl;
stream << "icu_data_path: " << icu_data_path << std::endl;
stream << "assets_dir: " << assets_dir << std::endl;
stream << "assets_path: " << assets_path << std::endl;
Expand Down
6 changes: 6 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ struct Settings {
bool skia_deterministic_rendering_on_cpu = false;
bool verbose_logging = false;
std::string log_tag = "flutter";

// The icu_initialization_required setting does not have a corresponding
// switch because it is intended to be decided during build time, not runtime.
// Some companies apply source modification here because their build system
// brings its own ICU data files.
bool icu_initialization_required = true;
std::string icu_data_path;
MappingCallback icu_mapper;

Expand Down
14 changes: 8 additions & 6 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ static void PerformInitializationTasks(const blink::Settings& settings) {
FML_DLOG(INFO) << "Skia deterministic rendering is enabled.";
}

if (settings.icu_data_path.size() != 0) {
fml::icu::InitializeICU(settings.icu_data_path);
} else if (settings.icu_mapper) {
fml::icu::InitializeICUFromMapping(settings.icu_mapper());
} else {
FML_DLOG(WARNING) << "Skipping ICU initialization in the shell.";
if (settings.icu_initialization_required) {
if (settings.icu_data_path.size() != 0) {
fml::icu::InitializeICU(settings.icu_data_path);
} else if (settings.icu_mapper) {
fml::icu::InitializeICUFromMapping(settings.icu_mapper());
} else {
FML_DLOG(WARNING) << "Skipping ICU initialization in the shell.";
}
}
});
}
Expand Down
20 changes: 11 additions & 9 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,17 @@ blink::Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
command_line.GetOptionValue(FlagForSwitch(Switch::CacheDirPath),
&settings.temp_directory_path);

command_line.GetOptionValue(FlagForSwitch(Switch::ICUDataFilePath),
&settings.icu_data_path);
if (command_line.HasOption(FlagForSwitch(Switch::ICUSymbolPrefix))) {
std::string icu_symbol_prefix;
command_line.GetOptionValue(FlagForSwitch(Switch::ICUSymbolPrefix),
&icu_symbol_prefix);
settings.icu_mapper = [icu_symbol_prefix] {
return GetSymbolMapping(icu_symbol_prefix);
};
if (settings.icu_initialization_required) {
command_line.GetOptionValue(FlagForSwitch(Switch::ICUDataFilePath),
&settings.icu_data_path);
if (command_line.HasOption(FlagForSwitch(Switch::ICUSymbolPrefix))) {
std::string icu_symbol_prefix;
command_line.GetOptionValue(FlagForSwitch(Switch::ICUSymbolPrefix),
&icu_symbol_prefix);
settings.icu_mapper = [icu_symbol_prefix] {
return GetSymbolMapping(icu_symbol_prefix);
};
}
}

settings.use_test_fonts =
Expand Down

0 comments on commit 204e7da

Please sign in to comment.