CodeViewer icon indicating copy to clipboard operation
CodeViewer copied to clipboard

Fix font size and add line height

Open gewill opened this issue 2 years ago • 0 comments

What's this PR do?

  • [x] Fix font size by set viewport, that means we set point as font size.
  • [x] Add line height, then we can calculate the code viewer's total height.

Here is an example, how set CodeViewer height:

   CodeViewer(content: .constant(code), mode: CodeWebView.Mode(rawValue: configuration.language ?? "") ?? .text, darkTheme: .tomorrow_night_eighties, lightTheme: .tomorrow, isReadOnly: true, fontSize: 14, lineHeight: 1.3)
          .frame(height: CGFloat(code.components(separatedBy: .newlines).count) * 14 * 1.3)

gewill avatar Apr 28 '23 15:04 gewill