annotate OrthancFramework/Sources/Images/Font.h @ 5334:5b2a5cc64cb1

upgraded anonymization to Basic Profile of PS 3.15-2023b Table E.1-1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Jun 2023 15:12:39 +0200
parents 0ea402b4d901
children 48b8dae6dc77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1617
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 * the License, or (at your option) any later version.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * Lesser General Public License for more details.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 * <http://www.gnu.org/licenses/>.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
26 #include "../OrthancFramework.h"
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
27
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "ImageAccessor.h"
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <stdint.h>
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <vector>
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <map>
1616
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
33 #include <boost/noncopyable.hpp>
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
37 class ORTHANC_PUBLIC Font : public boost::noncopyable
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 private:
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 struct Character
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 unsigned int width_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 unsigned int height_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 unsigned int top_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 unsigned int advance_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 std::vector<uint8_t> bitmap_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 };
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 typedef std::map<char, Character*> Characters;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 std::string name_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 unsigned int size_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 Characters characters_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 unsigned int maxHeight_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 void DrawCharacter(ImageAccessor& target,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 const Character& character,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 int x,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 int y,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 const uint8_t color[4]) const;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 void DrawInternal(ImageAccessor& target,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 const std::string& utf8,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 int x,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 int y,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 const uint8_t color[4]) const;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 public:
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
69 Font();
1616
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
70
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ~Font();
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 void LoadFromMemory(const std::string& font);
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
2407
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
75 #if ORTHANC_SANDBOXED == 0
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 void LoadFromFile(const std::string& path);
2407
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
77 #endif
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
79 const std::string& GetName() const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
81 unsigned int GetSize() const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
1611
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
83 void Draw(ImageAccessor& target,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
84 const std::string& utf8,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
85 int x,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
86 int y,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
87 uint8_t grayscale) const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
1611
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
89 void Draw(ImageAccessor& target,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
90 const std::string& utf8,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
91 int x,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
92 int y,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
93 uint8_t r,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
94 uint8_t g,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
95 uint8_t b) const;
2900
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
96
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
97 void ComputeTextExtent(unsigned int& width,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
98 unsigned int& height,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
99 const std::string& utf8) const;
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
100
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
101 ImageAccessor* Render(const std::string& utf8,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
102 PixelFormat format,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
103 uint8_t r,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
104 uint8_t g,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
105 uint8_t b) const;
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
106
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
107 ImageAccessor* RenderAlpha(const std::string& utf8) const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 };
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }