NVIDIA DeepStream SDK API Reference

9.1 Release
sources/libs/nvll_osd/textbackend/backend.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef TEXT_BACKEND_HPP
19 #define TEXT_BACKEND_HPP
20 
21 #include <vector>
22 #include <memory>
23 #include <tuple>
24 
25 // #define ENABLE_TEXT_BACKEND_PANGO
26 // #define ENABLE_TEXT_BACKEND_STB
27 #define MAX_FONT_SIZE 200
28 
29 enum class TextBackendType : int {
30  None = 0,
31  PangoCairo = 1,
32  StbTrueType = 2
33 };
34 
35 class WordMeta{
36 public:
37  virtual int width() const = 0;
38  virtual int height() const = 0;
39  virtual int x_offset_on_bitmap() const = 0;
40  virtual int xadvance(int font_size, bool empty=false) const = 0;
41 };
42 
44 public:
45  virtual WordMeta* query(unsigned long int word) = 0;
46 };
47 
49 public:
50  virtual std::vector<unsigned long int> split_utf8(const char* utf8_text) = 0;
51  virtual std::tuple<int, int, int> measure_text(const std::vector<unsigned long int>& words, unsigned int font_size, const char* font) = 0;
52  virtual void add_build_text(const std::vector<unsigned long int>& words, unsigned int font_size, const char* font) = 0;
53  virtual void build_bitmap(void* stream = nullptr) = 0;
54  virtual WordMetaMapper* query(const char* font, int font_size) = 0;
55  virtual unsigned char* bitmap_device_pointer() const = 0;
56  virtual int bitmap_width() const = 0;
57  virtual int compute_y_offset(int max_glyph_height, int h, WordMeta* word, int font_size) const = 0;
58  virtual int uniform_font_size(int size) const = 0;
59 };
60 
61 const char* text_backend_type_name(TextBackendType backend);
62 std::shared_ptr<TextBackend> create_text_backend(TextBackendType backend);
63 std::string concat_font_name_size(const char* name, int size);
64 
65 #endif // TEXT_BACKEND_HPP
cuOSDClockFormat::None
@ None
WordMeta
Definition: sources/libs/nvll_osd/textbackend/backend.hpp:35
cuOSDTextBackend::StbTrueType
@ StbTrueType
WordMetaMapper
Definition: sources/libs/nvll_osd/textbackend/backend.hpp:43
WordMeta::xadvance
virtual int xadvance(int font_size, bool empty=false) const =0
create_text_backend
std::shared_ptr< TextBackend > create_text_backend(TextBackendType backend)
WordMeta::width
virtual int width() const =0
TextBackend::add_build_text
virtual void add_build_text(const std::vector< unsigned long int > &words, unsigned int font_size, const char *font)=0
TextBackend::uniform_font_size
virtual int uniform_font_size(int size) const =0
concat_font_name_size
std::string concat_font_name_size(const char *name, int size)
text_backend_type_name
const char * text_backend_type_name(TextBackendType backend)
TextBackend::bitmap_device_pointer
virtual unsigned char * bitmap_device_pointer() const =0
TextBackend::build_bitmap
virtual void build_bitmap(void *stream=nullptr)=0
TextBackend::compute_y_offset
virtual int compute_y_offset(int max_glyph_height, int h, WordMeta *word, int font_size) const =0
TextBackend
Definition: sources/libs/nvll_osd/textbackend/backend.hpp:48
WordMeta::height
virtual int height() const =0
TextBackend::measure_text
virtual std::tuple< int, int, int > measure_text(const std::vector< unsigned long int > &words, unsigned int font_size, const char *font)=0
cuOSDTextBackend::PangoCairo
@ PangoCairo
WordMeta::x_offset_on_bitmap
virtual int x_offset_on_bitmap() const =0
TextBackendType
TextBackendType
Definition: sources/libs/nvll_osd/textbackend/backend.hpp:29
TextBackend::bitmap_width
virtual int bitmap_width() const =0
TextBackend::query
virtual WordMetaMapper * query(const char *font, int font_size)=0
WordMetaMapper::query
virtual WordMeta * query(unsigned long int word)=0
TextBackend::split_utf8
virtual std::vector< unsigned long int > split_utf8(const char *utf8_text)=0