فهرست منبع

Browser+Ladybird: Render text in the JS console with a monospace font

Timothy Flynn 2 سال پیش
والد
کامیت
61c0174fec
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 3 1
      Ladybird/ConsoleWidget.cpp
  2. 1 1
      Userland/Applications/Browser/ConsoleWidget.cpp

+ 3 - 1
Ladybird/ConsoleWidget.cpp

@@ -12,6 +12,7 @@
 #include "WebContentView.h"
 #include "WebContentView.h"
 #include <AK/StringBuilder.h>
 #include <AK/StringBuilder.h>
 #include <LibJS/MarkupGenerator.h>
 #include <LibJS/MarkupGenerator.h>
+#include <QFontDatabase>
 #include <QLineEdit>
 #include <QLineEdit>
 #include <QPalette>
 #include <QPalette>
 #include <QPushButton>
 #include <QPushButton>
@@ -41,7 +42,7 @@ ConsoleWidget::ConsoleWidget()
     if (is_using_dark_system_theme(*this))
     if (is_using_dark_system_theme(*this))
         m_output_view->update_palette(WebContentView::PaletteMode::Dark);
         m_output_view->update_palette(WebContentView::PaletteMode::Dark);
 
 
-    m_output_view->load("data:text/html,<html></html>"sv);
+    m_output_view->load("data:text/html,<html style=\"font: 10pt monospace;\"></html>"sv);
     // Wait until our output WebView is loaded, and then request any messages that occurred before we existed
     // Wait until our output WebView is loaded, and then request any messages that occurred before we existed
     m_output_view->on_load_finish = [this](auto&) {
     m_output_view->on_load_finish = [this](auto&) {
         if (on_request_messages)
         if (on_request_messages)
@@ -56,6 +57,7 @@ ConsoleWidget::ConsoleWidget()
     layout()->addWidget(bottom_container);
     layout()->addWidget(bottom_container);
 
 
     m_input = new QLineEdit(bottom_container);
     m_input = new QLineEdit(bottom_container);
+    m_input->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
     bottom_container->layout()->addWidget(m_input);
     bottom_container->layout()->addWidget(m_input);
 
 
     QObject::connect(m_input, &QLineEdit::returnPressed, [this] {
     QObject::connect(m_input, &QLineEdit::returnPressed, [this] {

+ 1 - 1
Userland/Applications/Browser/ConsoleWidget.cpp

@@ -25,7 +25,7 @@ ConsoleWidget::ConsoleWidget()
     set_fill_with_background_color(true);
     set_fill_with_background_color(true);
 
 
     m_output_view = add<WebView::OutOfProcessWebView>();
     m_output_view = add<WebView::OutOfProcessWebView>();
-    m_output_view->load("data:text/html,<html></html>"sv);
+    m_output_view->load("data:text/html,<html style=\"font: 10pt monospace;\"></html>"sv);
     // Wait until our output WebView is loaded, and then request any messages that occurred before we existed
     // Wait until our output WebView is loaded, and then request any messages that occurred before we existed
     m_output_view->on_load_finish = [this](auto&) {
     m_output_view->on_load_finish = [this](auto&) {
         if (on_request_messages)
         if (on_request_messages)