diff --git a/apps/graph/graph/graph_controller_helper.cpp b/apps/graph/graph/graph_controller_helper.cpp index a25379c02..db5e4a147 100644 --- a/apps/graph/graph/graph_controller_helper.cpp +++ b/apps/graph/graph/graph_controller_helper.cpp @@ -1,6 +1,7 @@ #include "graph_controller_helper.h" #include "../../shared/function_banner_delegate.h" #include "../app.h" +#include #include "../../shared/poincare_helpers.h" #include @@ -34,9 +35,8 @@ void GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(Shar char buffer[bufferSize]; const char * space = " "; int numberOfChar = function->derivativeNameWithArgument(buffer, bufferSize); - const char * legend = "="; assert(numberOfChar <= bufferSize); - numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); + numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); double y = function->approximateDerivative(cursor->x(), App::app()->localContext()); numberOfChar += PoincareHelpers::ConvertFloatToText(y, buffer + numberOfChar, bufferSize-numberOfChar, Preferences::ShortNumberOfSignificantDigits); assert(numberOfChar <= bufferSize); diff --git a/apps/graph/graph/intersection_graph_controller.cpp b/apps/graph/graph/intersection_graph_controller.cpp index f608d709e..2354d6446 100644 --- a/apps/graph/graph/intersection_graph_controller.cpp +++ b/apps/graph/graph/intersection_graph_controller.cpp @@ -1,7 +1,7 @@ #include "intersection_graph_controller.h" +#include #include "../../shared/poincare_helpers.h" #include -#include using namespace Shared; @@ -22,17 +22,15 @@ void IntersectionGraphController::reloadBannerView() { constexpr size_t bufferSize = FunctionBannerDelegate::k_maxNumberOfCharacters+Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits); char buffer[bufferSize]; const char * space = " "; - const char * legend = "="; - // 'f(x)=g(x)=', keep 2 chars for '=' + // 'f(x)=g(x)≈' ExpiringPointer f = functionStore()->modelForRecord(m_record); - int numberOfChar = f->nameWithArgument(buffer, bufferSize-2); + int numberOfChar = f->nameWithArgument(buffer, bufferSize - UTF8Decoder::CharSizeOfCodePoint('=') - UTF8Decoder::CharSizeOfCodePoint(UCodePointAlmostEqualTo)); assert(numberOfChar <= bufferSize); - numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); - // keep 1 char for '='; + numberOfChar += strlcpy(buffer+numberOfChar, "=", bufferSize-numberOfChar); ExpiringPointer g = functionStore()->modelForRecord(m_intersectedRecord); - numberOfChar += g->nameWithArgument(buffer+numberOfChar, bufferSize-numberOfChar-1); + numberOfChar += g->nameWithArgument(buffer + numberOfChar, bufferSize - numberOfChar - UTF8Decoder::CharSizeOfCodePoint(UCodePointAlmostEqualTo)); assert(numberOfChar <= bufferSize); - numberOfChar += strlcpy(buffer+numberOfChar, legend, bufferSize-numberOfChar); + numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); numberOfChar += PoincareHelpers::ConvertFloatToText(m_cursor->y(), buffer+numberOfChar, bufferSize-numberOfChar, Poincare::Preferences::MediumNumberOfSignificantDigits); assert(numberOfChar <= bufferSize); strlcpy(buffer+numberOfChar, space, bufferSize-numberOfChar); diff --git a/apps/graph/graph/tangent_graph_controller.cpp b/apps/graph/graph/tangent_graph_controller.cpp index 00db23d43..56f38bd65 100644 --- a/apps/graph/graph/tangent_graph_controller.cpp +++ b/apps/graph/graph/tangent_graph_controller.cpp @@ -1,6 +1,7 @@ #include "tangent_graph_controller.h" #include "../app.h" #include "../../apps_container.h" +#include #include "../../shared/poincare_helpers.h" #include @@ -72,15 +73,15 @@ void TangentGraphController::reloadBannerView() { Poincare::Context * context = textFieldDelegateApp()->localContext(); constexpr int precision = Preferences::MediumNumberOfSignificantDigits; - const char * legend = "a="; - int legendLength = strlcpy(buffer, legend, bufferSize); + int legendLength = strlcpy(buffer, "a", bufferSize); + legendLength += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+legendLength, bufferSize-legendLength); ExpiringPointer function = App::app()->functionStore()->modelForRecord(m_record); double y = function->approximateDerivative(m_cursor->x(), context); PoincareHelpers::ConvertFloatToText(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(precision), precision); m_bannerView->aView()->setText(buffer); - legend = "b="; - legendLength = strlcpy(buffer, legend, bufferSize); + legendLength = strlcpy(buffer, "b", bufferSize); + legendLength += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+legendLength, bufferSize-legendLength); Shared::TextFieldDelegateApp * myApp = textFieldDelegateApp(); assert(function->plotType() == Shared::ContinuousFunction::PlotType::Cartesian); y = -y*m_cursor->x()+function->evaluate2DAtParameter(m_cursor->x(), myApp->localContext()).x2(); diff --git a/apps/shared/function_banner_delegate.cpp b/apps/shared/function_banner_delegate.cpp index 98d98eecf..035d23749 100644 --- a/apps/shared/function_banner_delegate.cpp +++ b/apps/shared/function_banner_delegate.cpp @@ -27,7 +27,7 @@ void FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(CurveViewCursor numberOfChar = function->nameWithArgument(buffer, bufferSize); assert(numberOfChar <= bufferSize); - numberOfChar += strlcpy(buffer+numberOfChar, "=", bufferSize-numberOfChar); + numberOfChar += UTF8Decoder::CodePointToChars(UCodePointAlmostEqualTo, buffer+numberOfChar, bufferSize-numberOfChar); numberOfChar += function->printValue(cursor->t(), cursor->x(),cursor->y(), buffer+numberOfChar, bufferSize-numberOfChar, precision, context); assert(numberOfChar <= bufferSize); strlcpy(buffer+numberOfChar, space, bufferSize-numberOfChar); diff --git a/ion/include/ion/unicode/code_point.h b/ion/include/ion/unicode/code_point.h index 52708cfed..7f7de9326 100644 --- a/ion/include/ion/unicode/code_point.h +++ b/ion/include/ion/unicode/code_point.h @@ -39,6 +39,7 @@ static constexpr CodePoint UCodePointRightwardsArrow = 0x2192; // → static constexpr CodePoint UCodePointNArySummation = 0x2211; // ∑ static constexpr CodePoint UCodePointSquareRoot = 0x221a; // √ static constexpr CodePoint UCodePointIntegral = 0x222b; // ∫ +static constexpr CodePoint UCodePointAlmostEqualTo = 0x2248; // ≈ static constexpr CodePoint UCodePointMathematicalBoldSmallI = 0x1d422; // 𝐢 #endif