annotate OrthancFramework/Sources/Images/Font.h @ 4188:a2f1c97002fe

removed bad include for win32
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 14 Sep 2020 20:34:47 +0200
parents bf7b9edf6b81
children 785a2713323e
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * the License, or (at your option) any later version.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * 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
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * Lesser General Public License for more details.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
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
17 * 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
18 * 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
19 * <http://www.gnu.org/licenses/>.
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
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 #pragma once
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
25 #include "../OrthancFramework.h"
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
26
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "ImageAccessor.h"
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <stdint.h>
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <vector>
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <map>
1616
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
32 #include <boost/noncopyable.hpp>
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Orthanc
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
36 class ORTHANC_PUBLIC Font : public boost::noncopyable
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 private:
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 struct Character
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 unsigned int width_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 unsigned int height_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 unsigned int top_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 unsigned int advance_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 std::vector<uint8_t> bitmap_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 };
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 typedef std::map<char, Character*> Characters;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 std::string name_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 unsigned int size_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 Characters characters_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 unsigned int maxHeight_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 void DrawCharacter(ImageAccessor& target,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 const Character& character,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 int x,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 int y,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 const uint8_t color[4]) const;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 void DrawInternal(ImageAccessor& target,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 const std::string& utf8,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 int x,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 int y,
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 const uint8_t color[4]) const;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 public:
1617
dd1f7909a14c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1616
diff changeset
68 Font() :
dd1f7909a14c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1616
diff changeset
69 size_(0),
dd1f7909a14c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1616
diff changeset
70 maxHeight_(0)
1616
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
71 {
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
72 }
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
73
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 ~Font();
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 void LoadFromMemory(const std::string& font);
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
2407
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
78 #if ORTHANC_SANDBOXED == 0
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 void LoadFromFile(const std::string& path);
2407
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
80 #endif
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 const std::string& GetName() const
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 return name_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 unsigned int GetSize() const
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 return size_;
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
1611
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
92 void Draw(ImageAccessor& target,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
93 const std::string& utf8,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
94 int x,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
95 int y,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
96 uint8_t grayscale) const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
1611
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
98 void Draw(ImageAccessor& target,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
99 const std::string& utf8,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
100 int x,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
101 int y,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
102 uint8_t r,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
103 uint8_t g,
5e9b2aac8b89 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
104 uint8_t b) const;
2900
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
105
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
106 void ComputeTextExtent(unsigned int& width,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
107 unsigned int& height,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
108 const std::string& utf8) const;
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
109
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
110 ImageAccessor* Render(const std::string& utf8,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
111 PixelFormat format,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
112 uint8_t r,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
113 uint8_t g,
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
114 uint8_t b) const;
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
115
668d5ad73c74 Font::Render()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
116 ImageAccessor* RenderAlpha(const std::string& utf8) const;
1610
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 };
2dff2bdffdb8 font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }