# HG changeset patch # User Sebastien Jodogne # Date 1621263543 -7200 # Node ID 373d7f7e796e0de8660cf6ef6a8d8b02c3c25889 # Parent 9b650ab68d4c0aa2cb222b59430a1b5e0b1477d3 ICompositor::ComputeTextBoundingBox() diff -r 9b650ab68d4c -r 373d7f7e796e OrthancStone/Sources/Scene2D/CairoCompositor.cpp --- a/OrthancStone/Sources/Scene2D/CairoCompositor.cpp Mon May 17 16:11:17 2021 +0200 +++ b/OrthancStone/Sources/Scene2D/CairoCompositor.cpp Mon May 17 16:59:03 2021 +0200 @@ -190,4 +190,24 @@ return found->second->RenderText(utf8); } } + + +#if ORTHANC_ENABLE_LOCALE == 1 + TextBoundingBox* CairoCompositor::ComputeTextBoundingBox(size_t fontIndex, + const std::string& utf8) + { + Fonts::const_iterator found = fonts_.find(fontIndex); + + if (found == fonts_.end()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, + "No such font: " + boost::lexical_cast(fontIndex)); + } + else + { + assert(found->second != NULL); + return new TextBoundingBox(found->second->GetAlphabet(), utf8); + } + } +#endif } diff -r 9b650ab68d4c -r 373d7f7e796e OrthancStone/Sources/Scene2D/CairoCompositor.h --- a/OrthancStone/Sources/Scene2D/CairoCompositor.h Mon May 17 16:11:17 2021 +0200 +++ b/OrthancStone/Sources/Scene2D/CairoCompositor.h Mon May 17 16:59:03 2021 +0200 @@ -92,5 +92,10 @@ Orthanc::ImageAccessor* RenderText(size_t fontIndex, const std::string& utf8) const; + +#if ORTHANC_ENABLE_LOCALE == 1 + virtual TextBoundingBox* ComputeTextBoundingBox(size_t fontIndex, + const std::string& utf8) ORTHANC_OVERRIDE; +#endif }; } diff -r 9b650ab68d4c -r 373d7f7e796e OrthancStone/Sources/Scene2D/ICompositor.h --- a/OrthancStone/Sources/Scene2D/ICompositor.h Mon May 17 16:11:17 2021 +0200 +++ b/OrthancStone/Sources/Scene2D/ICompositor.h Mon May 17 16:59:03 2021 +0200 @@ -25,6 +25,10 @@ #include "Scene2D.h" #include "ScenePoint2D.h" +#if ORTHANC_ENABLE_LOCALE == 1 +# include "../Fonts/TextBoundingBox.h" +#endif + namespace OrthancStone { class ICompositor : public boost::noncopyable @@ -69,5 +73,10 @@ { scene.FitContent(GetCanvasWidth(), GetCanvasHeight()); } + +#if ORTHANC_ENABLE_LOCALE == 1 + virtual TextBoundingBox* ComputeTextBoundingBox(size_t fontIndex, + const std::string& utf8) = 0; +#endif }; } diff -r 9b650ab68d4c -r 373d7f7e796e OrthancStone/Sources/Scene2D/OpenGLCompositor.cpp --- a/OrthancStone/Sources/Scene2D/OpenGLCompositor.cpp Mon May 17 16:11:17 2021 +0200 +++ b/OrthancStone/Sources/Scene2D/OpenGLCompositor.cpp Mon May 17 16:59:03 2021 +0200 @@ -253,4 +253,24 @@ canvasWidth_ = canvasWidth; canvasHeight_ = canvasHeight; } + + +#if ORTHANC_ENABLE_LOCALE == 1 + TextBoundingBox* OpenGLCompositor::ComputeTextBoundingBox(size_t fontIndex, + const std::string& utf8) + { + Fonts::const_iterator found = fonts_.find(fontIndex); + + if (found == fonts_.end()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, + "No such font: " + boost::lexical_cast(fontIndex)); + } + else + { + assert(found->second != NULL); + return new TextBoundingBox(found->second->GetAlphabet().GetAlphabet(), utf8); + } + } +#endif } diff -r 9b650ab68d4c -r 373d7f7e796e OrthancStone/Sources/Scene2D/OpenGLCompositor.h --- a/OrthancStone/Sources/Scene2D/OpenGLCompositor.h Mon May 17 16:11:17 2021 +0200 +++ b/OrthancStone/Sources/Scene2D/OpenGLCompositor.h Mon May 17 16:59:03 2021 +0200 @@ -85,5 +85,10 @@ { return canvasHeight_; } + +#if ORTHANC_ENABLE_LOCALE == 1 + virtual TextBoundingBox* ComputeTextBoundingBox(size_t fontIndex, + const std::string& utf8) ORTHANC_OVERRIDE; +#endif }; }