Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"text_scaling_factor" should default to 1 if unset #392

Closed
t123yh opened this issue Oct 1, 2023 · 1 comment · Fixed by #393
Closed

"text_scaling_factor" should default to 1 if unset #392

t123yh opened this issue Oct 1, 2023 · 1 comment · Fixed by #393
Labels
engine Topics of Flutter Engine and its artifacts enhancement New feature or request

Comments

@t123yh
Copy link
Contributor

t123yh commented Oct 1, 2023

Related commit: c5a7852

I recently upgraded from 3.10.2 to 3.13.6, and all my text disappeared. I found the reason is that "text_scale_factor" is set to zero after digging hard through Skia font rendering code.

I use a custom main function in my app:

int main(int argc, char** argv) {
  // Creates the Flutter project.
  const auto bundle_path = std::string(".");
  const std::wstring fl_path(bundle_path.begin(), bundle_path.end());
  flutter::DartProject project(fl_path);
  auto command_line_arguments = std::vector<std::string>();
  command_line_arguments.push_back("embedded");
  project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

  flutter::FlutterViewController::ViewProperties view_properties = {};
  view_properties.width = 800;
  view_properties.height = 480;
  view_properties.view_mode = flutter::FlutterViewController::ViewMode::kFullscreen;
  view_properties.view_rotation = flutter::FlutterViewController::ViewRotation::kRotation_0;
  view_properties.use_mouse_cursor = false;
  view_properties.use_onscreen_keyboard = false;
  view_properties.use_window_decoration = false;
  view_properties.force_scale_factor = true;
  view_properties.scale_factor = 1;
  // view_properties.text_scale_factor = 1; <===== This was missing

  // The Flutter instance hosted by this window.
  FlutterWindow window(view_properties, project);
  if (!window.OnCreate()) {
    return 0;
  }
  window.Run();
  window.OnDestroy();

  return 0;
}

Before upgrading to 3.13, there's no text_scale_factor. After upgrading to 3.13, text_scale_factor will default to zero if unspecified, and this will cause all text disappear.

I suggest add some check in the embedder, and if text_scale_factor is zero, then set it to 1 or print a warning, to avoid this kind of mistakes. Also we can set text_scale_factor to 1 in the constructor of flutter::FlutterViewController::ViewProperties.

HidenoriMatsubayashi added a commit to HidenoriMatsubayashi/flutter-embedded-linux that referenced this issue Oct 2, 2023
Fixed sony#392

Signed-off-by: Hidenori Matsubayashi <Hidenori.Matsubayashi@gmail.com>
@HidenoriMatsubayashi HidenoriMatsubayashi added enhancement New feature or request engine Topics of Flutter Engine and its artifacts labels Oct 2, 2023
@HidenoriMatsubayashi
Copy link
Contributor

Agreed. I'll add that check. Thanks.

HidenoriMatsubayashi added a commit that referenced this issue Oct 2, 2023
Fixed #392

Signed-off-by: Hidenori Matsubayashi <Hidenori.Matsubayashi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Topics of Flutter Engine and its artifacts enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants