nareshmlx/opencv-pr huggingface dataset:
**File:** modules/3d/include/opencv2/3d/odometry_frame.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples
**Review Line:** 36

**Code Changes:**
```diff
  * OdometryFrame is made to be used together with Odometry class to reuse precalculated data between Rt data calculations.
- * A proper way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
+ * A correct way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
  */
-class CV_EXPORTS_W OdometryFrame
+class CV_EXPORTS_W_SIMPLE OdometryFrame
 {
 public:
     /**
      * @brief Construct a new OdometryFrame object. All non-empty images should have the same size.
      *
```

Review comment:
Please add Python test for `OdometryFrame` class.
**File:** modules/3d/misc/python/test/test_volume.py
**Change Type:** added
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -0,0 +1,123 @@
+import numpy as np
+import cv2 as cv
+
+from tests_common import NewOpenCVTests
+
+class volume_test(NewOpenCVTests):
+    def test_VolumeDefault(self):
+        depthPath = 'cv/rgbd/depth.png'
+        depth = self.get_sample(depthPath, cv.IMREAD_ANYDEPTH).astype(np.float32)
```

Review comment:
Didn't get it; the only method that modifies the volume is `integrate/integrateColor()` All volumes support `raycast/raycastEx` but only ColorTSDF supports `*color()` methods
**File:** modules/3d/include/opencv2/3d/odometry_frame.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -29,68 +29,68 @@ enum OdometryFramePyramidType
 /**
  * @brief An object that keeps per-frame data for Odometry algorithms from user-provided images to algorithm-specific precalculated data.
  * When not empty, it contains a depth image, a mask of valid pixels and a set of pyramids generated from that data.
- * An BGR/Gray image and normals are optional.
+ * A BGR/Gray image and normals are optional.
  * OdometryFrame is made to be used together with Odometry class to reuse precalculated data between Rt data calculations.
- * A proper way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
+ * A correct way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
  */
```

Review comment:
Used int instead
**File:** modules/3d/include/opencv2/3d/odometry_frame.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples
**Review Line:** 36

**Code Changes:**
```diff
  * OdometryFrame is made to be used together with Odometry class to reuse precalculated data between Rt data calculations.
- * A proper way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
+ * A correct way to do that is to call Odometry::prepareFrames() on prev and next frames and then pass them to Odometry::compute() method.
  */
-class CV_EXPORTS_W OdometryFrame
+class CV_EXPORTS_W_SIMPLE OdometryFrame
 {
 public:
     /**
      * @brief Construct a new OdometryFrame object. All non-empty images should have the same size.
      *
```

Review comment:
That wasn't a 20-minute adventure but I did it. Now this is more Odometry-related PR than Volume-related, see the changes.
**File:** modules/3d/include/opencv2/3d/odometry.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -18,7 +18,7 @@ namespace cv
 * @param RGB       only rgb image
 * @param RGB_DEPTH depth and rgb data simultaneously
 */
-enum OdometryType
+enum class OdometryType
 {
     DEPTH     = 0,
     RGB       = 1,
@@ -39,41 +39,69 @@ class CV_EXPORTS_W Odometry
```

Review comment:
`explicit` is needed for `CV_WRAP explicit Odometry(OdometryType otype);` only.
**File:** modules/3d/include/opencv2/3d/volume.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples
**Review Line:** 58

**Code Changes:**
```diff
     * @param pose the pose of camera in global coordinates.
     */
-    void integrate(InputArray depth, InputArray image, InputArray pose);
+    CV_WRAP_AS(integrateColor) void integrate(InputArray depth, InputArray image, InputArray pose);
+
+    // Python bindings do not process noArray() default argument correctly, so the raycast() method is repeated several times
+
+    /** @brief Renders the volume contents into an image. The resulting points and normals are in camera's coordinate system.
+
+    Rendered image size and camera intrinsics are taken from volume settings structure.
+
```

Review comment:
It's not true. Python `None` is treated by bindings as `noArray()`. The issue may be related to method resolution only, if there are more than one candidate for call.
**File:** modules/3d/include/opencv2/3d/volume_settings.hpp
**Change Type:** modified
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -20,148 +20,143 @@ enum class VolumeType
 };
 
 
-class CV_EXPORTS_W VolumeSettings
+class CV_EXPORTS_W_SIMPLE VolumeSettings
 {
 public:
-    /** @brief Constructor of settings for common TSDF volume type.
-    */
```

Review comment:
No need extra spaces in formatting as documentation is added between methods.
**File:** samples/python/volume.py
**Change Type:** added
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+import numpy as np
+import cv2 as cv
+import argparse
+
+# Use source data from this site:
+# https://vision.in.tum.de/data/datasets/rgbd-dataset/download
+# For example if you use rgbd_dataset_freiburg1_xyz sequence, your prompt should be:
+# python /path_to_opencv/samples/python/volume.py --source_folder /path_to_datasets/rgbd_dataset_freiburg1_xyz --algo <some algo>
+# so that the folder contains files groundtruth.txt and depth.txt
```

Review comment:
I propose to move instruction to the head of the file. To make it obvious.
**File:** modules/3d/misc/python/test/test_volume.py
**Change Type:** added
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -0,0 +1,123 @@
+import numpy as np
+import cv2 as cv
+
+from tests_common import NewOpenCVTests
+
+class volume_test(NewOpenCVTests):
+    def test_VolumeDefault(self):
+        depthPath = 'cv/rgbd/depth.png'
+        depth = self.get_sample(depthPath, cv.IMREAD_ANYDEPTH).astype(np.float32)
```

Review comment:
Need to check if images are loaded.
**File:** modules/3d/misc/python/test/test_volume.py
**Change Type:** added
**Context:** PR #22925: Volume gets Python bindings and examples

**Code Changes:**
```diff
@@ -0,0 +1,123 @@
+import numpy as np
+import cv2 as cv
+
+from tests_common import NewOpenCVTests
+
+class volume_test(NewOpenCVTests):
+    def test_VolumeDefault(self):
+        depthPath = 'cv/rgbd/depth.png'
+        depth = self.get_sample(depthPath, cv.IMREAD_ANYDEPTH).astype(np.float32)
```

Review comment:
Check image load.
**File:** cmake/OpenCVUtils.cmake
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 1902

**Code Changes:**
```diff
+    set(pattern "${pattern}${pattern}")
+    set(pattern "${pattern}${pattern}")
+    set(pattern "${pattern}${pattern}")
+    string(REGEX REPLACE "(${pattern})" "\\1\n" content "${hex_content}")
+    string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " content "${content}")
+    string(REGEX REPLACE ", $" "" content "${content}")
+
+    set(array_definition "static const unsigned char ${cpp_variable}[] =\n{\n${content}\n};")
+    set(source "// Auto generated file.\n${array_definition}\n")
+
+    file(WRITE "${hdr_filename}" "${source}")
```

Review comment:
Can we assume python availability to handle that? Or prefer python for processing if it is available.
**File:** modules/core/include/opencv2/core/cvdef.h
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -915,6 +915,14 @@ class float16_t
 }
 #endif
 
+/** @brief Constructs the 'fourcc' code, used in video codecs and many other places.
+    Simply call it with 4 chars like `CV_FOURCC('I', 'Y', 'U', 'V')`
+*/
+CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
+{
+    return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
```

Review comment:
Documentation is confusing, especially with new usage.
**File:** modules/core/misc/objc/common/Range.mm
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 4

**Code Changes:**
```diff
@@ -0,0 +1,96 @@
+//
+//  Range.m
+//
+//  Created by Giles Payne on 2019/10/08.
+//
+
+#import "Range.h"
+
+@implementation Range {
```

Review comment:
Do we need to merge something from the "master" branch?
**File:** modules/imgproc/CMakeLists.txt
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -12,8 +12,49 @@ ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2)
 ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
 ocv_define_module(imgproc opencv_core WRAP java objc python js)
 
+ocv_module_include_directories(opencv_imgproc ${ZLIB_INCLUDE_DIRS})
+
 ocv_check_environment_variables(OPENCV_IPP_GAUSSIAN_BLUR)
 option(OPENCV_IPP_GAUSSIAN_BLUR "Enable IPP optimizations for GaussianBlur (+8Mb in binary size)" OFF)
 if(OPENCV_IPP_GAUSSIAN_BLUR)
   ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/smooth.dispatch.cpp "ENABLE_IPP_GAUSSIAN_BLUR=1")
```

Review comment:
All external dependencies should be optional (externally configurable through CMake vars).
**File:** modules/imgproc/fonts/Rubik_OFL.txt
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 5

**Code Changes:**
```diff
@@ -0,0 +1,93 @@
+Copyright 2015 The Rubik Project Authors (https://github.com/googlefonts/rubik),
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
```

Review comment:
We should install this license through `ocv_install_3rdparty_licenses()`.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -4631,6 +4631,113 @@ CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace,
                                            const int pixelHeight,
                                            const int thickness = 1);
 
+/** @brief Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.
+
+The class is used to store the loaded fonts;
+the font can then be passed to the functions
+putText and getTextSize.
+*/
```

Review comment:
> String Let deprecate `String` and use `std::string` instead.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -4631,6 +4631,113 @@ CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace,
                                            const int pixelHeight,
                                            const int thickness = 1);
 
+/** @brief Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.
+
+The class is used to store the loaded fonts;
+the font can then be passed to the functions
+putText and getTextSize.
+*/
```

Review comment:
> int flags Prefer enums.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -4631,6 +4631,113 @@ CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace,
                                            const int pixelHeight,
                                            const int thickness = 1);
 
+/** @brief Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.
+
+The class is used to store the loaded fonts;
+the font can then be passed to the functions
+putText and getTextSize.
+*/
```

Review comment:
What is about introduction of `FontStyle` class to capture most part of these parameters?
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -4631,6 +4631,113 @@ CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace,
                                            const int pixelHeight,
                                            const int thickness = 1);
 
+/** @brief Wrapper on top of a truetype/opentype/etc font, i.e. Freetype's FT_Face.
+
+The class is used to store the loaded fonts;
+the font can then be passed to the functions
+putText and getTextSize.
+*/
```

Review comment:
> double weight Why is double required here? Usually `int` is enough, see `QFont` API as example.
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 2539

**Code Changes:**
```diff
@@ -2861,7 +2536,7 @@ cvInitFont( CvFont *font, int font_face, double hscale, double vscale,
 {
     CV_Assert( font != 0 && hscale > 0 && vscale > 0 && thickness >= 0 );
 
-    font->ascii = cv::getFontData(font_face);
+    font->ascii = 0;
     font->font_face = font_face;
     font->hscale = (float)hscale;
     font->vscale = (float)vscale;
```

Review comment:
Why is not removed completely?
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -0,0 +1,1547 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+#include <list>
+#include <tuple>
+#include <unordered_map>
```

Review comment:
Avoid using of obfuscated names.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 10

**Code Changes:**
```diff
+#include "precomp.hpp"
+
+#include <list>
+#include <tuple>
+#include <unordered_map>
+#include "zlib.h"
+#include "stb_truetype.hpp"
+
+namespace cv
+{
+
```

Review comment:
> zlib.h All 3rdparty dependencies should be optional. Related functionality is disabled if dependency is required.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 960

**Code Changes:**
```diff
+
+    // step 1. convert UTF8 to UTF32
+    u32buf.clear();
+    for( i = 0; i < len; i++ )
+    {
+        uchar ch = (uchar)str[i];
+        unsigned charcode;
+        if( ch <= 127 )
+            charcode = ch;
+        else if( ch <= 223 && i+1 < len && (str[i+1] & 0xc0) == 0x80) {
+            charcode = ((ch & 31) << 6) | (str[i+1] & 63);
```

Review comment:
Functions with >100 LOC should be avoided (this one has 500 LOC). Consider extraction of functionality into dedicated functions.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV

**Code Changes:**
```diff
@@ -0,0 +1,1547 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+#include <list>
+#include <tuple>
+#include <unordered_map>
```

Review comment:
IMHO, Exception should be emitted instead of silent return.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 933

**Code Changes:**
```diff
+
+    saved_weights[BUILTIN_FONTS_NUM] = stbtt_GetWeight(fontface->ttface);
+    fontface->setParams(size, weight);
+
+    for(j = 0; j < BUILTIN_FONTS_NUM; j++)
+    {
+        FontFace& fface = builtin_ffaces[j];
+        if(!builtin_ffaces_initialized)
+            fface.set(builtinFontData[j].name);
+
+        if (fface->ttface) {
```

Review comment:
Why we are touching ALL fonts?
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 943

**Code Changes:**
```diff
+        if (fface->ttface) {
+            saved_weights[j] = stbtt_GetWeight(fface->ttface);
+            fface->setParams(size, weight);
+        }
+    }
+    builtin_ffaces_initialized = true;
+
+    if(alignment == PUT_TEXT_ALIGN_RIGHT)
+        std::swap(x0, x1);
+
+    int alignSign = alignment == PUT_TEXT_ALIGN_RIGHT ? -1 : 1;
```

Review comment:
What is about reenterability? Do we guarantee avoiding of memory leaks from such initialization?
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 4664

**Code Changes:**
```diff
+             `myfont.setInstance({CV_FOURCC('w','g','h','t'), 400<<16, CV_FOURCC('s','l','n','t'), -(15<<16)});`
+        Note that the parameter values are specified in 16.16 fixed-point format, that is, integer values
+        need to be shifted by 16 (or multiplied by 65536).
+    */
+    CV_WRAP bool setInstance(const std::vector<int>& params);
+    CV_WRAP bool getInstance(CV_OUT std::vector<int>& params) const;
+
+    struct Impl;
+
+    Impl* operator -> ();
+    static bool getBuiltinFontData(const String& fontName, const uchar*& data, size_t& datasize);
```

Review comment:
"Instance" of what? `Property` is less confused name. > CV_FOURCC('s','l','n','t') Public API must be simple and readable. Obfuscation should not pass. --- What is the problem to add `setWeight()/getWeight()`, etc?
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 470

**Code Changes:**
```diff
+    std::vector<uchar> pixbuf;
+    uchar* glyph_buf;
+    int glyph_bufsz;
+};
+
+thread_local FontRenderEngine fontRenderEngine;
+
+FontFace::FontFace() { impl = makePtr<Impl>(); }
+FontFace::FontFace(const String& fontname)
+{
+    impl = makePtr<Impl>();
```

Review comment:
Why is thread local?
**File:** cmake/OpenCVUtils.cmake
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 1902

**Code Changes:**
```diff
+    set(pattern "${pattern}${pattern}")
+    set(pattern "${pattern}${pattern}")
+    set(pattern "${pattern}${pattern}")
+    string(REGEX REPLACE "(${pattern})" "\\1\n" content "${hex_content}")
+    string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " content "${content}")
+    string(REGEX REPLACE ", $" "" content "${content}")
+
+    set(array_definition "static const unsigned char ${cpp_variable}[] =\n{\n${content}\n};")
+    set(source "// Auto generated file.\n${array_definition}\n")
+
+    file(WRITE "${hdr_filename}" "${source}")
```

Review comment:
I'd prefer to leave it in CMake for now; it works. After it is integrated, I bless you to rewrite it in Python
**File:** modules/core/misc/objc/common/Range.mm
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 4

**Code Changes:**
```diff
@@ -0,0 +1,96 @@
+//
+//  Range.m
+//
+//  Created by Giles Payne on 2019/10/08.
+//
+
+#import "Range.h"
+
+@implementation Range {
```

Review comment:
yes, this part probably needs to be back ported to master
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 2539

**Code Changes:**
```diff
@@ -2861,7 +2536,7 @@ cvInitFont( CvFont *font, int font_face, double hscale, double vscale,
 {
     CV_Assert( font != 0 && hscale > 0 && vscale > 0 && thickness >= 0 );
 
-    font->ascii = cv::getFontData(font_face);
+    font->ascii = 0;
     font->font_face = font_face;
     font->hscale = (float)hscale;
     font->vscale = (float)vscale;
```

Review comment:
let's remove the old API in a separate pull request.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 10

**Code Changes:**
```diff
+#include "precomp.hpp"
+
+#include <list>
+#include <tuple>
+#include <unordered_map>
+#include "zlib.h"
+#include "stb_truetype.hpp"
+
+namespace cv
+{
+
```

Review comment:
zlib is required, because the embedded fonts are compressed
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 960

**Code Changes:**
```diff
+
+    // step 1. convert UTF8 to UTF32
+    u32buf.clear();
+    for( i = 0; i < len; i++ )
+    {
+        uchar ch = (uchar)str[i];
+        unsigned charcode;
+        if( ch <= 127 )
+            charcode = ch;
+        else if( ch <= 223 && i+1 < len && (str[i+1] & 0xc0) == 0x80) {
+            charcode = ((ch & 31) << 6) | (str[i+1] & 63);
```

Review comment:
Who sets this policy? Who approves this policy? Have we discussed it?
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 933

**Code Changes:**
```diff
+
+    saved_weights[BUILTIN_FONTS_NUM] = stbtt_GetWeight(fontface->ttface);
+    fontface->setParams(size, weight);
+
+    for(j = 0; j < BUILTIN_FONTS_NUM; j++)
+    {
+        FontFace& fface = builtin_ffaces[j];
+        if(!builtin_ffaces_initialized)
+            fface.set(builtinFontData[j].name);
+
+        if (fface->ttface) {
```

Review comment:
because the missing characters from the specified font are automatically searched in all builtin fonts; because of this feature, you can use whatever font you want, but CJK characters (if missing) are automatically taken from the "uni" font. This feature is implemented in practically all software that works with text — terminals, text editors, browsers etc.
**File:** modules/imgproc/src/drawing_text.cpp
**Change Type:** added
**Context:** PR #18760: Adding truetype font support to OpenCV
**Review Line:** 943

**Code Changes:**
```diff
+        if (fface->ttface) {
+            saved_weights[j] = stbtt_GetWeight(fface->ttface);
+            fface->setParams(size, weight);
+        }
+    }
+    builtin_ffaces_initialized = true;
+
+    if(alignment == PUT_TEXT_ALIGN_RIGHT)
+        std::swap(x0, x1);
+
+    int alignSign = alignment == PUT_TEXT_ALIGN_RIGHT ? -1 : 1;
```

Review comment:
FontEngine is thread-local. There should not be any problems with reenterability.