diff --git a/apps/code/console_controller.cpp b/apps/code/console_controller.cpp index 971bdb6d7..e2caa19cf 100644 --- a/apps/code/console_controller.cpp +++ b/apps/code/console_controller.cpp @@ -25,7 +25,7 @@ ConsoleController::ConsoleController(Responder * parentResponder, App * pythonDe TextFieldDelegate(), MicroPython::ExecutionEnvironment(), m_pythonDelegate(pythonDelegate), - m_rowHeight(KDText::charSize(k_fontSize).height()), + m_rowHeight(k_font->glyphSize().height()), m_importScriptsWhenViewAppears(false), m_selectableTableView(this, this, this, this), m_editCell(this, this), diff --git a/apps/code/console_controller.h b/apps/code/console_controller.h index c2916d93b..0502d6476 100644 --- a/apps/code/console_controller.h +++ b/apps/code/console_controller.h @@ -16,7 +16,7 @@ class App; class ConsoleController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate, public TextFieldDelegate, public MicroPython::ExecutionEnvironment { public: - static constexpr KDText::FontSize k_fontSize = KDText::FontSize::Large; + static constexpr const KDFont * k_font = KDFont::LargeFont; ConsoleController(Responder * parentResponder, App * pythonDelegate, ScriptStore * scriptStore #if EPSILON_GETOPT diff --git a/apps/code/console_edit_cell.cpp b/apps/code/console_edit_cell.cpp index 2aced5b52..f1588275a 100644 --- a/apps/code/console_edit_cell.cpp +++ b/apps/code/console_edit_cell.cpp @@ -10,8 +10,8 @@ ConsoleEditCell::ConsoleEditCell(Responder * parentResponder, TextFieldDelegate HighlightCell(), Responder(parentResponder), m_textBuffer{0}, - m_promptView(ConsoleController::k_fontSize, nullptr, 0, 0.5), - m_textField(this, m_textBuffer, m_textBuffer, TextField::maxBufferSize(), delegate, false, ConsoleController::k_fontSize) + m_promptView(ConsoleController::k_font, nullptr, 0, 0.5), + m_textField(this, m_textBuffer, m_textBuffer, TextField::maxBufferSize(), delegate, false, ConsoleController::k_font) { } @@ -55,4 +55,4 @@ bool ConsoleEditCell::insertText(const char * text) { return m_textField.handleEventWithText(text); } -} \ No newline at end of file +} diff --git a/apps/code/console_line_cell.cpp b/apps/code/console_line_cell.cpp index c5f9e60fe..7593591b1 100644 --- a/apps/code/console_line_cell.cpp +++ b/apps/code/console_line_cell.cpp @@ -18,11 +18,11 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), KDColorWhite); - ctx->drawString(m_line->text(), KDPointZero, ConsoleController::k_fontSize, textColor(m_line), isHighlighted()? Palette::Select : KDColorWhite); + ctx->drawString(m_line->text(), KDPointZero, ConsoleController::k_font, textColor(m_line), isHighlighted()? Palette::Select : KDColorWhite); } KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(m_line->text(), ConsoleController::k_fontSize); + return ConsoleController::k_font->stringSize(m_line->text()); } ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder * parentResponder) : @@ -38,7 +38,7 @@ KDSize ConsoleLineCell::ScrollableConsoleLineView::minimalSizeForOptimalDisplay( ConsoleLineCell::ConsoleLineCell(Responder * parentResponder) : HighlightCell(), Responder(parentResponder), - m_promptView(ConsoleController::k_fontSize, I18n::Message::ConsolePrompt, 0, 0.5), + m_promptView(ConsoleController::k_font, I18n::Message::ConsolePrompt, 0, 0.5), m_scrollableView(this), m_line() { @@ -83,7 +83,7 @@ View * ConsoleLineCell::subviewAtIndex(int index) { void ConsoleLineCell::layoutSubviews() { if (m_line.isCommand()) { - KDSize promptSize = KDText::stringSize(I18n::translate(I18n::Message::ConsolePrompt), ConsoleController::k_fontSize); + KDSize promptSize = ConsoleController::k_font->stringSize(I18n::translate(I18n::Message::ConsolePrompt)); m_promptView.setFrame(KDRect(KDPointZero, promptSize.width(), bounds().height())); m_scrollableView.setFrame(KDRect(KDPoint(promptSize.width(), 0), bounds().width() - promptSize.width(), bounds().height())); return; diff --git a/apps/code/editor_view.cpp b/apps/code/editor_view.cpp index fdc3ec91f..96e52d434 100644 --- a/apps/code/editor_view.cpp +++ b/apps/code/editor_view.cpp @@ -6,13 +6,13 @@ namespace Code { /* EditorView */ -constexpr KDText::FontSize editorFontSize = KDText::FontSize::Large; +static constexpr const KDFont * editorFont = KDFont::LargeFont; EditorView::EditorView(Responder * parentResponder, App * pythonDelegate) : Responder(parentResponder), View(), - m_textArea(parentResponder, pythonDelegate, editorFontSize), - m_gutterView(editorFontSize) + m_textArea(parentResponder, pythonDelegate, editorFont), + m_gutterView(editorFont) { m_textArea.setScrollViewDelegate(this); } @@ -49,9 +49,9 @@ void EditorView::layoutSubviews() { /* EditorView::GutterView */ -EditorView::GutterView::GutterView(KDText::FontSize fontSize) : +EditorView::GutterView::GutterView(const KDFont * font) : View(), - m_fontSize(fontSize), + m_font(font), m_offset(0) { } @@ -62,21 +62,21 @@ void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(rect, backgroundColor); - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); - KDCoordinate firstLine = m_offset / charSize.height(); - KDCoordinate firstLinePixelOffset = m_offset - firstLine * charSize.height(); + KDCoordinate firstLine = m_offset / glyphSize.height(); + KDCoordinate firstLinePixelOffset = m_offset - firstLine * glyphSize.height(); char lineNumber[4]; - int numberOfLines = bounds().height() / charSize.height() + 1; + int numberOfLines = bounds().height() / glyphSize.height() + 1; for (int i=0; idrawString( lineNumber, - KDPoint(k_margin + leftPadding, i*charSize.height() - firstLinePixelOffset), - m_fontSize, + KDPoint(k_margin + leftPadding, i*glyphSize.height() - firstLinePixelOffset), + m_font, textColor, backgroundColor ); @@ -94,7 +94,7 @@ void EditorView::GutterView::setOffset(KDCoordinate offset) { KDSize EditorView::GutterView::minimalSizeForOptimalDisplay() const { int numberOfChars = 2; // TODO: Could be computed - return KDSize(2 * k_margin + numberOfChars * KDText::charSize(m_fontSize).width(), 0); + return KDSize(2 * k_margin + numberOfChars * m_font->glyphSize().width(), 0); } } diff --git a/apps/code/editor_view.h b/apps/code/editor_view.h index 520efb376..9fdeead33 100644 --- a/apps/code/editor_view.h +++ b/apps/code/editor_view.h @@ -30,13 +30,13 @@ private: class GutterView : public View { public: - GutterView(KDText::FontSize fontSize); + GutterView(const KDFont * font); void drawRect(KDContext * ctx, KDRect rect) const override; void setOffset(KDCoordinate offset); KDSize minimalSizeForOptimalDisplay() const override; private: static constexpr KDCoordinate k_margin = 2; - KDText::FontSize m_fontSize; + const KDFont * m_font; KDCoordinate m_offset; }; diff --git a/apps/code/menu_controller.cpp b/apps/code/menu_controller.cpp index bbc88ae9b..a850512f7 100644 --- a/apps/code/menu_controller.cpp +++ b/apps/code/menu_controller.cpp @@ -18,7 +18,7 @@ MenuController::MenuController(Responder * parentResponder, App * pythonDelegate menu->consoleController()->setAutoImport(true); menu->stackViewController()->push(menu->consoleController()); return; - }, this), KDText::FontSize::Large), + }, this), KDFont::LargeFont), m_selectableTableView(this, this, this, this), m_scriptParameterController(nullptr, I18n::Message::ScriptOptions, this), m_editorController(this, pythonDelegate), diff --git a/apps/code/python_text_area.h b/apps/code/python_text_area.h index bb04c07fc..45bfb4151 100644 --- a/apps/code/python_text_area.h +++ b/apps/code/python_text_area.h @@ -9,9 +9,9 @@ class App; class PythonTextArea : public TextArea { public: - PythonTextArea(Responder * parentResponder, App * pythonDelegate, KDText::FontSize fontSize) : - TextArea(parentResponder, &m_contentView, fontSize), - m_contentView(pythonDelegate, fontSize) + PythonTextArea(Responder * parentResponder, App * pythonDelegate, const KDFont * font) : + TextArea(parentResponder, &m_contentView, font), + m_contentView(pythonDelegate, font) { } void loadSyntaxHighlighter() { m_contentView.loadSyntaxHighlighter(); } @@ -19,8 +19,8 @@ public: protected: class ContentView : public TextArea::ContentView { public: - ContentView(App * pythonDelegate, KDText::FontSize fontSize) : - TextArea::ContentView(fontSize), + ContentView(App * pythonDelegate, const KDFont * font) : + TextArea::ContentView(font), m_pythonDelegate(pythonDelegate) { } diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 176a0a20a..b775dfe2e 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -282,7 +282,7 @@ KDCoordinate PythonToolbox::rowHeight(int j) { * children of the toolbox, which is the only menu that has special height * rows. */ const ToolboxMessageTree * messageTree = static_cast(m_messageTreeModel->children(j)); - return KDText::stringSize(I18n::translate(messageTree->label()), k_fontSize).height() + 2*Metric::TableCellLabelTopMargin + (messageTree->text() == I18n::Message::Default ? 0 : Toolbox::rowHeight(j)); + return k_font->stringSize(I18n::translate(messageTree->label())).height() + 2*Metric::TableCellLabelTopMargin + (messageTree->text() == I18n::Message::Default ? 0 : Toolbox::rowHeight(j)); } return Toolbox::rowHeight(j); } diff --git a/apps/code/python_toolbox.h b/apps/code/python_toolbox.h index 03c48ebf0..11fd046c2 100644 --- a/apps/code/python_toolbox.h +++ b/apps/code/python_toolbox.h @@ -23,7 +23,7 @@ protected: // 13 = minimal string height size // 3 = vertical margins private: - constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Small; + constexpr static const KDFont * k_font = KDFont::SmallFont; void scrollToLetter(char letter); void scrollToAndSelectChild(int i); MessageTableCellWithMessage m_leafCells[k_maxNumberOfDisplayedRows]; diff --git a/apps/code/script_node_cell.cpp b/apps/code/script_node_cell.cpp index 3928955ba..c60ddf84d 100644 --- a/apps/code/script_node_cell.cpp +++ b/apps/code/script_node_cell.cpp @@ -23,23 +23,23 @@ void ScriptNodeCell::ScriptNodeView::setScriptStore(ScriptStore * scriptStore) { } void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->drawString(m_scriptNode->name(), KDPoint(0, Metric::TableCellLabelTopMargin), k_fontSize, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite); - KDSize nameSize = KDText::stringSize(m_scriptNode->name(), k_fontSize); + ctx->drawString(m_scriptNode->name(), KDPoint(0, Metric::TableCellLabelTopMargin), k_font, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite); + KDSize nameSize = k_font->stringSize(m_scriptNode->name()); if (m_scriptNode->type() == ScriptNode::Type::Function) { - ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), Metric::TableCellLabelTopMargin), k_fontSize, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite); + ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), Metric::TableCellLabelTopMargin), k_font, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite); } - ctx->drawString(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), KDPoint(0, Metric::TableCellLabelTopMargin + nameSize.height() + k_verticalMargin), k_fontSize, Palette::GreyDark, isHighlighted()? Palette::Select : KDColorWhite); + ctx->drawString(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), KDPoint(0, Metric::TableCellLabelTopMargin + nameSize.height() + k_verticalMargin), k_font, Palette::GreyDark, isHighlighted()? Palette::Select : KDColorWhite); } KDSize ScriptNodeCell::ScriptNodeView::minimalSizeForOptimalDisplay() const { if (m_scriptNode->name() == nullptr) { return KDSizeZero; } - KDSize size1 = KDText::stringSize(m_scriptNode->name(), k_fontSize); - KDSize size2 = KDText::stringSize(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), k_fontSize); + KDSize size1 = k_font->stringSize(m_scriptNode->name()); + KDSize size2 = k_font->stringSize(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name()); KDSize size3 = KDSizeZero; if (m_scriptNode->type() == ScriptNode::Type::Function) { - size3 = KDText::stringSize(ScriptNodeCell::k_parentheses, k_fontSize); + size3 = k_font->stringSize(ScriptNodeCell::k_parentheses); } return KDSize(size1.width() + size3.width() > size2.width() ? size1.width() + size3.width() : size2.width(), Metric::TableCellLabelTopMargin + size1.width() + k_verticalMargin + size2.width()); } diff --git a/apps/code/script_node_cell.h b/apps/code/script_node_cell.h index b885b92ac..893d51378 100644 --- a/apps/code/script_node_cell.h +++ b/apps/code/script_node_cell.h @@ -37,7 +37,7 @@ protected: return m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(); } private: - constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Small; + constexpr static const KDFont * k_font = KDFont::SmallFont; constexpr static KDCoordinate k_verticalMargin = 7; ScriptNode * m_scriptNode; ScriptStore * m_scriptStore; diff --git a/apps/empty_battery_window.cpp b/apps/empty_battery_window.cpp index ec35f54dd..bae9b0f00 100644 --- a/apps/empty_battery_window.cpp +++ b/apps/empty_battery_window.cpp @@ -13,7 +13,7 @@ EmptyBatteryWindow::EmptyBatteryWindow() : void EmptyBatteryWindow::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), KDColorWhite); const char * warningMessage = I18n::translate(I18n::Message::LowBattery, GlobalPreferences::sharedGlobalPreferences()->language()); - KDSize warningSize = KDText::stringSize(warningMessage, KDText::FontSize::Large); - ctx->drawString(warningMessage, KDPoint((Ion::Display::Width - warningSize.width())/2, (Ion::Display::Height - warningSize.height())/2), KDText::FontSize::Large); + KDSize warningSize = KDFont::LargeFont->stringSize(warningMessage); + ctx->drawString(warningMessage, KDPoint((Ion::Display::Width - warningSize.width())/2, (Ion::Display::Height - warningSize.height())/2), KDFont::LargeFont); } diff --git a/apps/exam_pop_up_controller.cpp b/apps/exam_pop_up_controller.cpp index c0c935bf9..0a0cb85c3 100644 --- a/apps/exam_pop_up_controller.cpp +++ b/apps/exam_pop_up_controller.cpp @@ -50,7 +50,7 @@ ExamPopUpController::ContentView::ContentView(Responder * parentResponder) : ExamPopUpController * controller = (ExamPopUpController *)context; Container * container = (Container *)controller->app()->container(); container->activeApp()->dismissModalViewController(); - }, parentResponder), KDText::FontSize::Small), + }, parentResponder), KDFont::SmallFont), m_okButton(parentResponder, I18n::Message::Ok, Invocation([](void * context, void * sender) { ExamPopUpController * controller = (ExamPopUpController *)context; GlobalPreferences::ExamMode nextExamMode = controller->isActivatingExamMode() ? GlobalPreferences::ExamMode::Activate : GlobalPreferences::ExamMode::Desactivate; @@ -65,11 +65,11 @@ ExamPopUpController::ContentView::ContentView(Responder * parentResponder) : } container->refreshPreferences(); container->activeApp()->dismissModalViewController(); - }, parentResponder), KDText::FontSize::Small), - m_warningTextView(KDText::FontSize::Small, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView1(KDText::FontSize::Small, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView2(KDText::FontSize::Small, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView3(KDText::FontSize::Small, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack) + }, parentResponder), KDFont::SmallFont), + m_warningTextView(KDFont::SmallFont, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView1(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView2(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView3(KDFont::SmallFont, I18n::Message::Default, 0.5, 0.5, KDColorWhite, KDColorBlack) { } @@ -133,7 +133,7 @@ View * ExamPopUpController::ContentView::subviewAtIndex(int index) { void ExamPopUpController::ContentView::layoutSubviews() { KDCoordinate height = bounds().height(); KDCoordinate width = bounds().width(); - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); m_warningTextView.setFrame(KDRect(0, k_topMargin, width, textHeight)); m_messageTextView1.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+textHeight, width, textHeight)); m_messageTextView2.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+2*textHeight, width, textHeight)); diff --git a/apps/graph/graph/banner_view.cpp b/apps/graph/graph/banner_view.cpp index 21e8b34cb..aebd501d1 100644 --- a/apps/graph/graph/banner_view.cpp +++ b/apps/graph/graph/banner_view.cpp @@ -4,12 +4,12 @@ namespace Graph { BannerView::BannerView() : - m_abscissaView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_functionView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_derivativeView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_tangentEquationView(KDText::FontSize::Small, I18n::Message::LinearRegressionFormula, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_aView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_bView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_abscissaView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_functionView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_derivativeView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_tangentEquationView(KDFont::SmallFont, I18n::Message::LinearRegressionFormula, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_aView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_bView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_numberOfSubviews(2) { } diff --git a/apps/graph/graph/calculation_graph_controller.cpp b/apps/graph/graph/calculation_graph_controller.cpp index de9ef00f1..077737652 100644 --- a/apps/graph/graph/calculation_graph_controller.cpp +++ b/apps/graph/graph/calculation_graph_controller.cpp @@ -13,7 +13,7 @@ CalculationGraphController::CalculationGraphController(Responder * parentRespond m_graphRange(curveViewRange), m_cursor(cursor), m_function(nullptr), - m_defaultBannerView(KDText::FontSize::Small, defaultMessage, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_defaultBannerView(KDFont::SmallFont, defaultMessage, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_isActive(false) { } diff --git a/apps/graph/graph/integral_graph_controller.cpp b/apps/graph/graph/integral_graph_controller.cpp index 29b09df61..aa6daadc0 100644 --- a/apps/graph/graph/integral_graph_controller.cpp +++ b/apps/graph/graph/integral_graph_controller.cpp @@ -39,7 +39,7 @@ double IntegralGraphController::cursorNextStep(double x, int direction) { Layout IntegralGraphController::createFunctionLayout(const char * functionName) { char buffer[7] = "0(x)dx"; buffer[0] = functionName[0]; - return LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small); + return LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont); } } diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 4b48c1e56..d97c351aa 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -18,7 +18,7 @@ ValuesController::ValuesController(Responder * parentResponder, CartesianFunctio { for (int i = 0; i < k_maxNumberOfFunctions; i++) { m_functionTitleCells[i].setOrientation(FunctionTitleCell::Orientation::HorizontalIndicator); - m_functionTitleCells[i].setFontSize(KDText::FontSize::Small); + m_functionTitleCells[i].setFont(KDFont::SmallFont); } } diff --git a/apps/hardware_test/battery_test_controller.cpp b/apps/hardware_test/battery_test_controller.cpp index 71da3a269..62ff2fe7e 100644 --- a/apps/hardware_test/battery_test_controller.cpp +++ b/apps/hardware_test/battery_test_controller.cpp @@ -66,9 +66,9 @@ void BatteryTestController::updateBatteryState(float batteryLevel, bool batteryC BatteryTestController::ContentView::ContentView() : SolidColorView(KDColorWhite), - m_batteryStateView(KDText::FontSize::Large), - m_batteryLevelView(KDText::FontSize::Small), - m_batteryChargingView(KDText::FontSize::Small) + m_batteryStateView(KDFont::LargeFont), + m_batteryLevelView(KDFont::SmallFont), + m_batteryChargingView(KDFont::SmallFont) { } @@ -93,7 +93,7 @@ void BatteryTestController::ContentView::setColor(KDColor color) { void BatteryTestController::ContentView::layoutSubviews() { m_batteryStateView.setFrame(KDRect(0, 0, Ion::Display::Width, Ion::Display::Height/2)); - KDSize textSize = KDText::charSize(KDText::FontSize::Small); + KDSize textSize = KDFont::SmallFont->glyphSize(); m_batteryLevelView.setFrame(KDRect(0, Ion::Display::Height-2*textSize.height(), Ion::Display::Width, textSize.height())); m_batteryChargingView.setFrame(KDRect(0, Ion::Display::Height-textSize.height(), Ion::Display::Width, textSize.height())); } diff --git a/apps/hardware_test/led_test_controller.cpp b/apps/hardware_test/led_test_controller.cpp index 74c1ad3d4..07b3917b1 100644 --- a/apps/hardware_test/led_test_controller.cpp +++ b/apps/hardware_test/led_test_controller.cpp @@ -48,7 +48,7 @@ LEDTestController::ContentView::ContentView() : SolidColorView(KDColorWhite), m_ledColorIndicatorView(KDColorBlack), m_ledColorOutlineView(KDColorBlack), - m_ledView(KDText::FontSize::Large), + m_ledView(KDFont::LargeFont), m_arrowView() { m_ledView.setText("LED"); diff --git a/apps/hardware_test/pop_up_controller.cpp b/apps/hardware_test/pop_up_controller.cpp index 3f53b830b..c0cb42ce2 100644 --- a/apps/hardware_test/pop_up_controller.cpp +++ b/apps/hardware_test/pop_up_controller.cpp @@ -36,17 +36,17 @@ PopUpController::ContentView::ContentView(Responder * parentResponder) : m_cancelButton(this, I18n::Message::Cancel, Invocation([](void * context, void * sender) { PopUpController::ContentView * view = (PopUpController::ContentView *)context; view->app()->dismissModalViewController(); - }, this), KDText::FontSize::Small), + }, this), KDFont::SmallFont), m_okButton(this, I18n::Message::Ok, Invocation([](void * context, void * sender) { PopUpController::ContentView * view = (PopUpController::ContentView *)context; AppsContainer * appsContainer = (AppsContainer *)view->app()->container(); appsContainer->switchTo(appsContainer->hardwareTestAppSnapshot()); - }, this), KDText::FontSize::Small), - m_warningTextView(KDText::FontSize::Small, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView1(KDText::FontSize::Small, I18n::Message::HardwareTestLaunch1, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView2(KDText::FontSize::Small, I18n::Message::HardwareTestLaunch2, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView3(KDText::FontSize::Small, I18n::Message::HardwareTestLaunch3, 0.5, 0.5, KDColorWhite, KDColorBlack), - m_messageTextView4(KDText::FontSize::Small, I18n::Message::HardwareTestLaunch4, 0.5, 0.5, KDColorWhite, KDColorBlack) + }, this), KDFont::SmallFont), + m_warningTextView(KDFont::SmallFont, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView1(KDFont::SmallFont, I18n::Message::HardwareTestLaunch1, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView2(KDFont::SmallFont, I18n::Message::HardwareTestLaunch2, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView3(KDFont::SmallFont, I18n::Message::HardwareTestLaunch3, 0.5, 0.5, KDColorWhite, KDColorBlack), + m_messageTextView4(KDFont::SmallFont, I18n::Message::HardwareTestLaunch4, 0.5, 0.5, KDColorWhite, KDColorBlack) { } @@ -100,7 +100,7 @@ View * PopUpController::ContentView::subviewAtIndex(int index) { void PopUpController::ContentView::layoutSubviews() { KDCoordinate height = bounds().height(); KDCoordinate width = bounds().width(); - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); m_warningTextView.setFrame(KDRect(0, k_topMargin, width, textHeight)); m_messageTextView1.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+textHeight, width, textHeight)); m_messageTextView2.setFrame(KDRect(0, k_topMargin+k_paragraphHeight+2*textHeight, width, textHeight)); diff --git a/apps/home/app_cell.cpp b/apps/home/app_cell.cpp index 77388e0e0..1b2c1ad8c 100644 --- a/apps/home/app_cell.cpp +++ b/apps/home/app_cell.cpp @@ -5,7 +5,7 @@ namespace Home { AppCell::AppCell() : HighlightCell(), - m_nameView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, KDColorWhite), + m_nameView(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, KDColorWhite), m_visible(true) { } diff --git a/apps/on_boarding/update_controller.cpp b/apps/on_boarding/update_controller.cpp index d674e4b3a..ecc8d1e4e 100644 --- a/apps/on_boarding/update_controller.cpp +++ b/apps/on_boarding/update_controller.cpp @@ -6,7 +6,7 @@ namespace OnBoarding { UpdateController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) : MessageView(messages, colors, numberOfMessages), - m_skipView(KDText::FontSize::Small, I18n::Message::Skip, 1.0f, 0.5f), + m_skipView(KDFont::SmallFont, I18n::Message::Skip, 1.0f, 0.5f), m_okView() { } @@ -36,7 +36,7 @@ void UpdateController::MessageViewWithSkip::layoutSubviews() { // Layout the "skip (OK)" KDCoordinate height = bounds().height(); KDCoordinate width = bounds().width(); - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); KDSize okSize = m_okView.minimalSizeForOptimalDisplay(); m_skipView.setFrame(KDRect(0, height-k_bottomMargin-textHeight, width-okSize.width()-k_okMargin-k_skipMargin, textHeight)); m_okView.setFrame(KDRect(width - okSize.width()-k_okMargin, height-okSize.height()-k_okMargin, okSize)); diff --git a/apps/probability/calculation_cell.cpp b/apps/probability/calculation_cell.cpp index 8c3d3f638..cf892a8c8 100644 --- a/apps/probability/calculation_cell.cpp +++ b/apps/probability/calculation_cell.cpp @@ -6,7 +6,7 @@ namespace Probability { CalculationCell::CalculationCell(Responder * parentResponder, char * draftTextBuffer, TextFieldDelegate * textFieldDelegate) : - m_text(KDText::FontSize::Large, I18n::Message::Default, 0.5f, 0.5f), + m_text(KDFont::LargeFont, I18n::Message::Default, 0.5f, 0.5f), m_calculation(parentResponder, textFieldDelegate, draftTextBuffer), m_isResponder(true) { @@ -30,7 +30,10 @@ void CalculationCell::setHighlighted(bool highlight) { KDSize CalculationCell::minimalSizeForOptimalDisplay() const { KDSize textSize = m_text.minimalSizeForOptimalDisplay(); - return KDSize(2*k_margin+textSize.width()+calculationCellWidth()+2*ResponderImageCell::k_outline, KDText::charSize().height()); + return KDSize( + 2 * k_margin + textSize.width() + calculationCellWidth() + 2 * ResponderImageCell::k_outline, + KDFont::LargeFont->glyphSize().height() + ); } void CalculationCell::drawRect(KDContext * ctx, KDRect rect) const { @@ -69,7 +72,10 @@ void CalculationCell::layoutSubviews() { KDCoordinate CalculationCell::calculationCellWidth() const { KDCoordinate calculationCellWidth = m_calculation.minimalSizeForOptimalDisplay().width(); - return min(k_maxTextFieldWidth, max(k_minTextFieldWidth, calculationCellWidth)); + KDCoordinate glyphWidth = KDFont::LargeFont->glyphSize().width(); + KDCoordinate minTextFieldWidth = 4 * glyphWidth + TextCursorView::k_width; + KDCoordinate maxTextFieldWidth = 14 * glyphWidth + TextCursorView::k_width; + return min(maxTextFieldWidth, max(minTextFieldWidth, calculationCellWidth)); } } diff --git a/apps/probability/calculation_cell.h b/apps/probability/calculation_cell.h index 26178b562..8f2e9f56f 100644 --- a/apps/probability/calculation_cell.h +++ b/apps/probability/calculation_cell.h @@ -20,8 +20,6 @@ public: } private: constexpr static KDCoordinate k_margin = 5; - constexpr static KDCoordinate k_minTextFieldWidth = 4*KDText::charSize().width()+TextCursorView::k_width; - constexpr static KDCoordinate k_maxTextFieldWidth = 14*KDText::charSize().width()+TextCursorView::k_width; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; diff --git a/apps/probability/calculation_controller.cpp b/apps/probability/calculation_controller.cpp index 130f0c3d5..46a9f687a 100644 --- a/apps/probability/calculation_controller.cpp +++ b/apps/probability/calculation_controller.cpp @@ -24,7 +24,7 @@ using namespace Shared; namespace Probability { CalculationController::ContentView::ContentView(SelectableTableView * selectableTableView, Law * law, Calculation * calculation) : - m_titleView(KDText::FontSize::Small, I18n::Message::ComputeProbability, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), + m_titleView(KDFont::SmallFont, I18n::Message::ComputeProbability, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), m_selectableTableView(selectableTableView), m_lawCurveView(law, calculation) { @@ -46,7 +46,7 @@ View * CalculationController::ContentView::subviewAtIndex(int index) { } void CalculationController::ContentView::layoutSubviews() { - KDCoordinate titleHeight = KDText::charSize(KDText::FontSize::Small).height()+k_titleHeightMargin; + KDCoordinate titleHeight = KDFont::SmallFont->glyphSize().height()+k_titleHeightMargin; m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight)); KDCoordinate calculationHeight = ResponderImageCell::k_oneCellHeight+2*k_tableMargin; m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), calculationHeight)); diff --git a/apps/probability/cell.cpp b/apps/probability/cell.cpp index 7c711b0f6..a78a116f2 100644 --- a/apps/probability/cell.cpp +++ b/apps/probability/cell.cpp @@ -5,7 +5,7 @@ namespace Probability { Cell::Cell() : HighlightCell(), - m_labelView(KDText::FontSize::Large, (I18n::Message)0, 0, 0.5, KDColorBlack, KDColorWhite), + m_labelView(KDFont::LargeFont, (I18n::Message)0, 0, 0.5, KDColorBlack, KDColorWhite), m_icon(nullptr), m_focusedIcon(nullptr) { diff --git a/apps/probability/law_controller.cpp b/apps/probability/law_controller.cpp index a49139e43..b507bb8a9 100644 --- a/apps/probability/law_controller.cpp +++ b/apps/probability/law_controller.cpp @@ -21,7 +21,7 @@ namespace Probability { LawController::ContentView::ContentView(SelectableTableView * selectableTableView) : - m_titleView(KDText::FontSize::Small, I18n::Message::ChooseLaw, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), + m_titleView(KDFont::SmallFont, I18n::Message::ChooseLaw, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), m_selectableTableView(selectableTableView) { } @@ -39,7 +39,7 @@ View * LawController::ContentView::subviewAtIndex(int index) { } void LawController::ContentView::layoutSubviews() { - KDCoordinate titleHeight = KDText::charSize(KDText::FontSize::Small).height()+k_titleMargin; + KDCoordinate titleHeight = KDFont::SmallFont->glyphSize().height()+k_titleMargin; m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight)); m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), bounds().height()-titleHeight)); } diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index f8a306ecb..d5f90c0bd 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -8,9 +8,9 @@ namespace Probability { ParametersController::ContentView::ContentView(Responder * parentResponder, SelectableTableView * selectableTableView) : m_numberOfParameters(1), - m_titleView(KDText::FontSize::Small, I18n::Message::ChooseParameters, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), - m_firstParameterDefinition(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), - m_secondParameterDefinition(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), + m_titleView(KDFont::SmallFont, I18n::Message::ChooseParameters, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen), + m_firstParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), + m_secondParameterDefinition(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), m_selectableTableView(selectableTableView) { } @@ -51,11 +51,11 @@ View * ParametersController::ContentView::subviewAtIndex(int index) { } void ParametersController::ContentView::layoutSubviews() { - KDCoordinate titleHeight = KDText::charSize(KDText::FontSize::Small).height()+k_titleMargin; + KDCoordinate titleHeight = KDFont::SmallFont->glyphSize().height()+k_titleMargin; m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight)); KDCoordinate tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height() + Metric::CommonTopMargin + Metric::CommonBottomMargin; m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), tableHeight)); - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); KDCoordinate defOrigin = (titleHeight+tableHeight)/2+(bounds().height()-textHeight)/2; m_secondParameterDefinition.setFrame(KDRectZero); if (m_numberOfParameters == 2) { diff --git a/apps/regression/banner_view.cpp b/apps/regression/banner_view.cpp index 259cff4ea..8861ff019 100644 --- a/apps/regression/banner_view.cpp +++ b/apps/regression/banner_view.cpp @@ -6,15 +6,15 @@ constexpr KDColor BannerView::k_textColor; constexpr KDColor BannerView::k_backgroundColor; BannerView::BannerView() : - m_dotNameView(k_fontSize, 0.0f, 0.5f, k_textColor, k_backgroundColor), - m_xView(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_yView(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_regressionTypeView(k_fontSize, (I18n::Message)0, 0.0f, 0.5f, k_textColor,k_backgroundColor), - m_subText1(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_subText2(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_subText3(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_subText4(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor), - m_subText5(k_fontSize, 0.5f, 0.5f, k_textColor, k_backgroundColor) + m_dotNameView(k_font, 0.0f, 0.5f, k_textColor, k_backgroundColor), + m_xView(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_yView(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_regressionTypeView(k_font, (I18n::Message)0, 0.0f, 0.5f, k_textColor,k_backgroundColor), + m_subText1(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_subText2(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_subText3(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_subText4(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor), + m_subText5(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor) { } diff --git a/apps/regression/banner_view.h b/apps/regression/banner_view.h index 49427a699..c0345e80f 100644 --- a/apps/regression/banner_view.h +++ b/apps/regression/banner_view.h @@ -10,9 +10,9 @@ class BannerView : public Shared::BannerView { public: BannerView(); int numberOfTextviews() const { return k_numberOfTextViews; } - KDText::FontSize fontSize() const { return k_fontSize; } + const KDFont * font() const { return k_font; } private: - static constexpr KDText::FontSize k_fontSize = KDText::FontSize::Small; + static constexpr const KDFont * k_font = KDFont::SmallFont; static constexpr KDColor k_textColor = KDColorBlack; static constexpr KDColor k_backgroundColor = Palette::GreyMiddle; static constexpr int k_numberOfTextViews = 9; diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 3993a0a4d..ab0f652be 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -25,7 +25,7 @@ CalculationController::CalculationController(Responder * parentResponder, Button m_hideableCell(), m_store(store) { - m_r2Layout = HorizontalLayout(CharLayout('r', KDText::FontSize::Small), VerticalOffsetLayout(CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript)); + m_r2Layout = HorizontalLayout(CharLayout('r', KDFont::SmallFont), VerticalOffsetLayout(CharLayout('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript)); m_selectableTableView.setVerticalCellOverlap(0); m_selectableTableView.setBackgroundColor(Palette::WallScreenDark); m_selectableTableView.setMargins(k_margin, k_scrollBarMargin, k_scrollBarMargin, k_margin); diff --git a/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp b/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp index d397bf80e..bf8126083 100644 --- a/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp +++ b/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp @@ -9,8 +9,8 @@ EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparat EvenOddCell(), Responder(parentResponder), m_firstTextSelected(true), - m_firstBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment), - m_secondBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment) + m_firstBufferTextView(KDFont::SmallFont, horizontalAlignment, verticalAlignment), + m_secondBufferTextView(KDFont::SmallFont, horizontalAlignment, verticalAlignment) { } diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index 9a0a84556..ac1c1fe55 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -173,7 +173,7 @@ void GraphController::reloadBannerView() { } if (!coefficientsAreDefined) { // Force the "Data not suitable" message to be on the next line - int numberOfCharToCompleteLine = maxInt(Ion::Display::Width/(KDText::charSize(m_bannerView.fontSize()).width())- strlen(I18n::translate(formula)), 0); + int numberOfCharToCompleteLine = maxInt(Ion::Display::Width/(m_bannerView.font()->glyphSize().width())- strlen(I18n::translate(formula)), 0); numberOfChar = 0; for (int i = 0; i < numberOfCharToCompleteLine-1; i++) { buffer[numberOfChar++] = ' '; @@ -384,9 +384,9 @@ float GraphController::displayBottomMarginRatio() { float GraphController::estimatedBannerHeight() const { if (selectedSeriesIndex() < 0) { - return KDText::charSize(KDText::FontSize::Small).height() * 3; + return KDFont::SmallFont->glyphSize().height() * 3; } - float result = KDText::charSize(KDText::FontSize::Small).height() * m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount(); + float result = KDFont::SmallFont->glyphSize().height() * m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount(); return result; } diff --git a/apps/regression/model/cubic_model.cpp b/apps/regression/model/cubic_model.cpp index 1c5929dfe..ecd338252 100644 --- a/apps/regression/model/cubic_model.cpp +++ b/apps/regression/model/cubic_model.cpp @@ -11,27 +11,27 @@ namespace Regression { Layout CubicModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('3', KDText::FontSize::Small), + CharLayout('3', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('2', KDText::FontSize::Small), + CharLayout('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('c', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('d', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('c', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('d', KDFont::SmallFont), }; m_layout = HorizontalLayout(layoutChildren, 15); } diff --git a/apps/regression/model/exponential_model.cpp b/apps/regression/model/exponential_model.cpp index 6ad999c6f..bd3004e72 100644 --- a/apps/regression/model/exponential_model.cpp +++ b/apps/regression/model/exponential_model.cpp @@ -9,14 +9,14 @@ namespace Regression { Layout ExponentialModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('e', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('e', KDFont::SmallFont), VerticalOffsetLayout( HorizontalLayout( - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small) + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont) ), VerticalOffsetLayoutNode::Type::Superscript ) diff --git a/apps/regression/model/linear_model.cpp b/apps/regression/model/linear_model.cpp index a88bdf567..19eaaea98 100644 --- a/apps/regression/model/linear_model.cpp +++ b/apps/regression/model/linear_model.cpp @@ -10,11 +10,11 @@ namespace Regression { Layout LinearModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), }; m_layout = HorizontalLayout(layoutChildren, 5); } diff --git a/apps/regression/model/logarithmic_model.cpp b/apps/regression/model/logarithmic_model.cpp index 2471474ad..75d2a604b 100644 --- a/apps/regression/model/logarithmic_model.cpp +++ b/apps/regression/model/logarithmic_model.cpp @@ -10,15 +10,15 @@ namespace Regression { Layout LogarithmicModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('l', KDText::FontSize::Small), - CharLayout('n', KDText::FontSize::Small), - CharLayout('(', KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout(')', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small) + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('l', KDFont::SmallFont), + CharLayout('n', KDFont::SmallFont), + CharLayout('(', KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout(')', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont) }; m_layout = HorizontalLayout(layoutChildren, 9); } diff --git a/apps/regression/model/logistic_model.cpp b/apps/regression/model/logistic_model.cpp index 53a3151c4..659955830 100644 --- a/apps/regression/model/logistic_model.cpp +++ b/apps/regression/model/logistic_model.cpp @@ -9,24 +9,24 @@ namespace Regression { Layout LogisticModel::layout() { if (m_layout.isUninitialized()) { const Layout exponentLayoutChildren[] = { - CharLayout('-', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small) + CharLayout('-', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont) }; const Layout layoutChildren[] = { - CharLayout('1', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('e', KDText::FontSize::Small), + CharLayout('1', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('e', KDFont::SmallFont), VerticalOffsetLayout( HorizontalLayout(exponentLayoutChildren, 4), VerticalOffsetLayoutNode::Type::Superscript ) }; m_layout = FractionLayout( - CharLayout('c', KDText::FontSize::Small), + CharLayout('c', KDFont::SmallFont), HorizontalLayout(layoutChildren, 6) ); } diff --git a/apps/regression/model/power_model.cpp b/apps/regression/model/power_model.cpp index 62e6b02f9..d72c5baf9 100644 --- a/apps/regression/model/power_model.cpp +++ b/apps/regression/model/power_model.cpp @@ -10,11 +10,11 @@ namespace Regression { Layout PowerModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('b', KDText::FontSize::Small), + CharLayout('b', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), }; diff --git a/apps/regression/model/quadratic_model.cpp b/apps/regression/model/quadratic_model.cpp index 0f50b1098..e59e625ad 100644 --- a/apps/regression/model/quadratic_model.cpp +++ b/apps/regression/model/quadratic_model.cpp @@ -11,19 +11,19 @@ namespace Regression { Layout QuadraticModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('2', KDText::FontSize::Small), + CharLayout('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('c', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('c', KDFont::SmallFont), }; m_layout = HorizontalLayout(layoutChildren, 10); } diff --git a/apps/regression/model/quartic_model.cpp b/apps/regression/model/quartic_model.cpp index 3dc54c39c..6f042b3ab 100644 --- a/apps/regression/model/quartic_model.cpp +++ b/apps/regression/model/quartic_model.cpp @@ -11,35 +11,35 @@ namespace Regression { Layout QuarticModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('4', KDText::FontSize::Small), + CharLayout('4', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('3', KDText::FontSize::Small), + CharLayout('3', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('c', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('c', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('2', KDText::FontSize::Small), + CharLayout('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript ), - CharLayout('+', KDText::FontSize::Small), - CharLayout('d', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('e', KDText::FontSize::Small), + CharLayout('+', KDFont::SmallFont), + CharLayout('d', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('e', KDFont::SmallFont), }; m_layout = HorizontalLayout(layoutChildren, 20); } diff --git a/apps/regression/model/trigonometric_model.cpp b/apps/regression/model/trigonometric_model.cpp index a23ead6e3..01ce24a61 100644 --- a/apps/regression/model/trigonometric_model.cpp +++ b/apps/regression/model/trigonometric_model.cpp @@ -12,20 +12,20 @@ namespace Regression { Layout TrigonometricModel::layout() { if (m_layout.isUninitialized()) { const Layout layoutChildren[] = { - CharLayout('a', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('s', KDText::FontSize::Small), - CharLayout('i', KDText::FontSize::Small), - CharLayout('n', KDText::FontSize::Small), - CharLayout('(', KDText::FontSize::Small), - CharLayout('b', KDText::FontSize::Small), - CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - CharLayout('X', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('c', KDText::FontSize::Small), - CharLayout(')', KDText::FontSize::Small), - CharLayout('+', KDText::FontSize::Small), - CharLayout('d', KDText::FontSize::Small) + CharLayout('a', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('s', KDFont::SmallFont), + CharLayout('i', KDFont::SmallFont), + CharLayout('n', KDFont::SmallFont), + CharLayout('(', KDFont::SmallFont), + CharLayout('b', KDFont::SmallFont), + CharLayout(Ion::Charset::MiddleDot, KDFont::SmallFont), + CharLayout('X', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('c', KDFont::SmallFont), + CharLayout(')', KDFont::SmallFont), + CharLayout('+', KDFont::SmallFont), + CharLayout('d', KDFont::SmallFont) }; m_layout = HorizontalLayout(layoutChildren, 14); } diff --git a/apps/sequence/graph/banner_view.cpp b/apps/sequence/graph/banner_view.cpp index 0a5f0e920..50e0f7f2f 100644 --- a/apps/sequence/graph/banner_view.cpp +++ b/apps/sequence/graph/banner_view.cpp @@ -3,8 +3,8 @@ namespace Sequence { BannerView::BannerView() : - m_abscissaView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sequenceView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle) + m_abscissaView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_sequenceView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle) { } diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index 264d748b8..2c48f5967 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -48,9 +48,9 @@ double TermSumController::cursorNextStep(double x, int direction) { Layout TermSumController::createFunctionLayout(const char * functionName) { return HorizontalLayout( - CharLayout(functionName[0], KDText::FontSize::Small), + CharLayout(functionName[0], KDFont::SmallFont), VerticalOffsetLayout( - CharLayout('n', KDText::FontSize::Small), + CharLayout('n', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Subscript ) ); diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index 4c6197078..bee02394b 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -74,19 +74,19 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu for (int j = 0; j < recurrenceDepth; j++) { const char * indice = j == 0 ? "n" : "n+1"; m_addedCellLayout[j] = HorizontalLayout( - CharLayout(sequenceName[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(sequenceName[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); m_addedCellLayout[j+recurrenceDepth] = HorizontalLayout( - CharLayout(otherSequenceName[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(otherSequenceName[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); } if (recurrenceDepth < 2) { const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2"); m_addedCellLayout[2*recurrenceDepth] = HorizontalLayout( - CharLayout(otherSequenceName[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(otherSequenceName[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); } } diff --git a/apps/sequence/list/type_parameter_controller.cpp b/apps/sequence/list/type_parameter_controller.cpp index 554c5197c..328574a98 100644 --- a/apps/sequence/list/type_parameter_controller.cpp +++ b/apps/sequence/list/type_parameter_controller.cpp @@ -107,15 +107,15 @@ KDCoordinate TypeParameterController::cellHeight() { void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { const char * nextName = m_sequenceStore->firstAvailableName(); - KDText::FontSize size = KDText::FontSize::Large; + const KDFont * font = KDFont::LargeFont; if (m_sequence) { nextName = m_sequence->name(); - size = KDText::FontSize::Small; + font = KDFont::SmallFont; } const char * subscripts[3] = {"n", "n+1", "n+2"}; m_layouts[j] = HorizontalLayout( - CharLayout(nextName[0], size), - VerticalOffsetLayout(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(nextName[0], font), + VerticalOffsetLayout(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), font), VerticalOffsetLayoutNode::Type::Subscript) ); ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell; myCell->setLayout(m_layouts[j]); diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index e8745caf1..63aadc708 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -147,8 +147,8 @@ int Sequence::numberOfElements() { Poincare::Layout Sequence::nameLayout() { if (m_nameLayout.isUninitialized()) { m_nameLayout = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Small), - VerticalOffsetLayout(CharLayout('n', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(name()[0], KDFont::SmallFont), + VerticalOffsetLayout(CharLayout('n', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Subscript) ); } return m_nameLayout; @@ -158,20 +158,20 @@ Poincare::Layout Sequence::definitionName() { if (m_definitionName.isUninitialized()) { if (m_type == Type::Explicit) { m_definitionName = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(name()[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String("n", 1, KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); } if (m_type == Type::SingleRecurrence) { m_definitionName = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(name()[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String("n+1", 3, KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); } if (m_type == Type::DoubleRecurrence) { m_definitionName = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Large), - VerticalOffsetLayout(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + CharLayout(name()[0], KDFont::LargeFont), + VerticalOffsetLayout(LayoutHelper::String("n+2", 3, KDFont::LargeFont), VerticalOffsetLayoutNode::Type::Subscript) ); } } @@ -185,9 +185,9 @@ Poincare::Layout Sequence::firstInitialConditionName() { && (m_type == Type::SingleRecurrence || m_type == Type::DoubleRecurrence)) { - Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large); + Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDFont::LargeFont); m_firstInitialConditionName = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Large), + CharLayout(name()[0], KDFont::LargeFont), VerticalOffsetLayout(indexLayout, VerticalOffsetLayoutNode::Type::Subscript) ); } @@ -199,9 +199,9 @@ Poincare::Layout Sequence::secondInitialConditionName() { Integer(m_initialRank+1).serialize(buffer, k_initialRankNumberOfDigits+1); if (m_secondInitialConditionName.isUninitialized()) { if (m_type == Type::DoubleRecurrence) { - Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large); + Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDFont::LargeFont); m_secondInitialConditionName = HorizontalLayout( - CharLayout(name()[0], KDText::FontSize::Large), + CharLayout(name()[0], KDFont::LargeFont), VerticalOffsetLayout(indexLayout, VerticalOffsetLayoutNode::Type::Subscript) ); } diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 4f8a808c3..120365aff 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -39,9 +39,9 @@ const SettingsMessageTree model = SettingsMessageTree(I18n::Message::SettingsApp MainController::MainController(Responder * parentResponder) : ViewController(parentResponder), #if EPSILON_SOFTWARE_UPDATE_PROMPT - m_updateCell(I18n::Message::Default, KDText::FontSize::Large), + m_updateCell(I18n::Message::Default, KDFont::LargeFont), #endif - m_brightnessCell(I18n::Message::Default, KDText::FontSize::Large), + m_brightnessCell(I18n::Message::Default, KDFont::LargeFont), m_selectableTableView(this), m_messageTreeModel((MessageTree *)&model), m_preferencesController(this), @@ -51,7 +51,7 @@ MainController::MainController(Responder * parentResponder) : m_aboutController(this) { for (int i = 0; i < k_numberOfSimpleChevronCells; i++) { - m_cells[i].setMessageFontSize(KDText::FontSize::Large); + m_cells[i].setMessageFont(KDFont::LargeFont); } } diff --git a/apps/settings/sub_menu/about_controller.cpp b/apps/settings/sub_menu/about_controller.cpp index eeb96fe12..a8096d0de 100644 --- a/apps/settings/sub_menu/about_controller.cpp +++ b/apps/settings/sub_menu/about_controller.cpp @@ -11,8 +11,8 @@ AboutController::AboutController(Responder * parentResponder) : GenericSubController(parentResponder) { for (int i = 0; i < k_totalNumberOfCell; i++) { - m_cells[i].setMessageFontSize(KDText::FontSize::Large); - m_cells[i].setAccessoryFontSize(KDText::FontSize::Small); + m_cells[i].setMessageFont(KDFont::LargeFont); + m_cells[i].setAccessoryFont(KDFont::SmallFont); m_cells[i].setAccessoryTextColor(Palette::GreyDark); } } diff --git a/apps/settings/sub_menu/display_mode_controller.cpp b/apps/settings/sub_menu/display_mode_controller.cpp index 320e566fd..f8d349ded 100644 --- a/apps/settings/sub_menu/display_mode_controller.cpp +++ b/apps/settings/sub_menu/display_mode_controller.cpp @@ -13,7 +13,7 @@ DisplayModeController::DisplayModeController(Responder * parentResponder) : m_editableCell(&m_selectableTableView, this, m_draftTextBuffer) { m_editableCell.messageTableCellWithEditableText()->setMessage(I18n::Message::SignificantFigures); - m_editableCell.messageTableCellWithEditableText()->setMessageFontSize(KDText::FontSize::Large); + m_editableCell.messageTableCellWithEditableText()->setMessageFont(KDFont::LargeFont); } KDCoordinate DisplayModeController::rowHeight(int j) { diff --git a/apps/settings/sub_menu/exam_mode_controller.cpp b/apps/settings/sub_menu/exam_mode_controller.cpp index 6903add84..d3cc2890b 100644 --- a/apps/settings/sub_menu/exam_mode_controller.cpp +++ b/apps/settings/sub_menu/exam_mode_controller.cpp @@ -11,7 +11,7 @@ namespace Settings { ExamModeController::ExamModeController(Responder * parentResponder) : GenericSubController(parentResponder), - m_cell(I18n::Message::ExamModeActive, KDText::FontSize::Large) + m_cell(I18n::Message::ExamModeActive, KDFont::LargeFont) { } diff --git a/apps/settings/sub_menu/preferences_controller.cpp b/apps/settings/sub_menu/preferences_controller.cpp index 40097bfbd..9461f647e 100644 --- a/apps/settings/sub_menu/preferences_controller.cpp +++ b/apps/settings/sub_menu/preferences_controller.cpp @@ -12,7 +12,7 @@ PreferencesController::PreferencesController(Responder * parentResponder) : GenericSubController(parentResponder) { for (int i = 0; i < k_totalNumberOfCell; i++) { - m_cells[i].setMessageFontSize(KDText::FontSize::Large); + m_cells[i].setMessageFont(KDFont::LargeFont); } } @@ -51,45 +51,45 @@ Layout layoutForPreferences(I18n::Message message) { case I18n::Message::Degres: { const char degEx[] = {'9', '0', Ion::Charset::Degree}; - return LayoutHelper::String(degEx, sizeof(degEx), KDText::FontSize::Small); + return LayoutHelper::String(degEx, sizeof(degEx), KDFont::SmallFont); } case I18n::Message::Radian: { const char pi[] = {Ion::Charset::SmallPi}; return FractionLayout( - LayoutHelper::String(pi, sizeof(pi), KDText::FontSize::Small), - LayoutHelper::String("2", 1, KDText::FontSize::Small) + LayoutHelper::String(pi, sizeof(pi), KDFont::SmallFont), + LayoutHelper::String("2", 1, KDFont::SmallFont) ); } // Display Mode format case I18n::Message::Decimal: - return LayoutHelper::String("12.34", 5, KDText::FontSize::Small); + return LayoutHelper::String("12.34", 5, KDFont::SmallFont); case I18n::Message::Scientific: { const char text[] = {'1','.', '2', '3', '4', Ion::Charset::Exponent, '1'}; - return LayoutHelper::String(text, sizeof(text), KDText::FontSize::Small); + return LayoutHelper::String(text, sizeof(text), KDFont::SmallFont); } // Edition mode case I18n::Message::Edition2D: return HorizontalLayout( - LayoutHelper::String("1+", 2, KDText::FontSize::Small), - FractionLayout(LayoutHelper::String("2", 1, KDText::FontSize::Small), LayoutHelper::String("3", 1, KDText::FontSize::Small)) + LayoutHelper::String("1+", 2, KDFont::SmallFont), + FractionLayout(LayoutHelper::String("2", 1, KDFont::SmallFont), LayoutHelper::String("3", 1, KDFont::SmallFont)) ); case I18n::Message::EditionLinear: - return LayoutHelper::String("1+2/3", 5, KDText::FontSize::Small); + return LayoutHelper::String("1+2/3", 5, KDFont::SmallFont); // Complex format case I18n::Message::Cartesian: { const char text[] = {'a','+', Ion::Charset::IComplex, 'b'}; - return LayoutHelper::String(text, sizeof(text), KDText::FontSize::Small); + return LayoutHelper::String(text, sizeof(text), KDFont::SmallFont); } case I18n::Message::Polar: { const char base[] = {'r', Ion::Charset::Exponential}; const char superscript[] = {Ion::Charset::IComplex, Ion::Charset::SmallTheta}; return HorizontalLayout( - LayoutHelper::String(base, sizeof(base), KDText::FontSize::Small), - VerticalOffsetLayout(LayoutHelper::String(superscript, sizeof(superscript), KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript) + LayoutHelper::String(base, sizeof(base), KDFont::SmallFont), + VerticalOffsetLayout(LayoutHelper::String(superscript, sizeof(superscript), KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript) ); } default: diff --git a/apps/shared/banner_view.cpp b/apps/shared/banner_view.cpp index 8643b0dcf..afdd47f75 100644 --- a/apps/shared/banner_view.cpp +++ b/apps/shared/banner_view.cpp @@ -22,7 +22,7 @@ void BannerView::setMessageAtIndex(I18n::Message text, int index) { } KDSize BannerView::minimalSizeForOptimalDisplay() const { - return KDSize(0, KDText::charSize(KDText::FontSize::Small).height()*numberOfLines()); + return KDSize(0, KDFont::SmallFont->glyphSize().height()*numberOfLines()); } int BannerView::numberOfSubviews() const { @@ -81,7 +81,7 @@ int BannerView::numberOfLines() const { KDCoordinate usedWidth = 0; KDCoordinate lineNumber = 0; for (int i = 0; i < numberOfSubviews(); i++) { - KDCoordinate textWidth = KDText::stringSize(textViewAtIndex(i)->text(), KDText::FontSize::Small).width(); + KDCoordinate textWidth = KDFont::SmallFont->stringSize(textViewAtIndex(i)->text()).width(); if (usedWidth+textWidth > width) { usedWidth = textWidth; lineNumber++; diff --git a/apps/shared/buffer_function_title_cell.cpp b/apps/shared/buffer_function_title_cell.cpp index b6a92b7a2..0d37abcba 100644 --- a/apps/shared/buffer_function_title_cell.cpp +++ b/apps/shared/buffer_function_title_cell.cpp @@ -3,9 +3,9 @@ namespace Shared { -BufferFunctionTitleCell::BufferFunctionTitleCell(Orientation orientation, KDText::FontSize size) : +BufferFunctionTitleCell::BufferFunctionTitleCell(Orientation orientation, const KDFont * font) : FunctionTitleCell(orientation), - m_bufferTextView(size, 0.5f, 0.5f) + m_bufferTextView(font, 0.5f, 0.5f) { } diff --git a/apps/shared/buffer_function_title_cell.h b/apps/shared/buffer_function_title_cell.h index 548fefdf8..c2f8a8b15 100644 --- a/apps/shared/buffer_function_title_cell.h +++ b/apps/shared/buffer_function_title_cell.h @@ -7,12 +7,12 @@ namespace Shared { class BufferFunctionTitleCell : public FunctionTitleCell { public: - BufferFunctionTitleCell(Orientation orientation = Orientation::VerticalIndicator, KDText::FontSize size = KDText::FontSize::Large); + BufferFunctionTitleCell(Orientation orientation = Orientation::VerticalIndicator, const KDFont * font = KDFont::LargeFont); void setEven(bool even) override; void setHighlighted(bool highlight) override; void setColor(KDColor color) override; void setText(const char * textContent); - void setFontSize(KDText::FontSize size) { m_bufferTextView.setFontSize(size); } + void setFont(const KDFont * font) { m_bufferTextView.setFont(font); } const char * text() const override { return m_bufferTextView.text(); } diff --git a/apps/shared/buffer_text_view_with_text_field.cpp b/apps/shared/buffer_text_view_with_text_field.cpp index 4e97fec39..6e5d0758b 100644 --- a/apps/shared/buffer_text_view_with_text_field.cpp +++ b/apps/shared/buffer_text_view_with_text_field.cpp @@ -3,11 +3,11 @@ namespace Shared { -BufferTextViewWithTextField::BufferTextViewWithTextField(Responder * parentResponder, TextFieldDelegate * delegate, KDText::FontSize size) : +BufferTextViewWithTextField::BufferTextViewWithTextField(Responder * parentResponder, TextFieldDelegate * delegate, const KDFont * font) : View(), Responder(parentResponder), - m_bufferTextView(size, 0.0f, 0.5f), - m_textField(this, m_textFieldBuffer, m_textFieldBuffer, k_textFieldBufferSize, delegate, false, size, 0.0f, 0.5f), + m_bufferTextView(font, 0.0f, 0.5f), + m_textField(this, m_textFieldBuffer, m_textFieldBuffer, k_textFieldBufferSize, delegate, false, font, 0.0f, 0.5f), m_textFieldBuffer{} { } diff --git a/apps/shared/buffer_text_view_with_text_field.h b/apps/shared/buffer_text_view_with_text_field.h index 755efd693..0e88ed581 100644 --- a/apps/shared/buffer_text_view_with_text_field.h +++ b/apps/shared/buffer_text_view_with_text_field.h @@ -6,7 +6,7 @@ namespace Shared { class BufferTextViewWithTextField : public View, public Responder { public: - BufferTextViewWithTextField(Responder * parentResponder, TextFieldDelegate * delegate = nullptr, KDText::FontSize size = KDText::FontSize::Large); + BufferTextViewWithTextField(Responder * parentResponder, TextFieldDelegate * delegate = nullptr, const KDFont * font = KDFont::LargeFont); KDSize minimalSizeForOptimalDisplay() const override; TextField * textField() { return &m_textField; } void setBufferText(const char * text); diff --git a/apps/shared/button_with_separator.cpp b/apps/shared/button_with_separator.cpp index cc9049b8a..a4d6dec1c 100644 --- a/apps/shared/button_with_separator.cpp +++ b/apps/shared/button_with_separator.cpp @@ -1,7 +1,7 @@ #include "button_with_separator.h" ButtonWithSeparator::ButtonWithSeparator(Responder * parentResponder, I18n::Message message, Invocation invocation) : - Button(parentResponder, message, invocation, KDText::FontSize::Large, KDColorBlack) + Button(parentResponder, message, invocation, KDFont::LargeFont, KDColorBlack) { } diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index c6c04087c..16b7180c9 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -162,7 +162,7 @@ void CurveView::drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOr graduation = KDRect(horizontalCoordinate-(k_labelGraduationLength-2)/2, std::round(floatToPixel(Axis::Vertical, x)), k_labelGraduationLength, 1); } if (!graduationOnly) { - KDSize textSize = KDText::stringSize(label(axis, i), KDText::FontSize::Small); + KDSize textSize = KDFont::SmallFont->stringSize(label(axis, i)); KDPoint origin(std::round(floatToPixel(Axis::Horizontal, x)) - textSize.width()/2, verticalCoordinate + k_labelMargin); if (axis == Axis::Vertical) { origin = KDPoint(horizontalCoordinate + k_labelMargin, std::round(floatToPixel(Axis::Vertical, x)) - textSize.height()/2); @@ -170,8 +170,8 @@ void CurveView::drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOr if (-step < x && x < step && shiftOrigin) { origin = KDPoint(horizontalCoordinate + k_labelMargin, verticalCoordinate + k_labelMargin); } - if (rect.intersects(KDRect(origin, KDText::stringSize(label(axis, i), KDText::FontSize::Small)))) { - ctx->blendString(label(axis, i), origin, KDText::FontSize::Small, KDColorBlack); + if (rect.intersects(KDRect(origin, KDFont::SmallFont->stringSize(label(axis, i))))) { + ctx->drawString(label(axis, i), origin, KDFont::SmallFont, KDColorBlack); } } ctx->fillRect(graduation, KDColorBlack); diff --git a/apps/shared/expression_model_list_controller.cpp b/apps/shared/expression_model_list_controller.cpp index 2300a9d67..62a17b7b1 100644 --- a/apps/shared/expression_model_list_controller.cpp +++ b/apps/shared/expression_model_list_controller.cpp @@ -27,7 +27,7 @@ KDCoordinate ExpressionModelListController::expressionRowHeight(int j) { return Metric::StoreRowHeight; } KDCoordinate modelSize = m->layout().layoutSize().height(); - return modelSize + Metric::StoreRowHeight - KDText::charSize().height(); + return modelSize + Metric::StoreRowHeight - KDFont::LargeFont->glyphSize().height(); } void ExpressionModelListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { diff --git a/apps/shared/function_list_controller.cpp b/apps/shared/function_list_controller.cpp index 68a5e98c4..caefbe841 100644 --- a/apps/shared/function_list_controller.cpp +++ b/apps/shared/function_list_controller.cpp @@ -13,12 +13,12 @@ FunctionListController::FunctionListController(Responder * parentResponder, Func FunctionListController * list = (FunctionListController *)context; TabViewController * tabController = list->tabController(); tabController->setActiveTab(1); - }, this), KDText::FontSize::Small, Palette::PurpleBright), + }, this), KDFont::SmallFont, Palette::PurpleBright), m_valuesButton(this, I18n::Message::DisplayValues, Invocation([](void * context, void * sender) { FunctionListController * list = (FunctionListController *)context; TabViewController * tabController = list->tabController(); tabController->setActiveTab(2); - }, this), KDText::FontSize::Small, Palette::PurpleBright) + }, this), KDFont::SmallFont, Palette::PurpleBright) { m_selectableTableView.setMargins(0); m_selectableTableView.setVerticalCellOverlap(0); diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 242f0eee6..a97dd51b9 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -18,17 +18,17 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->rangeParameterController()); - }, this), KDText::FontSize::Small), + }, this), KDFont::SmallFont), m_zoomButton(this, I18n::Message::Zoom, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->zoomParameterController()); - }, this), KDText::FontSize::Small), + }, this), KDFont::SmallFont), m_defaultInitialisationButton(this, I18n::Message::Initialization, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->initialisationParameterController()); - }, this), KDText::FontSize::Small) + }, this), KDFont::SmallFont) { } diff --git a/apps/shared/language_controller.cpp b/apps/shared/language_controller.cpp index 59bb83748..d277a28f7 100644 --- a/apps/shared/language_controller.cpp +++ b/apps/shared/language_controller.cpp @@ -12,7 +12,7 @@ LanguageController::LanguageController(Responder * parentResponder, KDCoordinate m_selectableTableView.setTopMargin(topMargin); m_selectableTableView.setBottomMargin(0); for (int i = 0; i < I18n::NumberOfLanguages; i++) { - m_cells[i].setMessageFontSize(KDText::FontSize::Large); + m_cells[i].setMessageFont(KDFont::LargeFont); } } diff --git a/apps/shared/margin_even_odd_message_text_cell.h b/apps/shared/margin_even_odd_message_text_cell.h index 051b988ab..f62ed4f08 100644 --- a/apps/shared/margin_even_odd_message_text_cell.h +++ b/apps/shared/margin_even_odd_message_text_cell.h @@ -7,8 +7,8 @@ namespace Shared { class MarginEvenOddMessageTextCell : public EvenOddMessageTextCell { public: - MarginEvenOddMessageTextCell(KDText::FontSize size = KDText::FontSize::Small) : - EvenOddMessageTextCell(size) + MarginEvenOddMessageTextCell(const KDFont * font = KDFont::SmallFont) : + EvenOddMessageTextCell(font) {} void layoutSubviews() override; private: diff --git a/apps/shared/message_view.cpp b/apps/shared/message_view.cpp index 141830f38..8b5396ee3 100644 --- a/apps/shared/message_view.cpp +++ b/apps/shared/message_view.cpp @@ -4,7 +4,7 @@ MessageView::MessageView(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) { m_numberOfMessages = numberOfMessages < k_maxNumberOfMessages ? numberOfMessages : k_maxNumberOfMessages; for (uint8_t i = 0; i < m_numberOfMessages; i++) { - m_messageTextViews[i].setFontSize(i == 0 ? KDText::FontSize::Large : KDText::FontSize::Small); + m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont); m_messageTextViews[i].setMessage(messages[i]); m_messageTextViews[i].setAlignment(0.5f, 0.5f); m_messageTextViews[i].setTextColor(colors[i]); @@ -29,7 +29,7 @@ void MessageView::layoutSubviews() { } KDCoordinate width = bounds().width(); KDCoordinate titleHeight = m_messageTextViews[0].minimalSizeForOptimalDisplay().height(); - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); m_messageTextViews[0].setFrame(KDRect(0, k_titleMargin, width, titleHeight)); for (uint8_t i = 1; i < m_numberOfMessages; i++) { m_messageTextViews[i].setFrame(KDRect(0, k_paragraphHeight + (i-1) * textHeight, width, textHeight)); diff --git a/apps/shared/scrollable_exact_approximate_expressions_view.cpp b/apps/shared/scrollable_exact_approximate_expressions_view.cpp index 6362f941b..d1c551a1f 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_view.cpp +++ b/apps/shared/scrollable_exact_approximate_expressions_view.cpp @@ -7,7 +7,7 @@ namespace Shared { ScrollableExactApproximateExpressionsView::ContentCell::ContentCell() : m_approximateExpressionView(), - m_approximateSign(KDText::FontSize::Large, I18n::Message::AlmostEqual, 0.5f, 0.5f, Palette::GreyVeryDark), + m_approximateSign(KDFont::LargeFont, I18n::Message::AlmostEqual, 0.5f, 0.5f, Palette::GreyVeryDark), m_exactExpressionView(), m_selectedSubviewType((SubviewType)0) { diff --git a/apps/shared/store_title_cell.h b/apps/shared/store_title_cell.h index 51e3952bf..1a727cc6e 100644 --- a/apps/shared/store_title_cell.h +++ b/apps/shared/store_title_cell.h @@ -8,7 +8,7 @@ namespace Shared { class StoreTitleCell : public BufferFunctionTitleCell { public: StoreTitleCell() : - BufferFunctionTitleCell(Orientation::HorizontalIndicator, KDText::FontSize::Small), + BufferFunctionTitleCell(Orientation::HorizontalIndicator, KDFont::SmallFont), m_separatorLeft(false) {} void setSeparatorLeft(bool separator); diff --git a/apps/shared/sum_graph_controller.cpp b/apps/shared/sum_graph_controller.cpp index 67354d31b..97ed82b0a 100644 --- a/apps/shared/sum_graph_controller.cpp +++ b/apps/shared/sum_graph_controller.cpp @@ -203,8 +203,8 @@ bool SumGraphController::handleEnter() { SumGraphController::LegendView::LegendView(SumGraphController * controller, char sumSymbol) : m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_sumLayout(), - m_legend(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_editableZone(controller, m_draftText, m_draftText, TextField::maxBufferSize(), controller, false, KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_legend(KDFont::SmallFont, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_editableZone(controller, m_draftText, m_draftText, TextField::maxBufferSize(), controller, false, KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_sumSymbol(sumSymbol) { m_draftText[0] = 0; @@ -239,15 +239,15 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl PrintFloat::convertFloatToText(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal); m_sumLayout = CondensedSumLayout( LayoutHelper::String(sigma, sizeof(sigma)), - LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small), - EmptyLayout(EmptyLayoutNode::Color::Yellow, false, KDText::FontSize::Small, false)); + LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont), + EmptyLayout(EmptyLayoutNode::Color::Yellow, false, KDFont::SmallFont, false)); } else { m_sumLayout = LayoutHelper::String(sigma, sizeof(sigma)); char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal); - Layout start = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small); + Layout start = LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont); PrintFloat::convertFloatToText(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal); - Layout end = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small); + Layout end = LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont); m_sumLayout = CondensedSumLayout( LayoutHelper::String(sigma, sizeof(sigma)), start, @@ -257,7 +257,7 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl m_sumLayout = HorizontalLayout( m_sumLayout, functionLayout, - LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small)); + LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont)); } m_sum.setLayout(m_sumLayout); if (step == Step::Result) { @@ -300,13 +300,26 @@ void SumGraphController::LegendView::layoutSubviews(Step step) { m_legend.setFrame(KDRectZero); } - KDSize largeCharSize = KDText::charSize(); + KDCoordinate largeGlyphWidth = KDFont::LargeFont->glyphSize().width(); + KDCoordinate editableZoneWidth = 12 * KDFont::SmallFont->glyphSize().width(); + KDCoordinate editableZoneHeight = KDFont::SmallFont->glyphSize().height(); + switch(step) { case Step::FirstParameter: - m_editableZone.setFrame(KDRect(2*largeCharSize.width(), k_symbolHeightMargin+k_sigmaHeight/2, k_editableZoneWidth, k_editableZoneHeight)); + m_editableZone.setFrame(KDRect( + 2 * largeGlyphWidth, + k_symbolHeightMargin + k_sigmaHeight/2, + editableZoneWidth, + editableZoneHeight + )); return; case Step::SecondParameter: - m_editableZone.setFrame(KDRect(2*largeCharSize.width(), k_symbolHeightMargin+k_sigmaHeight/2-k_editableZoneHeight, k_editableZoneWidth, k_editableZoneHeight)); + m_editableZone.setFrame(KDRect( + 2 * largeGlyphWidth, + k_symbolHeightMargin + k_sigmaHeight/2 - editableZoneHeight, + editableZoneWidth, + editableZoneHeight + )); return; default: m_editableZone.setFrame(KDRectZero); diff --git a/apps/shared/sum_graph_controller.h b/apps/shared/sum_graph_controller.h index 0b1327577..13f738cb6 100644 --- a/apps/shared/sum_graph_controller.h +++ b/apps/shared/sum_graph_controller.h @@ -61,8 +61,6 @@ private: void setSumSymbol(Step step, double start = NAN, double end = NAN, double result = NAN, Poincare::Layout sequenceName = Poincare::Layout()); private: constexpr static KDCoordinate k_legendHeight = 35; - constexpr static KDCoordinate k_editableZoneWidth = 12*KDText::charSize(KDText::FontSize::Small).width(); - constexpr static KDCoordinate k_editableZoneHeight = KDText::charSize(KDText::FontSize::Small).height(); constexpr static KDCoordinate k_symbolHeightMargin = 8; constexpr static KDCoordinate k_sigmaHeight = 18; int numberOfSubviews() const override; diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index 2222d3384..33d4e9d38 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -23,7 +23,7 @@ ValuesController::ValuesController(Responder * parentResponder, ButtonRowControl ValuesController * valuesController = (ValuesController *) context; StackViewController * stack = ((StackViewController *)valuesController->stackController()); stack->push(valuesController->intervalParameterController()); - }, this), KDText::FontSize::Small) + }, this), KDFont::SmallFont) { m_selectableTableView.setVerticalCellOverlap(0); m_selectableTableView.setTopMargin(k_topMargin); @@ -32,12 +32,12 @@ ValuesController::ValuesController(Responder * parentResponder, ButtonRowControl m_selectableTableView.setLeftMargin(k_leftMargin); m_selectableTableView.setBackgroundColor(Palette::WallScreenDark); m_selectableTableView.setIndicatorThickness(13); - m_abscissaTitleCell.setMessageFontSize(KDText::FontSize::Small); + m_abscissaTitleCell.setMessageFont(KDFont::SmallFont); for (int i = 0; i < k_maxNumberOfAbscissaCells; i++) { m_abscissaCells[i].setParentResponder(&m_selectableTableView); m_abscissaCells[i].editableTextCell()->textField()->setDelegate(this); m_abscissaCells[i].editableTextCell()->textField()->setDraftTextBuffer(m_draftTextBuffer); - m_abscissaCells[i].editableTextCell()->textField()->setFontSize(KDText::FontSize::Small); + m_abscissaCells[i].editableTextCell()->textField()->setFont(KDFont::SmallFont); } } diff --git a/apps/shared/zoom_parameter_controller.cpp b/apps/shared/zoom_parameter_controller.cpp index 149e1d8dc..92a9aa179 100644 --- a/apps/shared/zoom_parameter_controller.cpp +++ b/apps/shared/zoom_parameter_controller.cpp @@ -101,7 +101,7 @@ ZoomParameterController::ContentView::LegendView::LegendView() I18n::Message messages[k_numberOfLegends] = {I18n::Message::Move, I18n::Message::ToZoom, I18n::Message::Or}; float horizontalAlignments[k_numberOfLegends] = {1.0f, 1.0f, 0.5f}; for (int i = 0; i < k_numberOfLegends; i++) { - m_legends[i].setFontSize(KDText::FontSize::Small); + m_legends[i].setFont(KDFont::SmallFont); m_legends[i].setMessage(messages[i]); m_legends[i].setBackgroundColor(Palette::GreyBright); m_legends[i].setAlignment(horizontalAlignments[i], 0.5f); diff --git a/apps/shift_alpha_lock_view.cpp b/apps/shift_alpha_lock_view.cpp index b3423173e..ae811e1d3 100644 --- a/apps/shift_alpha_lock_view.cpp +++ b/apps/shift_alpha_lock_view.cpp @@ -2,7 +2,7 @@ ShiftAlphaLockView::ShiftAlphaLockView() : View(), - m_shiftAlphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), + m_shiftAlphaView(KDFont::SmallFont, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), m_status(Ion::Events::ShiftAlphaStatus::Default) { } @@ -37,7 +37,7 @@ bool ShiftAlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { } KDSize ShiftAlphaLockView::minimalSizeForOptimalDisplay() const { - KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); + KDSize modifierSize = KDFont::SmallFont->stringSize(I18n::translate(I18n::Message::Alpha)); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); KDCoordinate height = lockSize.height() > modifierSize.height() ? lockSize.height() : modifierSize.height(); return KDSize(modifierSize.width() + lockSize.width() + k_lockRightMargin, height); @@ -66,7 +66,7 @@ View * ShiftAlphaLockView::subviewAtIndex(int index) { } void ShiftAlphaLockView::layoutSubviews() { - KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); + KDSize modifierSize = KDFont::SmallFont->stringSize(I18n::translate(I18n::Message::Alpha)); m_shiftAlphaView.setFrame(KDRect(bounds().width() - modifierSize.width(), (bounds().height()- modifierSize.height())/2, modifierSize)); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); diff --git a/apps/solver/equation_models_parameter_controller.cpp b/apps/solver/equation_models_parameter_controller.cpp index 12548a91c..d53d42746 100644 --- a/apps/solver/equation_models_parameter_controller.cpp +++ b/apps/solver/equation_models_parameter_controller.cpp @@ -13,7 +13,7 @@ constexpr const char * EquationModelsParameterController::k_models[k_numberOfMod EquationModelsParameterController::EquationModelsParameterController(Responder * parentResponder, EquationStore * equationStore, ListController * listController) : ViewController(parentResponder), - m_emptyModelCell(I18n::Message::Empty, KDText::FontSize::Large), + m_emptyModelCell(I18n::Message::Empty, KDFont::LargeFont), m_layouts{}, m_selectableTableView(this), m_equationStore(equationStore), diff --git a/apps/solver/interval_controller.cpp b/apps/solver/interval_controller.cpp index 7c4302920..87fd46584 100644 --- a/apps/solver/interval_controller.cpp +++ b/apps/solver/interval_controller.cpp @@ -7,8 +7,8 @@ namespace Solver { IntervalController::ContentView::ContentView(SelectableTableView * selectableTableView) : - m_instructions0(KDText::FontSize::Small, I18n::Message::ApproximateSolutionIntervalInstruction0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), - m_instructions1(KDText::FontSize::Small, I18n::Message::ApproximateSolutionIntervalInstruction1, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), + m_instructions0(KDFont::SmallFont, I18n::Message::ApproximateSolutionIntervalInstruction0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), + m_instructions1(KDFont::SmallFont, I18n::Message::ApproximateSolutionIntervalInstruction1, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), m_selectableTableView(selectableTableView) { } @@ -33,7 +33,7 @@ View * IntervalController::ContentView::subviewAtIndex(int index) { } void IntervalController::ContentView::layoutSubviews() { - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); m_instructions0.setFrame(KDRect(0, k_topMargin/2-textHeight, bounds().width(), textHeight)); m_instructions1.setFrame(KDRect(0, k_topMargin/2, bounds().width(), textHeight)); m_selectableTableView->setFrame(KDRect(0, k_topMargin, bounds().width(), bounds().height()-k_topMargin)); diff --git a/apps/solver/list_controller.cpp b/apps/solver/list_controller.cpp index 9258d1250..c6cacdcf7 100644 --- a/apps/solver/list_controller.cpp +++ b/apps/solver/list_controller.cpp @@ -15,7 +15,7 @@ ListController::ListController(Responder * parentResponder, EquationStore * equa m_resolveButton(this, equationStore->numberOfDefinedModels() > 1 ? I18n::Message::ResolveSystem : I18n::Message::ResolveEquation, Invocation([](void * context, void * sender) { ListController * list = (ListController *)context; list->resolveEquations(); - }, this), KDText::FontSize::Large, Palette::PurpleBright), + }, this), KDFont::LargeFont, Palette::PurpleBright), m_modelsParameterController(this, equationStore, this), m_modelsStackController(nullptr, &m_modelsParameterController, KDColorWhite, Palette::PurpleDark, Palette::PurpleDark) { diff --git a/apps/solver/solutions_controller.cpp b/apps/solver/solutions_controller.cpp index 576447e15..64da4881d 100644 --- a/apps/solver/solutions_controller.cpp +++ b/apps/solver/solutions_controller.cpp @@ -11,8 +11,8 @@ using namespace Shared; namespace Solver { SolutionsController::ContentView::ContentView(SolutionsController * controller) : - m_warningMessageView0(KDText::FontSize::Small, I18n::Message::OnlyFirstSolutionsDisplayed0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreenDark), - m_warningMessageView1(KDText::FontSize::Small, I18n::Message::OnlyFirstSolutionsDisplayed1, 0.5f, 0.5f, KDColorBlack, Palette::WallScreenDark), + m_warningMessageView0(KDFont::SmallFont, I18n::Message::OnlyFirstSolutionsDisplayed0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreenDark), + m_warningMessageView1(KDFont::SmallFont, I18n::Message::OnlyFirstSolutionsDisplayed1, 0.5f, 0.5f, KDColorBlack, Palette::WallScreenDark), m_selectableTableView(controller), m_displayWarningMoreSolutions(false) { @@ -50,7 +50,7 @@ View * SolutionsController::ContentView::subviewAtIndex(int index) { void SolutionsController::ContentView::layoutSubviews() { if (m_displayWarningMoreSolutions) { - KDCoordinate textHeight = KDText::charSize(KDText::FontSize::Small).height(); + KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); m_warningMessageView0.setFrame(KDRect(0, k_topMargin/2-textHeight, bounds().width(), textHeight)); m_warningMessageView1.setFrame(KDRect(0, k_topMargin/2, bounds().width(), textHeight)); m_selectableTableView.setFrame(KDRect(0, k_topMargin, bounds().width(), bounds().height()-k_topMargin)); @@ -66,14 +66,14 @@ SolutionsController::SolutionsController(Responder * parentResponder, EquationSt m_delta2Layout(), m_contentView(this) { - m_delta2Layout = HorizontalLayout(VerticalOffsetLayout(CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small)); + m_delta2Layout = HorizontalLayout(VerticalOffsetLayout(CharLayout('2', KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript), LayoutHelper::String("-4ac", 4, KDFont::SmallFont)); char deltaB[] = {Ion::Charset::CapitalDelta, '=', 'b'}; - static_cast(m_delta2Layout).addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false); + static_cast(m_delta2Layout).addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDFont::SmallFont), 0, false); for (int i = 0; i < EquationStore::k_maxNumberOfExactSolutions; i++) { m_exactValueCells[i].setParentResponder(m_contentView.selectableTableView()); } for (int i = 0; i < EquationStore::k_maxNumberOfApproximateSolutions; i++) { - m_approximateValueCells[i].setFontSize(KDText::FontSize::Large); + m_approximateValueCells[i].setFont(KDFont::LargeFont); } for (int i = 0; i < EquationStore::k_maxNumberOfSolutions; i++) { m_symbolCells[i].setAlignment(0.5f, 0.5f); @@ -148,7 +148,7 @@ void SolutionsController::willDisplayCellAtLocation(HighlightCell * cell, int i, deltaCell->setLayout(m_delta2Layout); } else { EvenOddBufferTextCell * symbolCell = static_cast(cell); - symbolCell->setFontSize(KDText::FontSize::Large); + symbolCell->setFont(KDFont::LargeFont); char bufferSymbol[10]; // hold at maximum Delta = b^2-4ac switch (m_equationStore->type()) { case EquationStore::Type::LinearSystem: diff --git a/apps/statistics/box_banner_view.cpp b/apps/statistics/box_banner_view.cpp index 6d3b87741..4bd8a5238 100644 --- a/apps/statistics/box_banner_view.cpp +++ b/apps/statistics/box_banner_view.cpp @@ -3,9 +3,9 @@ namespace Statistics { BoxBannerView::BoxBannerView() : - m_seriesName(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_calculationName(KDText::FontSize::Small, I18n::Message::Minimum, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_calculationValue(KDText::FontSize::Small, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) + m_seriesName(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_calculationName(KDFont::SmallFont, I18n::Message::Minimum, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_calculationValue(KDFont::SmallFont, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) { } diff --git a/apps/statistics/histogram_banner_view.cpp b/apps/statistics/histogram_banner_view.cpp index 95c36180b..aff3f6448 100644 --- a/apps/statistics/histogram_banner_view.cpp +++ b/apps/statistics/histogram_banner_view.cpp @@ -6,12 +6,12 @@ namespace Statistics { HistogramBannerView::HistogramBannerView() : - m_intervalLegendView(KDText::FontSize::Small, I18n::Message::Interval, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_intervalView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sizeLegendView(KDText::FontSize::Small, I18n::Message::Size, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sizeView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_frequencyLegendView(KDText::FontSize::Small, I18n::Message::Frequency, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_frequencyView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) + m_intervalLegendView(KDFont::SmallFont, I18n::Message::Interval, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_intervalView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_sizeLegendView(KDFont::SmallFont, I18n::Message::Size, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_sizeView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_frequencyLegendView(KDFont::SmallFont, I18n::Message::Frequency, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_frequencyView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) { } diff --git a/apps/title_bar_view.cpp b/apps/title_bar_view.cpp index 460e1940f..67cf74185 100644 --- a/apps/title_bar_view.cpp +++ b/apps/title_bar_view.cpp @@ -10,8 +10,8 @@ using namespace Poincare; TitleBarView::TitleBarView() : View(), - m_titleView(KDText::FontSize::Small, I18n::Message::Default, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark), - m_preferenceView(KDText::FontSize::Small, 1.0f, 0.5, KDColorWhite, Palette::YellowDark) + m_titleView(KDFont::SmallFont, I18n::Message::Default, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark), + m_preferenceView(KDFont::SmallFont, 1.0f, 0.5, KDColorWhite, Palette::YellowDark) { m_examModeIconView.setImage(ImageStore::ExamIcon); } diff --git a/apps/variable_box_leaf_cell.cpp b/apps/variable_box_leaf_cell.cpp index fdb943d96..e0cc56760 100644 --- a/apps/variable_box_leaf_cell.cpp +++ b/apps/variable_box_leaf_cell.cpp @@ -5,8 +5,8 @@ using namespace Poincare; VariableBoxLeafCell::VariableBoxLeafCell() : HighlightCell(), - m_labelView(KDText::FontSize::Small, 0, 0.5, KDColorBlack, KDColorWhite), - m_subtitleView(KDText::FontSize::Small, 0, 0.5, Palette::GreyDark, KDColorWhite), + m_labelView(KDFont::SmallFont, 0, 0.5, KDColorBlack, KDColorWhite), + m_subtitleView(KDFont::SmallFont, 0, 0.5, Palette::GreyDark, KDColorWhite), m_expressionView(1.0f, 0.5f), m_displayExpression(false) { diff --git a/escher/include/escher/buffer_text_view.h b/escher/include/escher/buffer_text_view.h index 78de5482a..739041cc7 100644 --- a/escher/include/escher/buffer_text_view.h +++ b/escher/include/escher/buffer_text_view.h @@ -5,7 +5,7 @@ class BufferTextView : public TextView { public: - BufferTextView(KDText::FontSize size = KDText::FontSize::Large, float horizontalAlignment = 0.5f, float verticalAlignment = 0.5f, + BufferTextView(const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 0.5f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; const char * text() const override; diff --git a/escher/include/escher/button.h b/escher/include/escher/button.h index fc3633a98..a163b00a9 100644 --- a/escher/include/escher/button.h +++ b/escher/include/escher/button.h @@ -10,7 +10,7 @@ class Button : public HighlightCell, public Responder { public: - Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, KDText::FontSize size = KDText::FontSize::Small, KDColor textColor = KDColorBlack); + Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, const KDFont * font = KDFont::SmallFont, KDColor textColor = KDColorBlack); void setMessage(I18n::Message message); bool handleEvent(Ion::Events::Event event) override; void setHighlighted(bool highlight) override; @@ -29,7 +29,7 @@ private: View * subviewAtIndex(int index) override; void layoutSubviews() override; Invocation m_invocation; - KDText::FontSize m_size; + const KDFont * m_font; }; #endif diff --git a/escher/include/escher/editable_text_cell.h b/escher/include/escher/editable_text_cell.h index 6b9141565..053b8e02d 100644 --- a/escher/include/escher/editable_text_cell.h +++ b/escher/include/escher/editable_text_cell.h @@ -8,7 +8,7 @@ class EditableTextCell : public HighlightCell, public Responder { public: - EditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr, KDText::FontSize size = KDText::FontSize::Large, + EditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr, const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); TextField * textField(); void setMargins(KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); diff --git a/escher/include/escher/even_odd_buffer_text_cell.h b/escher/include/escher/even_odd_buffer_text_cell.h index 2b7ddfaa0..c4410494c 100644 --- a/escher/include/escher/even_odd_buffer_text_cell.h +++ b/escher/include/escher/even_odd_buffer_text_cell.h @@ -6,10 +6,10 @@ class EvenOddBufferTextCell : public EvenOddCell { public: - EvenOddBufferTextCell(KDText::FontSize size = KDText::FontSize::Small, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f); + EvenOddBufferTextCell(const KDFont * font = KDFont::SmallFont, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f); const char * text() const override; - void setFontSize(KDText::FontSize fontSize) { - m_bufferTextView.setFontSize(fontSize); + void setFont(const KDFont * font) { + m_bufferTextView.setFont(font); } void setAlignment(float horizontalAlignment, float verticalAlignment) { m_bufferTextView.setAlignment(horizontalAlignment, verticalAlignment); diff --git a/escher/include/escher/even_odd_editable_text_cell.h b/escher/include/escher/even_odd_editable_text_cell.h index 635625ee5..50a9eeef7 100644 --- a/escher/include/escher/even_odd_editable_text_cell.h +++ b/escher/include/escher/even_odd_editable_text_cell.h @@ -7,7 +7,7 @@ class EvenOddEditableTextCell : public EvenOddCell, public Responder { public: - EvenOddEditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr, KDText::FontSize size = KDText::FontSize::Large, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); + EvenOddEditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr, const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); EditableTextCell * editableTextCell(); void setEven(bool even) override; void setHighlighted(bool highlight) override; diff --git a/escher/include/escher/even_odd_message_text_cell.h b/escher/include/escher/even_odd_message_text_cell.h index ef76ce2ba..88b617024 100644 --- a/escher/include/escher/even_odd_message_text_cell.h +++ b/escher/include/escher/even_odd_message_text_cell.h @@ -7,12 +7,12 @@ class EvenOddMessageTextCell : public EvenOddCell { public: - EvenOddMessageTextCell(KDText::FontSize size = KDText::FontSize::Large); + EvenOddMessageTextCell(const KDFont * font = KDFont::LargeFont); void setEven(bool even) override; void setHighlighted(bool highlight) override; void setMessage(I18n::Message textContent, KDColor textColor = KDColorBlack); void setAlignment(float horizontalAlignment, float verticalAlignment); - void setMessageFontSize(KDText::FontSize size) { m_messageTextView.setFontSize(size); } + void setMessageFont(const KDFont * font) { m_messageTextView.setFont(font); } protected: int numberOfSubviews() const override; View * subviewAtIndex(int index) override; diff --git a/escher/include/escher/message_table_cell.h b/escher/include/escher/message_table_cell.h index 3b820283a..b87480201 100644 --- a/escher/include/escher/message_table_cell.h +++ b/escher/include/escher/message_table_cell.h @@ -7,12 +7,12 @@ class MessageTableCell : public TableCell { public: - MessageTableCell(I18n::Message label = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small, Layout layout = Layout::Horizontal); + MessageTableCell(I18n::Message label = (I18n::Message)0, const KDFont * font = KDFont::SmallFont, Layout layout = Layout::Horizontal); View * labelView() const override; virtual void setHighlighted(bool highlight) override; void setMessage(I18n::Message message); virtual void setTextColor(KDColor color); - void setMessageFontSize(KDText::FontSize fontSize); + void setMessageFont(const KDFont * font); private: MessageTextView m_messageTextView; }; diff --git a/escher/include/escher/message_table_cell_with_buffer.h b/escher/include/escher/message_table_cell_with_buffer.h index c88d5512d..a2d014c08 100644 --- a/escher/include/escher/message_table_cell_with_buffer.h +++ b/escher/include/escher/message_table_cell_with_buffer.h @@ -6,14 +6,18 @@ class MessageTableCellWithBuffer : public MessageTableCell { public: - MessageTableCellWithBuffer(I18n::Message message = (I18n::Message)0, KDText::FontSize fontSize = KDText::FontSize::Small, KDText::FontSize accessoryFontSize = KDText::FontSize::Large, KDColor accessoryTextColor = KDColorBlack); + MessageTableCellWithBuffer(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont, const KDFont * accessoryFont = KDFont::LargeFont, KDColor accessoryTextColor = KDColorBlack); View * accessoryView() const override; void setHighlighted(bool highlight) override; void setAccessoryText(const char * textBody); const char * accessoryText(); void setTextColor(KDColor color) override; - void setAccessoryTextColor(KDColor color); - void setAccessoryFontSize(KDText::FontSize fontSize); + void setAccessoryTextColor(KDColor color) { + m_accessoryView.setTextColor(color); + } + void setAccessoryFont(const KDFont * font) { + m_accessoryView.setFont(font); + } const char * text() const override { return m_accessoryView.text(); } diff --git a/escher/include/escher/message_table_cell_with_chevron.h b/escher/include/escher/message_table_cell_with_chevron.h index 589da1103..2611346d4 100644 --- a/escher/include/escher/message_table_cell_with_chevron.h +++ b/escher/include/escher/message_table_cell_with_chevron.h @@ -6,7 +6,7 @@ class MessageTableCellWithChevron : public MessageTableCell { public: - MessageTableCellWithChevron(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); + MessageTableCellWithChevron(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont); View * accessoryView() const override; private: ChevronView m_accessoryView; diff --git a/escher/include/escher/message_table_cell_with_chevron_and_expression.h b/escher/include/escher/message_table_cell_with_chevron_and_expression.h index d6d196df0..f94cac89b 100644 --- a/escher/include/escher/message_table_cell_with_chevron_and_expression.h +++ b/escher/include/escher/message_table_cell_with_chevron_and_expression.h @@ -6,7 +6,7 @@ class MessageTableCellWithChevronAndExpression : public MessageTableCellWithChevron { public: - MessageTableCellWithChevronAndExpression(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); + MessageTableCellWithChevronAndExpression(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont); View * subAccessoryView() const override; void setHighlighted(bool highlight) override; void setLayout(Poincare::Layout layoutR); diff --git a/escher/include/escher/message_table_cell_with_chevron_and_message.h b/escher/include/escher/message_table_cell_with_chevron_and_message.h index 6f3044293..976dc69ad 100644 --- a/escher/include/escher/message_table_cell_with_chevron_and_message.h +++ b/escher/include/escher/message_table_cell_with_chevron_and_message.h @@ -5,7 +5,7 @@ class MessageTableCellWithChevronAndMessage : public MessageTableCellWithChevron { public: - MessageTableCellWithChevronAndMessage(KDText::FontSize labelSize = KDText::FontSize::Small, KDText::FontSize contentSize = KDText::FontSize::Small); + MessageTableCellWithChevronAndMessage(const KDFont * labelFont = KDFont::SmallFont, const KDFont * contentFont = KDFont::SmallFont); View * subAccessoryView() const override; void setHighlighted(bool highlight) override; void setSubtitle(I18n::Message text); diff --git a/escher/include/escher/message_table_cell_with_expression.h b/escher/include/escher/message_table_cell_with_expression.h index 369b4180d..c01d8af76 100644 --- a/escher/include/escher/message_table_cell_with_expression.h +++ b/escher/include/escher/message_table_cell_with_expression.h @@ -6,7 +6,7 @@ class MessageTableCellWithExpression : public MessageTableCell { public: - MessageTableCellWithExpression(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); + MessageTableCellWithExpression(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont); View * accessoryView() const override; void setHighlighted(bool highlight) override; void setLayout(Poincare::Layout layout); diff --git a/escher/include/escher/message_table_cell_with_gauge.h b/escher/include/escher/message_table_cell_with_gauge.h index c1e9d530f..8dfddf599 100644 --- a/escher/include/escher/message_table_cell_with_gauge.h +++ b/escher/include/escher/message_table_cell_with_gauge.h @@ -6,7 +6,7 @@ class MessageTableCellWithGauge : public MessageTableCell { public: - MessageTableCellWithGauge(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); + MessageTableCellWithGauge(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont); View * accessoryView() const override; void setHighlighted(bool highlight) override; private: diff --git a/escher/include/escher/message_table_cell_with_switch.h b/escher/include/escher/message_table_cell_with_switch.h index 3edff521d..78e27ef07 100644 --- a/escher/include/escher/message_table_cell_with_switch.h +++ b/escher/include/escher/message_table_cell_with_switch.h @@ -6,7 +6,7 @@ class MessageTableCellWithSwitch : public MessageTableCell { public: - MessageTableCellWithSwitch(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); + MessageTableCellWithSwitch(I18n::Message message = (I18n::Message)0, const KDFont * font = KDFont::SmallFont); View * accessoryView() const override; private: SwitchView m_accessoryView; diff --git a/escher/include/escher/message_text_view.h b/escher/include/escher/message_text_view.h index 4ca547ea4..7ae1e978b 100644 --- a/escher/include/escher/message_text_view.h +++ b/escher/include/escher/message_text_view.h @@ -6,7 +6,7 @@ class MessageTextView : public TextView { public: - MessageTextView(KDText::FontSize size = KDText::FontSize::Large, I18n::Message message = (I18n::Message)0, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + MessageTextView(const KDFont * font = KDFont::LargeFont, I18n::Message message = (I18n::Message)0, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; void setMessage(I18n::Message message); diff --git a/escher/include/escher/pointer_text_view.h b/escher/include/escher/pointer_text_view.h index c5877fa9c..432ee3147 100644 --- a/escher/include/escher/pointer_text_view.h +++ b/escher/include/escher/pointer_text_view.h @@ -6,7 +6,7 @@ class PointerTextView : public TextView { public: - PointerTextView(KDText::FontSize size = KDText::FontSize::Large, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + PointerTextView(const KDFont * font = KDFont::LargeFont, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); const char * text() const override { return m_text; } void setText(const char * text) override; diff --git a/escher/include/escher/solid_text_area.h b/escher/include/escher/solid_text_area.h index 54d1b934f..e38ffe498 100644 --- a/escher/include/escher/solid_text_area.h +++ b/escher/include/escher/solid_text_area.h @@ -8,15 +8,15 @@ class SolidTextArea : public TextArea { public: - SolidTextArea(Responder * parentResponder, KDText::FontSize fontSize = KDText::FontSize::Large, + SolidTextArea(Responder * parentResponder, const KDFont * font = KDFont::LargeFont, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite) : - TextArea(parentResponder, &m_contentView, fontSize), - m_contentView(fontSize, textColor, backgroundColor) {} + TextArea(parentResponder, &m_contentView, font), + m_contentView(font, textColor, backgroundColor) {} protected: class ContentView : public TextArea::ContentView { public: - ContentView(KDText::FontSize fontSize, KDColor textColor, KDColor backgroundColor) : - TextArea::ContentView(fontSize), + ContentView(const KDFont * font, KDColor textColor, KDColor backgroundColor) : + TextArea::ContentView(font), m_textColor(textColor), m_backgroundColor(backgroundColor) { diff --git a/escher/include/escher/text_area.h b/escher/include/escher/text_area.h index ee11e3317..8c11b2856 100644 --- a/escher/include/escher/text_area.h +++ b/escher/include/escher/text_area.h @@ -8,7 +8,7 @@ class TextArea : public TextInput { public: - TextArea(Responder * parentResponder, View * contentView, KDText::FontSize fontSize = KDText::FontSize::Large); + TextArea(Responder * parentResponder, View * contentView, const KDFont * font = KDFont::LargeFont); void setDelegate(TextAreaDelegate * delegate) { m_delegate = delegate; } bool handleEvent(Ion::Events::Event event) override; bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) override; @@ -93,8 +93,8 @@ protected: class ContentView : public TextInput::ContentView { public: - ContentView(KDText::FontSize fontSize) : - TextInput::ContentView(fontSize), + ContentView(const KDFont * font) : + TextInput::ContentView(font), m_text(nullptr, 0) { } diff --git a/escher/include/escher/text_field.h b/escher/include/escher/text_field.h index b6a2bbf03..d3fe2f821 100644 --- a/escher/include/escher/text_field.h +++ b/escher/include/escher/text_field.h @@ -8,7 +8,7 @@ class TextField : public TextInput { public: TextField(Responder * parentResponder, char * textBuffer, char * draftTextBuffer, size_t textBufferSize, - TextFieldDelegate * delegate = nullptr, bool hasTwoBuffers = true, KDText::FontSize size = KDText::FontSize::Large, + TextFieldDelegate * delegate = nullptr, bool hasTwoBuffers = true, const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setBackgroundColor(KDColor backgroundColor) override; void setTextColor(KDColor textColor); @@ -30,7 +30,7 @@ public: protected: class ContentView : public TextInput::ContentView { public: - ContentView(char * textBuffer, char * draftTextBuffer, size_t textBufferSize, KDText::FontSize size, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); + ContentView(char * textBuffer, char * draftTextBuffer, size_t textBufferSize, const KDFont * font, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); void setBackgroundColor(KDColor backgroundColor); KDColor backgroundColor() const { return m_backgroundColor; } void setTextColor(KDColor textColor); diff --git a/escher/include/escher/text_input.h b/escher/include/escher/text_input.h index 55dde64ed..77801ea03 100644 --- a/escher/include/escher/text_input.h +++ b/escher/include/escher/text_input.h @@ -10,7 +10,7 @@ class TextInput : public ScrollableView, public ScrollViewDataSource { public: TextInput(Responder * parentResponder, View * contentView); - void setFontSize(KDText::FontSize size) { contentView()->setFontSize(size); } + void setFont(const KDFont * font) { contentView()->setFont(font); } Toolbox * toolbox() override; const char * text() const { return nonEditableContentView()->text(); } bool removeChar(); @@ -20,8 +20,8 @@ public: protected: class ContentView : public View { public: - ContentView(KDText::FontSize size); - void setFontSize(KDText::FontSize size); + ContentView(const KDFont * font); + void setFont(const KDFont * font); size_t cursorLocation() const { return m_cursorIndex; } void setCursorLocation(int cursorLocation); virtual const char * text() const = 0; @@ -35,7 +35,7 @@ protected: void reloadRectFromCursorPosition(size_t index, bool lineBreak = false); virtual KDRect characterFrameAtIndex(size_t index) const = 0; TextCursorView m_cursorView; - KDText::FontSize m_fontSize; + const KDFont * m_font; size_t m_cursorIndex; private: int numberOfSubviews() const override; diff --git a/escher/include/escher/text_view.h b/escher/include/escher/text_view.h index e2309a661..e252a9360 100644 --- a/escher/include/escher/text_view.h +++ b/escher/include/escher/text_view.h @@ -9,7 +9,7 @@ public: // alignment = 0 -> align left or top // alignment = 0.5 -> align center // alignment = 1.0 -> align right or bottom - TextView(KDText::FontSize size = KDText::FontSize::Large, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + TextView(const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void drawRect(KDContext * ctx, KDRect rect) const override; void setBackgroundColor(KDColor backgroundColor); @@ -18,12 +18,12 @@ public: KDSize minimalSizeForOptimalDisplay() const override; virtual const char * text() const = 0; virtual void setText(const char * text) = 0; - void setFontSize(KDText::FontSize fontSize); + void setFont(const KDFont * font); protected: #if ESCHER_VIEW_LOGGING const char * className() const override; #endif - KDText::FontSize m_fontSize; + const KDFont * m_font; float m_horizontalAlignment; float m_verticalAlignment; KDColor m_textColor; diff --git a/escher/include/escher/view.h b/escher/include/escher/view.h index 262167d2f..f674a47b8 100644 --- a/escher/include/escher/view.h +++ b/escher/include/escher/view.h @@ -3,8 +3,8 @@ extern "C" { #include -#include } +#include #if ESCHER_VIEW_LOGGING #include diff --git a/escher/src/alternate_empty_view_controller.cpp b/escher/src/alternate_empty_view_controller.cpp index 21c9dff51..4aaf3ff1b 100644 --- a/escher/src/alternate_empty_view_controller.cpp +++ b/escher/src/alternate_empty_view_controller.cpp @@ -6,7 +6,7 @@ /* ContentView */ AlternateEmptyViewController::ContentView::ContentView(ViewController * mainViewController, AlternateEmptyViewDelegate * delegate) : - m_message(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), + m_message(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen), m_mainViewController(mainViewController), m_delegate(delegate) { diff --git a/escher/src/buffer_text_view.cpp b/escher/src/buffer_text_view.cpp index ea006c69a..5a456aed3 100644 --- a/escher/src/buffer_text_view.cpp +++ b/escher/src/buffer_text_view.cpp @@ -2,9 +2,9 @@ #include #include -BufferTextView::BufferTextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment, +BufferTextView::BufferTextView(const KDFont * font, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + TextView(font, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_buffer() { } diff --git a/escher/src/button.cpp b/escher/src/button.cpp index 1f2bbf33f..3c9551f2e 100644 --- a/escher/src/button.cpp +++ b/escher/src/button.cpp @@ -2,12 +2,12 @@ #include #include -Button::Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, KDText::FontSize size, KDColor textColor) : +Button::Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, const KDFont * font, KDColor textColor) : HighlightCell(), Responder(parentResponder), - m_messageTextView(size, textBody, 0.5f, 0.5f, textColor), + m_messageTextView(font, textBody, 0.5f, 0.5f, textColor), m_invocation(invocation), - m_size(size) + m_font(font) { } @@ -45,5 +45,5 @@ void Button::setHighlighted(bool highlight) { KDSize Button::minimalSizeForOptimalDisplay() const { KDSize textSize = m_messageTextView.minimalSizeForOptimalDisplay(); - return KDSize(textSize.width() + (m_size == KDText::FontSize::Small ? k_horizontalMarginSmall : k_horizontalMarginLarge), textSize.height() + k_verticalMargin); + return KDSize(textSize.width() + (m_font == KDFont::SmallFont ? k_horizontalMarginSmall : k_horizontalMarginLarge), textSize.height() + k_verticalMargin); } diff --git a/escher/src/editable_text_cell.cpp b/escher/src/editable_text_cell.cpp index 562565d84..0e3557917 100644 --- a/escher/src/editable_text_cell.cpp +++ b/escher/src/editable_text_cell.cpp @@ -4,10 +4,10 @@ #include EditableTextCell::EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, - KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : + const KDFont * font, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : HighlightCell(), Responder(parentResponder), - m_textField(this, m_textBody, draftTextBuffer, TextField::maxBufferSize(), delegate, true, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + m_textField(this, m_textBody, draftTextBuffer, TextField::maxBufferSize(), delegate, true, font, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_topMargin(topMargin), m_rightMargin(rightMargin), m_bottomMargin(bottomMargin), diff --git a/escher/src/even_odd_buffer_text_cell.cpp b/escher/src/even_odd_buffer_text_cell.cpp index 051f8712d..0e33e2d0c 100644 --- a/escher/src/even_odd_buffer_text_cell.cpp +++ b/escher/src/even_odd_buffer_text_cell.cpp @@ -1,9 +1,9 @@ #include #include -EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size, float horizontalAlignment, float verticalAlignment) : +EvenOddBufferTextCell::EvenOddBufferTextCell(const KDFont * font, float horizontalAlignment, float verticalAlignment) : EvenOddCell(), - m_bufferTextView(size, horizontalAlignment, verticalAlignment) + m_bufferTextView(font, horizontalAlignment, verticalAlignment) { } diff --git a/escher/src/even_odd_editable_text_cell.cpp b/escher/src/even_odd_editable_text_cell.cpp index cf16822fc..f7bacbd43 100644 --- a/escher/src/even_odd_editable_text_cell.cpp +++ b/escher/src/even_odd_editable_text_cell.cpp @@ -2,10 +2,10 @@ #include #include -EvenOddEditableTextCell::EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : +EvenOddEditableTextCell::EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, const KDFont * font, float horizontalAlignment, float verticalAlignment, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : EvenOddCell(), Responder(parentResponder), - m_editableCell(this, delegate, draftTextBuffer, size, horizontalAlignment, verticalAlignment, KDColorBlack, KDColorWhite, topMargin, rightMargin, bottomMargin, leftMargin) + m_editableCell(this, delegate, draftTextBuffer, font, horizontalAlignment, verticalAlignment, KDColorBlack, KDColorWhite, topMargin, rightMargin, bottomMargin, leftMargin) { } diff --git a/escher/src/even_odd_message_text_cell.cpp b/escher/src/even_odd_message_text_cell.cpp index 38fee43e0..30031d08c 100644 --- a/escher/src/even_odd_message_text_cell.cpp +++ b/escher/src/even_odd_message_text_cell.cpp @@ -1,9 +1,9 @@ #include #include -EvenOddMessageTextCell::EvenOddMessageTextCell(KDText::FontSize size) : +EvenOddMessageTextCell::EvenOddMessageTextCell(const KDFont * font) : EvenOddCell(), - m_messageTextView(size, (I18n::Message)0, 0.5f, 0.5f) + m_messageTextView(font, (I18n::Message)0, 0.5f, 0.5f) { } diff --git a/escher/src/expression_field.cpp b/escher/src/expression_field.cpp index 66cc499a1..e4a1055d9 100644 --- a/escher/src/expression_field.cpp +++ b/escher/src/expression_field.cpp @@ -5,7 +5,7 @@ ExpressionField::ExpressionField(Responder * parentResponder, char * textBuffer, int textBufferLength, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate) : Responder(parentResponder), View(), - m_textField(parentResponder, textBuffer, textBuffer, textBufferLength, textFieldDelegate, false, KDText::FontSize::Large, 0.0f, 0.5f, KDColorBlack, KDColorWhite), + m_textField(parentResponder, textBuffer, textBuffer, textBufferLength, textFieldDelegate, false, KDFont::LargeFont, 0.0f, 0.5f, KDColorBlack, KDColorWhite), m_layoutField(parentResponder, layoutFieldDelegate), m_textBuffer(textBuffer), m_textBufferLength(textBufferLength) diff --git a/escher/src/expression_table_cell_with_pointer.cpp b/escher/src/expression_table_cell_with_pointer.cpp index 55aecaf3a..54dfaf133 100644 --- a/escher/src/expression_table_cell_with_pointer.cpp +++ b/escher/src/expression_table_cell_with_pointer.cpp @@ -4,10 +4,10 @@ ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(I18n::Message accessoryMessage, Layout layout) : ExpressionTableCell(layout), - m_accessoryView(KDText::FontSize::Small, accessoryMessage, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite) + m_accessoryView(KDFont::SmallFont, accessoryMessage, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite) { if (layout == Layout::Horizontal) { - m_accessoryView.setAlignment(1.0f, 0.5f); + m_accessoryView.setAlignment(1.0f, 0.5f); } } diff --git a/escher/src/image_view.cpp b/escher/src/image_view.cpp index 97405ba78..6c076f899 100644 --- a/escher/src/image_view.cpp +++ b/escher/src/image_view.cpp @@ -16,6 +16,9 @@ void ImageView::drawRect(KDContext * ctx, KDRect rect) const { assert(bounds().width() == m_image->width()); assert(bounds().height() == m_image->height()); ctx->fillRectWithPixels(bounds(), m_image->pixels(), nullptr); + + // Image is 55*56 pixels 3K pixels = 6K bytes + } void ImageView::setImage(const Image * image) { diff --git a/escher/src/message_table_cell.cpp b/escher/src/message_table_cell.cpp index 70d50ecb0..00d4343a9 100644 --- a/escher/src/message_table_cell.cpp +++ b/escher/src/message_table_cell.cpp @@ -2,9 +2,9 @@ #include #include -MessageTableCell::MessageTableCell(I18n::Message label, KDText::FontSize size, Layout layout) : +MessageTableCell::MessageTableCell(I18n::Message label, const KDFont * font, Layout layout) : TableCell(layout), - m_messageTextView(size, label, 0, 0.5, KDColorBlack, KDColorWhite) + m_messageTextView(font, label, 0, 0.5, KDColorBlack, KDColorWhite) { } @@ -28,7 +28,7 @@ void MessageTableCell::setTextColor(KDColor color) { m_messageTextView.setTextColor(color); } -void MessageTableCell::setMessageFontSize(KDText::FontSize fontSize) { - m_messageTextView.setFontSize(fontSize); +void MessageTableCell::setMessageFont(const KDFont * font) { + m_messageTextView.setFont(font); layoutSubviews(); } diff --git a/escher/src/message_table_cell_with_buffer.cpp b/escher/src/message_table_cell_with_buffer.cpp index 5d1540436..6a965e2f4 100644 --- a/escher/src/message_table_cell_with_buffer.cpp +++ b/escher/src/message_table_cell_with_buffer.cpp @@ -1,9 +1,9 @@ #include #include -MessageTableCellWithBuffer::MessageTableCellWithBuffer(I18n::Message message, KDText::FontSize fontSize, KDText::FontSize accessoryFontSize, KDColor accessoryTextColor) : - MessageTableCell(message, fontSize), - m_accessoryView(accessoryFontSize, 1.0f, 0.5f, accessoryTextColor) +MessageTableCellWithBuffer::MessageTableCellWithBuffer(I18n::Message message, const KDFont * font, const KDFont * accessoryFont, KDColor accessoryTextColor) : + MessageTableCell(message, font), + m_accessoryView(accessoryFont, 1.0f, 0.5f, accessoryTextColor) { } @@ -30,11 +30,3 @@ void MessageTableCellWithBuffer::setTextColor(KDColor color) { m_accessoryView.setTextColor(color); MessageTableCell::setTextColor(color); } - -void MessageTableCellWithBuffer::setAccessoryTextColor(KDColor color) { - m_accessoryView.setTextColor(color); -} - -void MessageTableCellWithBuffer::setAccessoryFontSize(KDText::FontSize fontSize) { - m_accessoryView.setFontSize(fontSize); -} diff --git a/escher/src/message_table_cell_with_chevron.cpp b/escher/src/message_table_cell_with_chevron.cpp index 2fd7a8f6d..0f80c8034 100644 --- a/escher/src/message_table_cell_with_chevron.cpp +++ b/escher/src/message_table_cell_with_chevron.cpp @@ -1,7 +1,7 @@ #include -MessageTableCellWithChevron::MessageTableCellWithChevron(I18n::Message message, KDText::FontSize size) : - MessageTableCell(message, size), +MessageTableCellWithChevron::MessageTableCellWithChevron(I18n::Message message, const KDFont * font) : + MessageTableCell(message, font), m_accessoryView() { } diff --git a/escher/src/message_table_cell_with_chevron_and_expression.cpp b/escher/src/message_table_cell_with_chevron_and_expression.cpp index f568fc4a3..a2288c05b 100644 --- a/escher/src/message_table_cell_with_chevron_and_expression.cpp +++ b/escher/src/message_table_cell_with_chevron_and_expression.cpp @@ -1,8 +1,8 @@ #include #include -MessageTableCellWithChevronAndExpression::MessageTableCellWithChevronAndExpression(I18n::Message message, KDText::FontSize size) : - MessageTableCellWithChevron(message, size), +MessageTableCellWithChevronAndExpression::MessageTableCellWithChevronAndExpression(I18n::Message message, const KDFont * font) : + MessageTableCellWithChevron(message, font), m_subtitleView(1.0f, 0.5f, Palette::GreyDark) { } diff --git a/escher/src/message_table_cell_with_chevron_and_message.cpp b/escher/src/message_table_cell_with_chevron_and_message.cpp index c42e4f223..ff4d8a952 100644 --- a/escher/src/message_table_cell_with_chevron_and_message.cpp +++ b/escher/src/message_table_cell_with_chevron_and_message.cpp @@ -1,9 +1,9 @@ #include #include -MessageTableCellWithChevronAndMessage::MessageTableCellWithChevronAndMessage(KDText::FontSize labelSize, KDText::FontSize contentSize) : - MessageTableCellWithChevron((I18n::Message)0, labelSize), - m_subtitleView(contentSize, (I18n::Message)0, 1.0f, 0.5f, Palette::GreyDark) +MessageTableCellWithChevronAndMessage::MessageTableCellWithChevronAndMessage(const KDFont * labelFont, const KDFont * contentFont) : + MessageTableCellWithChevron((I18n::Message)0, labelFont), + m_subtitleView(contentFont, (I18n::Message)0, 1.0f, 0.5f, Palette::GreyDark) { } diff --git a/escher/src/message_table_cell_with_editable_text.cpp b/escher/src/message_table_cell_with_editable_text.cpp index b6427e1af..764d70e8a 100644 --- a/escher/src/message_table_cell_with_editable_text.cpp +++ b/escher/src/message_table_cell_with_editable_text.cpp @@ -5,7 +5,7 @@ MessageTableCellWithEditableText::MessageTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, I18n::Message message) : Responder(parentResponder), MessageTableCell(message), - m_textField(this, m_textBody, draftTextBuffer, TextField::maxBufferSize(), textFieldDelegate, true, KDText::FontSize::Large, 1.0f, 0.5f) + m_textField(this, m_textBody, draftTextBuffer, TextField::maxBufferSize(), textFieldDelegate, true, KDFont::LargeFont, 1.0f, 0.5f) { m_textBody[0] = '\0'; } diff --git a/escher/src/message_table_cell_with_expression.cpp b/escher/src/message_table_cell_with_expression.cpp index 345a3e9f8..144fa5c81 100644 --- a/escher/src/message_table_cell_with_expression.cpp +++ b/escher/src/message_table_cell_with_expression.cpp @@ -1,8 +1,8 @@ #include #include -MessageTableCellWithExpression::MessageTableCellWithExpression(I18n::Message message, KDText::FontSize size) : - MessageTableCell(message, size), +MessageTableCellWithExpression::MessageTableCellWithExpression(I18n::Message message, const KDFont * font) : + MessageTableCell(message, font), m_subtitleView(1.0f, 0.5f, Palette::GreyDark) { } diff --git a/escher/src/message_table_cell_with_gauge.cpp b/escher/src/message_table_cell_with_gauge.cpp index 366d6ecd9..a7f28054c 100644 --- a/escher/src/message_table_cell_with_gauge.cpp +++ b/escher/src/message_table_cell_with_gauge.cpp @@ -1,8 +1,8 @@ #include #include -MessageTableCellWithGauge::MessageTableCellWithGauge(I18n::Message message, KDText::FontSize size) : - MessageTableCell(message, size), +MessageTableCellWithGauge::MessageTableCellWithGauge(I18n::Message message, const KDFont * font) : + MessageTableCell(message, font), m_accessoryView() { } diff --git a/escher/src/message_table_cell_with_message.cpp b/escher/src/message_table_cell_with_message.cpp index 8c207bb58..18cdc993c 100644 --- a/escher/src/message_table_cell_with_message.cpp +++ b/escher/src/message_table_cell_with_message.cpp @@ -3,8 +3,8 @@ #include MessageTableCellWithMessage::MessageTableCellWithMessage(I18n::Message message, Layout layout) : - MessageTableCell(message, KDText::FontSize::Small, layout), - m_accessoryView(KDText::FontSize::Small, (I18n::Message)0, 0.0f, 0.5f) + MessageTableCell(message, KDFont::SmallFont, layout), + m_accessoryView(KDFont::SmallFont, (I18n::Message)0, 0.0f, 0.5f) { if (layout != Layout::Vertical) { m_accessoryView.setAlignment(1.0f, 0.5f); diff --git a/escher/src/message_table_cell_with_switch.cpp b/escher/src/message_table_cell_with_switch.cpp index aa9312860..b972c7086 100644 --- a/escher/src/message_table_cell_with_switch.cpp +++ b/escher/src/message_table_cell_with_switch.cpp @@ -1,8 +1,8 @@ #include #include -MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message, KDText::FontSize size) : - MessageTableCell(message, size), +MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message, const KDFont * font) : + MessageTableCell(message, font), m_accessoryView() { } diff --git a/escher/src/message_text_view.cpp b/escher/src/message_text_view.cpp index 34bae3181..013defe6d 100644 --- a/escher/src/message_text_view.cpp +++ b/escher/src/message_text_view.cpp @@ -1,9 +1,9 @@ #include #include -MessageTextView::MessageTextView(KDText::FontSize size, I18n::Message message, float horizontalAlignment, float verticalAlignment, +MessageTextView::MessageTextView(const KDFont * font, I18n::Message message, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + TextView(font, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_message(message) { } @@ -24,5 +24,5 @@ void MessageTextView::setMessage(I18n::Message message) { } KDSize MessageTextView::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(text(), m_fontSize); + return m_font->stringSize(text()); } diff --git a/escher/src/pointer_text_view.cpp b/escher/src/pointer_text_view.cpp index a20412f82..892311ee5 100644 --- a/escher/src/pointer_text_view.cpp +++ b/escher/src/pointer_text_view.cpp @@ -1,9 +1,9 @@ #include #include -PointerTextView::PointerTextView(KDText::FontSize size, const char * text, float horizontalAlignment, float verticalAlignment, +PointerTextView::PointerTextView(const KDFont * font, const char * text, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + TextView(font, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_text(text) { } @@ -16,5 +16,5 @@ void PointerTextView::setText(const char * text) { } KDSize PointerTextView::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(text(), m_fontSize); + return m_font->stringSize(text()); } diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index bd667671d..97f1c783d 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -30,15 +30,16 @@ void StackView::setNamedController(ViewController * controller) { } void StackView::drawRect(KDContext * ctx, KDRect rect) const { + const KDFont * font = KDFont::SmallFont; KDCoordinate height = bounds().height(); KDCoordinate width = bounds().width(); ctx->fillRect(KDRect(0, 0, width, 1), m_separatorColor); ctx->fillRect(KDRect(0, 1, width, height-2), m_backgroundColor); ctx->fillRect(KDRect(0, height-1, width, 1), m_separatorColor); // Write title - KDSize textSize = KDText::stringSize(m_controller->title(), KDText::FontSize::Small); + KDSize textSize = font->stringSize(m_controller->title()); KDPoint origin((m_frame.width() - textSize.width())/2,(m_frame.height() - textSize.height())/2); - ctx->drawString(m_controller->title(), origin, KDText::FontSize::Small, m_textColor, m_backgroundColor); + ctx->drawString(m_controller->title(), origin, font, m_textColor, m_backgroundColor); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/tab_view_cell.cpp b/escher/src/tab_view_cell.cpp index 43be0c1c8..6b7167728 100644 --- a/escher/src/tab_view_cell.cpp +++ b/escher/src/tab_view_cell.cpp @@ -28,7 +28,7 @@ void TabViewCell::setSelected(bool selected) { } KDSize TabViewCell::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(m_controller->title(), KDText::FontSize::Small); + return KDFont::SmallFont->stringSize(m_controller->title()); } void TabViewCell::drawRect(KDContext * ctx, KDRect rect) const { @@ -47,9 +47,9 @@ void TabViewCell::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(0, 0, width, height), background); } // Write title - KDSize textSize = KDText::stringSize(m_controller->title(), KDText::FontSize::Small); + KDSize textSize = KDFont::SmallFont->stringSize(m_controller->title()); KDPoint origin((m_frame.width() - textSize.width())/2, (m_frame.height() - textSize.height())/2); - ctx->drawString(m_controller->title(), origin, KDText::FontSize::Small, text, background); + ctx->drawString(m_controller->title(), origin, KDFont::SmallFont, text, background); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/text_area.cpp b/escher/src/text_area.cpp index a21f03252..9a5c17b7a 100644 --- a/escher/src/text_area.cpp +++ b/escher/src/text_area.cpp @@ -12,7 +12,7 @@ static inline size_t min(size_t a, size_t b) { /* TextArea */ -TextArea::TextArea(Responder * parentResponder, View * contentView, KDText::FontSize fontSize) : +TextArea::TextArea(Responder * parentResponder, View * contentView, const KDFont * font) : TextInput(parentResponder, contentView), m_delegate(nullptr) { @@ -273,17 +273,17 @@ void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const { // TODO: We're clearing areas we'll draw text over. It's not needed. clearRect(ctx, rect); - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); // We want to draw even partially visible characters. So we need to round // down for the top left corner and up for the bottom right one. Text::Position topLeft( - rect.x()/charSize.width(), - rect.y()/charSize.height() + rect.x()/glyphSize.width(), + rect.y()/glyphSize.height() ); Text::Position bottomRight( - rect.right()/charSize.width() + 1, - rect.bottom()/charSize.height() + 1 + rect.right()/glyphSize.width() + 1, + rect.bottom()/glyphSize.height() + 1 ); int y = 0; @@ -297,11 +297,11 @@ void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const { } void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, size_t length, KDColor textColor, KDColor backgroundColor) const { - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); ctx->drawString( text, - KDPoint(column*charSize.width(), line*charSize.height()), - m_fontSize, + KDPoint(column*glyphSize.width(), line*glyphSize.height()), + m_font, textColor, backgroundColor, length @@ -309,13 +309,13 @@ void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, } KDSize TextArea::ContentView::minimalSizeForOptimalDisplay() const { - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); Text::Position span = m_text.span(); return KDSize( /* We take into account the space required to draw a cursor at the end of - * line by adding charSize.width() to the width. */ - charSize.width() * (span.column()+1), - charSize.height() * span.line() + * line by adding glyphSize.width() to the width. */ + glyphSize.width() * (span.column()+1), + glyphSize.height() * span.line() ); } @@ -376,13 +376,13 @@ bool TextArea::ContentView::removeStartOfLine() { } KDRect TextArea::ContentView::characterFrameAtIndex(size_t index) const { - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); Text::Position p = m_text.positionAtIndex(index); return KDRect( - p.column() * charSize.width(), - p.line() * charSize.height(), - charSize.width(), - charSize.height() + p.column() * glyphSize.width(), + p.line() * glyphSize.height(), + glyphSize.width(), + glyphSize.height() ); } diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index caf4c6b08..19cd19ca5 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -6,8 +6,8 @@ /* TextField::ContentView */ -TextField::ContentView::ContentView(char * textBuffer, char * draftTextBuffer, size_t textBufferSize, KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextInput::ContentView(size), +TextField::ContentView::ContentView(char * textBuffer, char * draftTextBuffer, size_t textBufferSize, const KDFont * font, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : + TextInput::ContentView(font), m_isEditing(false), m_textBuffer(textBuffer), m_draftTextBuffer(draftTextBuffer), @@ -41,7 +41,7 @@ void TextField::ContentView::drawRect(KDContext * ctx, KDRect rect) const { backgroundColor = KDColorWhite; } ctx->fillRect(bounds(), backgroundColor); - ctx->drawString(text(), characterFrameAtIndex(0).origin(), m_fontSize, m_textColor, backgroundColor); + ctx->drawString(text(), characterFrameAtIndex(0).origin(), m_font, m_textColor, backgroundColor); } const char * TextField::ContentView::text() const { @@ -116,11 +116,11 @@ bool TextField::ContentView::insertTextAtLocation(const char * text, int locatio } KDSize TextField::ContentView::minimalSizeForOptimalDisplay() const { - KDSize charSize = KDText::charSize(m_fontSize); + KDSize glyphSize = m_font->glyphSize(); if (m_isEditing) { - return KDSize(charSize.width()*strlen(text())+m_cursorView.minimalSizeForOptimalDisplay().width(), charSize.height()); + return KDSize(glyphSize.width()*strlen(text())+m_cursorView.minimalSizeForOptimalDisplay().width(), glyphSize.height()); } - return KDSize(charSize.width()*strlen(text()), charSize.height()); + return KDSize(glyphSize.width()*strlen(text()), glyphSize.height()); } bool TextField::ContentView::removeChar() { @@ -163,19 +163,19 @@ void TextField::ContentView::layoutSubviews() { } KDRect TextField::ContentView::characterFrameAtIndex(size_t index) const { - KDSize charSize = KDText::charSize(m_fontSize); - KDSize textSize = KDText::stringSize(text(), m_fontSize); + KDSize glyphSize = m_font->glyphSize(); + KDSize textSize = m_font->stringSize(text()); KDCoordinate cursorWidth = m_cursorView.minimalSizeForOptimalDisplay().width(); - return KDRect(m_horizontalAlignment*(m_frame.width() - textSize.width()-cursorWidth)+ index * charSize.width(), m_verticalAlignment*(m_frame.height() - charSize.height()), charSize); + return KDRect(m_horizontalAlignment*(m_frame.width() - textSize.width()-cursorWidth)+ index * glyphSize.width(), m_verticalAlignment*(m_frame.height() - glyphSize.height()), glyphSize); } /* TextField */ TextField::TextField(Responder * parentResponder, char * textBuffer, char * draftTextBuffer, - size_t textBufferSize, TextFieldDelegate * delegate, bool hasTwoBuffers, KDText::FontSize size, + size_t textBufferSize, TextFieldDelegate * delegate, bool hasTwoBuffers, const KDFont * font, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : TextInput(parentResponder, &m_contentView), - m_contentView(textBuffer, draftTextBuffer, textBufferSize, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + m_contentView(textBuffer, draftTextBuffer, textBufferSize, font, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_hasTwoBuffers(hasTwoBuffers), m_delegate(delegate) { diff --git a/escher/src/text_input.cpp b/escher/src/text_input.cpp index b0db0c3c0..21ec672da 100644 --- a/escher/src/text_input.cpp +++ b/escher/src/text_input.cpp @@ -3,10 +3,10 @@ /* TextInput::ContentView */ -TextInput::ContentView::ContentView(KDText::FontSize size) : +TextInput::ContentView::ContentView(const KDFont * font) : View(), m_cursorView(), - m_fontSize(size), + m_font(font), m_cursorIndex(0) { } @@ -18,8 +18,8 @@ void TextInput::ContentView::setCursorLocation(int location) { layoutSubviews(); } -void TextInput::ContentView::setFontSize(KDText::FontSize size) { - m_fontSize = size; +void TextInput::ContentView::setFont(const KDFont * font) { + m_font = font; markRectAsDirty(bounds()); } diff --git a/escher/src/text_view.cpp b/escher/src/text_view.cpp index 824d161e1..610816b33 100644 --- a/escher/src/text_view.cpp +++ b/escher/src/text_view.cpp @@ -1,9 +1,9 @@ #include -TextView::TextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment, +TextView::TextView(const KDFont * font, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : View(), - m_fontSize(size), + m_font(font), m_horizontalAlignment(horizontalAlignment), m_verticalAlignment(verticalAlignment), m_textColor(textColor), @@ -27,24 +27,24 @@ void TextView::setAlignment(float horizontalAlignment, float verticalAlignment) markRectAsDirty(bounds()); } -void TextView::setFontSize(KDText::FontSize fontSize) { - m_fontSize = fontSize; +void TextView::setFont(const KDFont * font) { + m_font = font; markRectAsDirty(bounds()); } KDSize TextView::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(text(), m_fontSize); + return m_font->stringSize(text()); } void TextView::drawRect(KDContext * ctx, KDRect rect) const { if (text() == nullptr) { return; } - KDSize textSize = KDText::stringSize(text(), m_fontSize); + KDSize textSize = m_font->stringSize(text()); KDPoint origin(m_horizontalAlignment*(m_frame.width() - textSize.width()), m_verticalAlignment*(m_frame.height() - textSize.height())); ctx->fillRect(bounds(), m_backgroundColor); - ctx->drawString(text(), origin, m_fontSize, m_textColor, m_backgroundColor); + ctx->drawString(text(), origin, m_font, m_textColor, m_backgroundColor); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/warning_controller.cpp b/escher/src/warning_controller.cpp index 5d9936d19..b238e2c0f 100644 --- a/escher/src/warning_controller.cpp +++ b/escher/src/warning_controller.cpp @@ -3,7 +3,7 @@ WarningController::ContentView::ContentView() : SolidColorView(KDColorBlack), - m_textView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorWhite, KDColorBlack) + m_textView(KDFont::SmallFont, (I18n::Message)0, 0.5f, 0.5f, KDColorWhite, KDColorBlack) { } diff --git a/kandinsky/fonts/rasterizer.c b/kandinsky/fonts/rasterizer.c index 84f7f7a2e..f9f73bf8a 100644 --- a/kandinsky/fonts/rasterizer.c +++ b/kandinsky/fonts/rasterizer.c @@ -196,7 +196,7 @@ int main(int argc, char * argv[]) { #if NEW_FORMAT fprintf(sourceFile, "/* This file is auto-generated by the rasterizer */\n\n"); - fprintf(sourceFile, "#include \"font.h\"\n\n"); + fprintf(sourceFile, "#include \n\n"); fprintf(sourceFile, "static constexpr KDCoordinate glyphWidth = %d;\n\n", glyph_width); fprintf(sourceFile, "static constexpr KDCoordinate glyphHeight = %d;\n\n", glyph_height); @@ -264,8 +264,7 @@ int main(int argc, char * argv[]) { free(glyphData); free(uncompressedGlyphBuffer); - fprintf(sourceFile, "constexpr KDFont font(glyphWidth, glyphHeight, glyphDataOffset, glyphData);\n\n"); - fprintf(sourceFile, "const KDFont * KDFont::%s = &font;\n", font_name); + fprintf(sourceFile, "const KDFont KDFont::private%s(glyphWidth, glyphHeight, glyphDataOffset, glyphData);\n", font_name); #else diff --git a/kandinsky/include/kandinsky.h b/kandinsky/include/kandinsky.h index cd6b21b5f..bc3d951c7 100644 --- a/kandinsky/include/kandinsky.h +++ b/kandinsky/include/kandinsky.h @@ -4,12 +4,12 @@ #include #include #include +#include #include #include #include #include #include #include -#include #endif diff --git a/kandinsky/include/kandinsky/context.h b/kandinsky/include/kandinsky/context.h index ae44bc67d..bde8281d3 100644 --- a/kandinsky/include/kandinsky/context.h +++ b/kandinsky/include/kandinsky/context.h @@ -3,7 +3,7 @@ #include #include -#include +#include class KDContext { public: @@ -15,8 +15,7 @@ public: KDColor getPixel(KDPoint p); // Text - KDPoint drawString(const char * text, KDPoint p, KDText::FontSize size = KDText::FontSize::Large, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1); - KDPoint blendString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor = KDColorBlack); + KDPoint drawString(const char * text, KDPoint p, const KDFont * font = KDFont::LargeFont, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1); // Line. Not anti-aliased. void drawLine(KDPoint p1, KDPoint p2, KDColor c); @@ -33,8 +32,6 @@ protected: virtual void pullRect(KDRect rect, KDColor * pixels) = 0; private: KDRect absoluteFillRect(KDRect rect); - KDPoint writeString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, int maxLength, bool transparentBackground); - void writeChar(char character, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, bool transparentBackground); KDPoint m_origin; KDRect m_clippingRect; }; diff --git a/kandinsky/src/font.h b/kandinsky/include/kandinsky/font.h similarity index 69% rename from kandinsky/src/font.h rename to kandinsky/include/kandinsky/font.h index c0d5d6a02..caf9502b5 100644 --- a/kandinsky/src/font.h +++ b/kandinsky/include/kandinsky/font.h @@ -2,26 +2,30 @@ #define KANDINSKY_FONT_H #include +#include #include #include "palette.h" class KDFont { private: static constexpr int k_bitsPerPixel = 4; + static const KDFont privateLargeFont; + static const KDFont privateSmallFont; public: - static const KDFont * LargeFont; - static const KDFont * SmallFont; + static constexpr const KDFont * LargeFont = &privateLargeFont; + static constexpr const KDFont * SmallFont = &privateSmallFont; + + KDSize stringSize(const char * text) const; using RenderPalette = KDPalette<(1<; - void fetchGlyphForChar(char c, const RenderPalette & renderPalette, KDColor * pixelBuffer) const; + void fetchGlyphForChar(char c, const RenderPalette * renderPalette, KDColor * pixelBuffer) const; RenderPalette renderPalette(KDColor textColor, KDColor backgroundColor) const { return RenderPalette::Gradient(textColor, backgroundColor); } - KDCoordinate glyphWidth() const { return m_glyphWidth; } - KDCoordinate glyphHeight() const { return m_glyphHeight; } + KDSize glyphSize() const { return m_glyphSize; } constexpr KDFont(KDCoordinate glyphWidth, KDCoordinate glyphHeight, const uint16_t * glyphDataOffset, const uint8_t * data) : - m_glyphWidth(glyphWidth), m_glyphHeight(glyphHeight), m_glyphDataOffset(glyphDataOffset), m_data(data) { } + m_glyphSize(glyphWidth, glyphHeight), m_glyphDataOffset(glyphDataOffset), m_data(data) { } private: void fetchGreyscaleGlyphForChar(char c, uint8_t * greyscaleBuffer) const; @@ -37,8 +41,7 @@ private: // FIXME: 0x20 is a magic value... } - KDCoordinate m_glyphWidth; - KDCoordinate m_glyphHeight; + KDSize m_glyphSize; const uint16_t * m_glyphDataOffset; const uint8_t * m_data; }; diff --git a/kandinsky/src/palette.h b/kandinsky/include/kandinsky/palette.h similarity index 100% rename from kandinsky/src/palette.h rename to kandinsky/include/kandinsky/palette.h diff --git a/kandinsky/src/context_text.cpp b/kandinsky/src/context_text.cpp index 42e545c9a..4d3660de1 100644 --- a/kandinsky/src/context_text.cpp +++ b/kandinsky/src/context_text.cpp @@ -1,96 +1,33 @@ -#include -#include -#include "small_font.h" -#include "large_font.h" -#include "font.h" #include +#include +#include constexpr int maxGlyphPixelCount = 180; +constexpr static int k_tabCharacterWidth = 4; -KDPoint KDContext::drawString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, int maxLength) { -#define NEW_VERSION 1 -#if NEW_VERSION - const KDFont * font = KDFont::LargeFont; +KDPoint KDContext::drawString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxLength) { + + KDPoint position = p; + KDSize glyphSize = font->glyphSize(); KDFont::RenderPalette palette = font->renderPalette(textColor, backgroundColor); - assert(maxGlyphPixelCount >= font->glyphWidth() * font->glyphHeight()); + KDColor glyph[maxGlyphPixelCount]; - const char * c = text; - while(*c != 0) { - KDColor glyph[maxGlyphPixelCount]; - font->fetchGlyphForChar(*c, palette, glyph); - - KDRect absoluteRect = absoluteFillRect(KDRect(p, font->glyphWidth(), font->glyphHeight())); - pushRect(absoluteRect, glyph); - p = p.translatedBy(KDPoint(font->glyphWidth(), 0)); - - c++; - } - - return KDPointZero; -#else - return writeString(text, p, size, textColor, backgroundColor, maxLength, false); -#endif -} - -#if 0 - -KDPoint KDContext::blendString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor) { - return writeString(text, p, size, textColor, KDColorWhite, -1, true); -} - -KDPoint KDContext::writeString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, int maxLength, bool transparentBackground) { - KDPoint position = p; - int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH; - int characterHeight = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_HEIGHT: BITMAP_SmallFont_CHARACTER_HEIGHT; - KDPoint characterSize(characterWidth, 0); - - const char * end = text+maxLength; + const char * end = text + maxLength; while(*text != 0 && text != end) { - writeChar(*text, position, size, textColor, backgroundColor, transparentBackground); if (*text == '\n') { - position = KDPoint(0, position.y()+characterHeight); + position = KDPoint(0, position.y() + glyphSize.height()); } else if (*text == '\t') { - position = position.translatedBy(KDPoint(KDText::k_tabCharacterWidth*characterWidth, 0)); + position = position.translatedBy(KDPoint(k_tabCharacterWidth * glyphSize.width(), 0)); } else { - position = position.translatedBy(characterSize); + // Fetch and draw glyph for current char + font->fetchGlyphForChar(*text, &palette, glyph); + KDRect absoluteRect = absoluteFillRect(KDRect(position, glyphSize.width(), glyphSize.height())); + pushRect(absoluteRect, glyph); + + position = position.translatedBy(KDPoint(glyphSize.width(), 0)); } text++; } return position; } - -void KDContext::writeChar(char character, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, bool transparentBackground) { - if (character == '\n' || character == '\t') { - return; - } - char firstCharacter = size == KDText::FontSize::Large ? BITMAP_LargeFont_FIRST_CHARACTER : BITMAP_SmallFont_FIRST_CHARACTER; - int characterHeight = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_HEIGHT : BITMAP_SmallFont_CHARACTER_HEIGHT; - int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH; - - KDColor * characterBuffer = size == KDText::FontSize::Large ? largeCharacterBuffer : smallCharacterBuffer; - - KDRect absoluteRect = absoluteFillRect(KDRect(p, characterWidth, characterHeight)); - if (transparentBackground) { - pullRect(absoluteRect, characterBuffer); - } - KDCoordinate startingI = m_clippingRect.x() - p.translatedBy(m_origin).x(); - KDCoordinate startingJ = m_clippingRect.y() - p.translatedBy(m_origin).y(); - startingI = startingI < 0 ? 0 : startingI; - startingJ = startingJ < 0 ? 0 : startingJ; - - for (KDCoordinate j=0; j +#include #include "external/lz4/lz4.h" +constexpr static int k_tabCharacterWidth = 4; + +KDSize KDFont::stringSize(const char * text) const { + if (text == nullptr) { + return KDSizeZero; + } + KDSize stringSize = KDSize(0, m_glyphSize.height()); + while (*text != 0) { + KDSize cSize = KDSize(m_glyphSize.width(), 0); + if (*text == '\t') { + cSize = KDSize(k_tabCharacterWidth*m_glyphSize.width(), 0); + } + if (*text == '\n') { + cSize = KDSize(0, m_glyphSize.height()); + } + stringSize = KDSize(stringSize.width()+cSize.width(), stringSize.height()+cSize.height()); + text++; + } + return stringSize; +} + void KDFont::fetchGreyscaleGlyphForChar(char c, uint8_t * greyscaleBuffer) const { //TODO: If debug, use LZ4_decompress_safe, otherwise LZ4_decompress_fast int resultSize = LZ4_decompress_safe( reinterpret_cast(compressedGlyphData(c)), reinterpret_cast(greyscaleBuffer), compressedGlyphDataSize(c), - m_glyphWidth * m_glyphHeight * k_bitsPerPixel/8 + m_glyphSize.width() * m_glyphSize.height() * k_bitsPerPixel/8 ); - assert(resultSize == m_glyphWidth * m_glyphHeight * k_bitsPerPixel/8); + assert(resultSize == m_glyphSize.width() * m_glyphSize.height() * k_bitsPerPixel/8); } -void KDFont::fetchGlyphForChar(char c, const KDFont::RenderPalette & renderPalette, KDColor * pixelBuffer) const { +void KDFont::fetchGlyphForChar(char c, const KDFont::RenderPalette * renderPalette, KDColor * pixelBuffer) const { /* Since a greyscale value is smaller than a color value (see assertion), we * can store the temporary greyscale values in the output pixel buffer. * What's great is that now, if we fill the pixel buffer right-to-left with @@ -25,7 +46,7 @@ void KDFont::fetchGlyphForChar(char c, const KDFont::RenderPalette & renderPalet fetchGreyscaleGlyphForChar(c, greyscaleBuffer); uint8_t mask = (0xFF >> (8-k_bitsPerPixel)); - int pixelIndex = m_glyphWidth * m_glyphHeight - 1; // Let's start at the final pixel + int pixelIndex = m_glyphSize.width() * m_glyphSize.height() - 1; // Let's start at the final pixel int greyscaleByteIndex = pixelIndex * k_bitsPerPixel / 8; while (pixelIndex >= 0) { assert(greyscaleByteIndex == pixelIndex * k_bitsPerPixel / 8); @@ -34,25 +55,7 @@ void KDFont::fetchGlyphForChar(char c, const KDFont::RenderPalette & renderPalet uint8_t greyscale = greyscaleByte & mask; greyscaleByte = greyscaleByte >> k_bitsPerPixel; assert(pixelIndex >= 0); - pixelBuffer[pixelIndex--] = renderPalette.colorAtIndex(greyscale); + pixelBuffer[pixelIndex--] = renderPalette->colorAtIndex(greyscale); } } } -/* - -constexpr int glyphPixelCount = 12; - -void drawString(const char * text, KDColor textColor, KDColor backgroundColor) { - const KDFont * font = KDFont::LargeFont; - KDFont::RenderPalette palette = font->renderPalette(textColor, backgroundColor); - - assert(glyphPixelCount >= font->glyphWidth() * font->glyphHeight()); - - char c; - do { - char c = text[0]; - KDColor glyph[glyphPixelCount]; - font->fetchGlyphForChar(c, palette, glyph); - } while (c != 0); -} -*/ diff --git a/poincare/include/poincare/char_layout.h b/poincare/include/poincare/char_layout.h index a258c6709..fab2cb0dd 100644 --- a/poincare/include/poincare/char_layout.h +++ b/poincare/include/poincare/char_layout.h @@ -9,16 +9,16 @@ namespace Poincare { class CharLayoutNode : public LayoutNode { public: - CharLayoutNode(char c = Ion::Charset::Empty, KDText::FontSize fontSize = KDText::FontSize::Large) : + CharLayoutNode(char c = Ion::Charset::Empty, const KDFont * font = KDFont::LargeFont) : LayoutNode(), m_char(c), - m_fontSize(fontSize) + m_font(font) {} // CharLayout virtual void setChar(char c) { m_char = c; } - KDText::FontSize fontSize() const { return m_fontSize; } - void setFontSize(KDText::FontSize fontSize) { m_fontSize = fontSize; } + const KDFont * font() const { return m_font; } + void setFont(const KDFont * font) { m_font = font; } // LayoutNode void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override; @@ -50,13 +50,13 @@ protected: private: void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; char m_char; - KDText::FontSize m_fontSize; + const KDFont * m_font; }; class CharLayout : public Layout { public: - CharLayout(char c, KDText::FontSize fontSize = KDText::FontSize::Large); - KDText::FontSize fontSize() const { return const_cast(this)->node()->fontSize(); } + CharLayout(char c, const KDFont * font = KDFont::LargeFont); + const KDFont * font() const { return const_cast(this)->node()->font(); } private: using Layout::node; CharLayoutNode * node() { return static_cast(Layout::node());} diff --git a/poincare/include/poincare/empty_layout.h b/poincare/include/poincare/empty_layout.h index ebe705dbe..091e322f1 100644 --- a/poincare/include/poincare/empty_layout.h +++ b/poincare/include/poincare/empty_layout.h @@ -13,11 +13,11 @@ public: Grey }; - EmptyLayoutNode(Color color = Color::Yellow, bool visible = true, KDText::FontSize fontSize = KDText::FontSize::Large, bool margins = true) : + EmptyLayoutNode(Color color = Color::Yellow, bool visible = true, const KDFont * font = KDFont::LargeFont, bool margins = true) : LayoutNode(), m_isVisible(visible), m_color(color), - m_fontSize(fontSize), + m_font(font), m_margins(margins) {} @@ -27,7 +27,7 @@ public: bool isVisible() const { return m_isVisible; } void setVisible(bool visible) { m_isVisible = visible; } void setMargins(bool margins) { m_margins = margins; } - void setFontSize(KDText::FontSize fontSize) { m_fontSize = fontSize; } + void setFont(const KDFont * font) { m_font = font; } // LayoutNode void deleteBeforeCursor(LayoutCursor * cursor) override; @@ -58,8 +58,8 @@ private: constexpr static KDCoordinate k_marginWidth = 1; constexpr static KDCoordinate k_marginHeight = 3; constexpr static KDCoordinate k_lineThickness = 1; - KDCoordinate height() const { return KDText::charSize(m_fontSize).height() - 2*k_marginHeight; } - KDCoordinate width() const { return KDText::charSize(m_fontSize).width() - 2*k_marginWidth; } + KDCoordinate height() const { return m_font->glyphSize().height() - 2 * k_marginHeight; } + KDCoordinate width() const { return m_font->glyphSize().width() - 2 * k_marginWidth; } // LayoutNode void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override; @@ -68,14 +68,14 @@ private: bool m_isVisible; Color m_color; - KDText::FontSize m_fontSize; + const KDFont * m_font; bool m_margins; }; class EmptyLayout : public Layout { public: EmptyLayout(const EmptyLayoutNode * n); - EmptyLayout(EmptyLayoutNode::Color color = EmptyLayoutNode::Color::Yellow, bool visible = true, KDText::FontSize fontSize = KDText::FontSize::Large, bool margins = true); + EmptyLayout(EmptyLayoutNode::Color color = EmptyLayoutNode::Color::Yellow, bool visible = true, const KDFont * font = KDFont::LargeFont, bool margins = true); void setVisible(bool visible) { node()->setVisible(visible); } diff --git a/poincare/include/poincare/integral_layout.h b/poincare/include/poincare/integral_layout.h index 3c00cf228..7e8aeaa2d 100644 --- a/poincare/include/poincare/integral_layout.h +++ b/poincare/include/poincare/integral_layout.h @@ -39,7 +39,7 @@ protected: KDCoordinate computeBaseline() override; KDPoint positionOfChild(LayoutNode * child) override; private: - constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Large; + constexpr static const KDFont * k_font = KDFont::LargeFont; constexpr static KDCoordinate k_boundHeightMargin = 8; constexpr static KDCoordinate k_boundWidthMargin = 5; constexpr static KDCoordinate k_integrandWidthMargin = 2; diff --git a/poincare/include/poincare/layout_helper.h b/poincare/include/poincare/layout_helper.h index e7c9fd2da..b52eec8a9 100644 --- a/poincare/include/poincare/layout_helper.h +++ b/poincare/include/poincare/layout_helper.h @@ -14,7 +14,7 @@ namespace LayoutHelper { /* Create special layouts */ Layout Parentheses(Layout layout, bool cloneLayout); - HorizontalLayout String(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large); + HorizontalLayout String(const char * buffer, int bufferSize, const KDFont * font = KDFont::LargeFont); Layout Logarithm(Layout argument, Layout index); }; diff --git a/poincare/include/poincare/sequence_layout.h b/poincare/include/poincare/sequence_layout.h index 61855690b..c49e8a264 100644 --- a/poincare/include/poincare/sequence_layout.h +++ b/poincare/include/poincare/sequence_layout.h @@ -28,7 +28,7 @@ public: protected: constexpr static KDCoordinate k_boundHeightMargin = 2; constexpr static KDCoordinate k_argumentWidthMargin = 2; - constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Large; + constexpr static const KDFont * k_font = KDFont::LargeFont; constexpr static char k_nEquals[] = {'n', '=', 0}; KDSize lowerBoundSizeWithNEquals(); diff --git a/poincare/src/char_layout.cpp b/poincare/src/char_layout.cpp index 1a80467db..c4813bbae 100644 --- a/poincare/src/char_layout.cpp +++ b/poincare/src/char_layout.cpp @@ -49,23 +49,23 @@ bool CharLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft // Sizing and positioning KDSize CharLayoutNode::computeSize() { - return KDText::charSize(m_fontSize); + return m_font->glyphSize(); } KDCoordinate CharLayoutNode::computeBaseline() { - return (KDText::charSize(m_fontSize).height()+1)/2; //TODO +1 ? + return (m_font->glyphSize().height()+1)/2; //TODO +1 ? } void CharLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { char string[2] = {m_char, 0}; - ctx->drawString(string, p, m_fontSize, expressionColor, backgroundColor); + ctx->drawString(string, p, m_font, expressionColor, backgroundColor); } -CharLayout::CharLayout(char c, KDText::FontSize fontSize) : +CharLayout::CharLayout(char c, const KDFont * font) : Layout(TreePool::sharedPool()->createTreeNode()) { node()->setChar(c); - node()->setFontSize(fontSize); + node()->setFont(font); } } diff --git a/poincare/src/empty_layout.cpp b/poincare/src/empty_layout.cpp index 924a26a24..00f0b642b 100644 --- a/poincare/src/empty_layout.cpp +++ b/poincare/src/empty_layout.cpp @@ -95,12 +95,12 @@ void EmptyLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor } EmptyLayout::EmptyLayout(const EmptyLayoutNode * n) : Layout(n) {} -EmptyLayout::EmptyLayout(EmptyLayoutNode::Color color, bool visible, KDText::FontSize fontSize, bool margins) : +EmptyLayout::EmptyLayout(EmptyLayoutNode::Color color, bool visible, const KDFont * font, bool margins) : Layout(TreePool::sharedPool()->createTreeNode()) { node()->setColor(color); node()->setVisible(visible); - node()->setFontSize(fontSize); + node()->setFont(font); node()->setMargins(margins); } diff --git a/poincare/src/integral_layout.cpp b/poincare/src/integral_layout.cpp index c9dbebfd7..4d5980d80 100644 --- a/poincare/src/integral_layout.cpp +++ b/poincare/src/integral_layout.cpp @@ -176,7 +176,7 @@ int IntegralLayoutNode::serialize(char * buffer, int bufferSize, Preferences::Pr } KDSize IntegralLayoutNode::computeSize() { - KDSize dxSize = KDText::stringSize("dx", k_fontSize); + KDSize dxSize = k_font->stringSize("dx"); KDSize integrandSize = integrandLayout()->layoutSize(); KDSize lowerBoundSize = lowerBoundLayout()->layoutSize(); KDSize upperBoundSize = upperBoundLayout()->layoutSize(); @@ -228,7 +228,7 @@ void IntegralLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionCo // Render "dx". KDPoint dxPosition = p.translatedBy(positionOfChild(integrandLayout())).translatedBy(KDPoint(integrandSize.width(), 0)); - ctx->drawString("dx", dxPosition, k_fontSize, expressionColor, backgroundColor); + ctx->drawString("dx", dxPosition, k_font, expressionColor, backgroundColor); } } diff --git a/poincare/src/layout_helper.cpp b/poincare/src/layout_helper.cpp index 4ea3d4f07..0e86d7964 100644 --- a/poincare/src/layout_helper.cpp +++ b/poincare/src/layout_helper.cpp @@ -53,11 +53,11 @@ Layout LayoutHelper::Parentheses(Layout layout, bool cloneLayout) { return result; } -HorizontalLayout LayoutHelper::String(const char * buffer, int bufferSize, KDText::FontSize fontSize) { +HorizontalLayout LayoutHelper::String(const char * buffer, int bufferSize, const KDFont * font) { assert(bufferSize > 0); HorizontalLayout resultLayout; for (int i = 0; i < bufferSize; i++) { - resultLayout.addChildAtIndex(CharLayout(buffer[i], fontSize), i, i, nullptr); + resultLayout.addChildAtIndex(CharLayout(buffer[i], font), i, i, nullptr); } return resultLayout; } diff --git a/poincare/src/sequence_layout.cpp b/poincare/src/sequence_layout.cpp index 314aba4dd..b7c37f051 100644 --- a/poincare/src/sequence_layout.cpp +++ b/poincare/src/sequence_layout.cpp @@ -138,7 +138,7 @@ KDCoordinate SequenceLayoutNode::computeBaseline() { KDPoint SequenceLayoutNode::positionOfChild(LayoutNode * l) { KDSize nEqualslowerBoundSize = lowerBoundSizeWithNEquals(); - KDSize nEqualsSize = KDText::stringSize(k_nEquals, k_fontSize); + KDSize nEqualsSize = k_font->stringSize(k_nEquals); KDSize upperBoundSize = upperBoundLayout()->layoutSize(); KDCoordinate x = 0; KDCoordinate y = 0; @@ -202,8 +202,8 @@ int SequenceLayoutNode::writeDerivedClassInBuffer(const char * operatorName, cha void SequenceLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { // Render the "n=" - KDPoint nEqualsPosition = positionOfChild(lowerBoundLayout()).translatedBy(KDPoint(-KDText::stringSize(k_nEquals, k_fontSize).width(), 0)); - ctx->drawString(k_nEquals, p.translatedBy(nEqualsPosition), k_fontSize, expressionColor, backgroundColor); + KDPoint nEqualsPosition = positionOfChild(lowerBoundLayout()).translatedBy(KDPoint(-k_font->stringSize(k_nEquals).width(), 0)); + ctx->drawString(k_nEquals, p.translatedBy(nEqualsPosition), k_font, expressionColor, backgroundColor); // Render the parentheses KDCoordinate argumentWithParenthesesHeight = ParenthesisLayoutNode::HeightGivenChildHeight(argumentLayout()->layoutSize().height()); @@ -222,7 +222,7 @@ void SequenceLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionCo KDSize SequenceLayoutNode::lowerBoundSizeWithNEquals() { KDSize lowerBoundSize = lowerBoundLayout()->layoutSize(); - KDSize nEqualsSize = KDText::stringSize(k_nEquals, k_fontSize); + KDSize nEqualsSize = k_font->stringSize(k_nEquals); return KDSize( nEqualsSize.width() + lowerBoundSize.width(), max(nEqualsSize.height(), lowerBoundSize.height()));