Browse Source

Updated imgui

Thomas Buck 9 years ago
parent
commit
e3b087062f

+ 4
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20140203 ]
6
+    * Updated imgui to newest version, supporting Images
7
+    * Imgui Image texture viewer (still buggy)
8
+
5
     [ 20140124 ]
9
     [ 20140124 ]
6
     * Started working on Entity system.
10
     * Started working on Entity system.
7
 
11
 

+ 16
- 3
include/TextureManager.h View File

51
     SYSTEM
51
     SYSTEM
52
 };
52
 };
53
 
53
 
54
-/*!
55
- * \brief Texture registry
56
- */
54
+class BufferManager {
55
+  public:
56
+    BufferManager(int t, TextureStorage s) : texture(t), storage(s) { }
57
+    int getTextureID() { return texture; }
58
+    TextureStorage getTextureStorage() { return storage; }
59
+
60
+  private:
61
+    int texture;
62
+    TextureStorage storage;
63
+};
64
+
57
 class TextureManager {
65
 class TextureManager {
58
   public:
66
   public:
59
     static int initialize();
67
     static int initialize();
100
     static int getFirstTileAnimation(int index);
108
     static int getFirstTileAnimation(int index);
101
     static int getNextTileAnimation(int tile);
109
     static int getNextTileAnimation(int tile);
102
 
110
 
111
+    static BufferManager* getBufferManager(int tex, TextureStorage store);
112
+
103
   private:
113
   private:
104
     static std::vector<unsigned int>& getIds(TextureStorage s);
114
     static std::vector<unsigned int>& getIds(TextureStorage s);
105
     static std::vector<int>& getUnits(TextureStorage s);
115
     static std::vector<int>& getUnits(TextureStorage s);
116
     static std::vector<int> gameUnits;
126
     static std::vector<int> gameUnits;
117
     static std::vector<int> systemUnits;
127
     static std::vector<int> systemUnits;
118
     static unsigned int nextFreeTextureUnit;
128
     static unsigned int nextFreeTextureUnit;
129
+
130
+    static std::vector<BufferManager> gameBuffers;
131
+    static std::vector<BufferManager> systemBuffers;
119
 };
132
 };
120
 
133
 
121
 #endif
134
 #endif

+ 25
- 0
src/TextureManager.cpp View File

25
 std::vector<int> TextureManager::gameUnits;
25
 std::vector<int> TextureManager::gameUnits;
26
 std::vector<int> TextureManager::systemUnits;
26
 std::vector<int> TextureManager::systemUnits;
27
 unsigned int TextureManager::nextFreeTextureUnit = 0;
27
 unsigned int TextureManager::nextFreeTextureUnit = 0;
28
+std::vector<BufferManager> TextureManager::gameBuffers;
29
+std::vector<BufferManager> TextureManager::systemBuffers;
28
 
30
 
29
 int TextureManager::initialize() {
31
 int TextureManager::initialize() {
30
     assert(mTextureIdsGame.size() == 0);
32
     assert(mTextureIdsGame.size() == 0);
75
     }
77
     }
76
 
78
 
77
     clear();
79
     clear();
80
+
81
+    systemBuffers.clear();
78
 }
82
 }
79
 
83
 
80
 void TextureManager::clear() {
84
 void TextureManager::clear() {
94
     gameUnits.clear();
98
     gameUnits.clear();
95
     systemUnits.clear();
99
     systemUnits.clear();
96
     nextFreeTextureUnit = 0;
100
     nextFreeTextureUnit = 0;
101
+
102
+    gameBuffers.clear();
97
 }
103
 }
98
 
104
 
99
 int TextureManager::loadBufferSlot(unsigned char* image,
105
 int TextureManager::loadBufferSlot(unsigned char* image,
161
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
167
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
162
     }
168
     }
163
 
169
 
170
+    Log::get(LOG_DEBUG) << "New Texture: " << slot << " - "
171
+        << ((s == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
172
+
164
     return slot;
173
     return slot;
165
 }
174
 }
166
 
175
 
177
 }
186
 }
178
 
187
 
179
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
188
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
189
+    if (n >= getIds(s).size()) {
190
+        Log::get(LOG_DEBUG) << "Bound Unknown Texture " << n << " in "
191
+            << ((s == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
192
+    }
193
+
180
     assert(n < getIds(s).size());
194
     assert(n < getIds(s).size());
181
 
195
 
182
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
196
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
237
     return -1;
251
     return -1;
238
 }
252
 }
239
 
253
 
254
+BufferManager* TextureManager::getBufferManager(int tex, TextureStorage store) {
255
+    auto& v = (store == TextureStorage::GAME) ? gameBuffers : systemBuffers;
256
+    while (v.size() <= tex) {
257
+        v.emplace_back(v.size(), store);
258
+
259
+        Log::get(LOG_DEBUG) << "New BufferManager: " << v.size() - 1 << " - "
260
+            << ((store == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
261
+    }
262
+    return &(v.at(tex));
263
+}
264
+
240
 int TextureManager::loadImage(std::string filename, TextureStorage s, int slot) {
265
 int TextureManager::loadImage(std::string filename, TextureStorage s, int slot) {
241
     if (stringEndsWith(filename, ".pcx")) {
266
     if (stringEndsWith(filename, ".pcx")) {
242
         return loadPCX(filename, s, slot);
267
         return loadPCX(filename, s, slot);

+ 30
- 30
src/UI.cpp View File

89
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
89
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
90
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
90
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
91
                                              TextureStorage::SYSTEM, -1, false);
91
                                              TextureStorage::SYSTEM, -1, false);
92
+    io.Fonts->TexID = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
92
 
93
 
93
     // Set up OpenRaider style
94
     // Set up OpenRaider style
94
     ImGuiStyle& style = ImGui::GetStyle();
95
     ImGuiStyle& style = ImGui::GetStyle();
272
     if (ImGui::Begin("Engine", &visible, ImVec2(400, 400))) {
273
     if (ImGui::Begin("Engine", &visible, ImVec2(400, 400))) {
273
         Render::displayUI();
274
         Render::displayUI();
274
         RunTime::display();
275
         RunTime::display();
275
-        SoundManager::display();
276
 
276
 
277
-        /*
278
-        static bool visibleTex = false;
279
-        static bool visibleTile = false;
280
-        static bool visibleAnim = false;
281
-        static bool visibleSprite = false;
282
         if (ImGui::CollapsingHeader("Texture Viewer")) {
277
         if (ImGui::CollapsingHeader("Texture Viewer")) {
283
             static bool game = Game::isLoaded();
278
             static bool game = Game::isLoaded();
284
             static int index = 0;
279
             static int index = 0;
285
-            ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
286
-            ImGui::SliderInt("##texslide", &index, 0, TextureManager::.numTextures(
280
+            ImGui::SliderInt("##texslide", &index, 0, TextureManager::numTextures(
287
                                  game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1);
281
                                  game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1);
288
-            ImGui::PopItemWidth();
289
             ImGui::SameLine();
282
             ImGui::SameLine();
290
             if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
283
             if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
291
                 if (index < (TextureManager::numTextures(
284
                 if (index < (TextureManager::numTextures(
302
                     index = TextureManager::numTextures(
295
                     index = TextureManager::numTextures(
303
                                 game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1;
296
                                 game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1;
304
             }
297
             }
305
-            ImGui::SameLine();
306
-            if ((TextureManager::numTextures() > 0)) {
298
+
299
+            if ((TextureManager::numTextures(TextureStorage::GAME) > 0)) {
300
+                ImGui::SameLine();
307
                 ImGui::Checkbox("Game##texgame", &game);
301
                 ImGui::Checkbox("Game##texgame", &game);
308
             } else {
302
             } else {
309
                 game = false;
303
                 game = false;
310
             }
304
             }
311
-            ImGui::SameLine();
312
-            if (ImGui::Button("Show##texshow")) {
313
-                visibleTex = true;
314
-                visibleTile = false;
315
-                visibleAnim = false;
316
-                visibleSprite = false;
317
-            }
318
-            ImGui::SameLine();
319
-            if (ImGui::Button("Clear##texclear")) {
320
-                getRender().debugDisplayTexture();
321
-                visibleTex = false;
322
-            }
323
-            if (visibleTex) {
324
-                getRender().debugDisplayTexture(index,
325
-                                                game ? TextureStorage::GAME : TextureStorage::SYSTEM,
326
-                                                ImGui::GetWindowPos().x - ImGui::GetWindowWidth(),
327
-                                                ImGui::GetWindowPos().y,
328
-                                                ImGui::GetWindowWidth(), ImGui::GetWindowWidth());
305
+
306
+            if (index >= TextureManager::numTextures(game ? TextureStorage::GAME : TextureStorage::SYSTEM)) {
307
+                index = TextureManager::numTextures(game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1;
308
+                if (index < 0) {
309
+                    game = false;
310
+                    index = 0;
311
+                }
329
             }
312
             }
313
+
314
+            ImGui::Image(TextureManager::getBufferManager(index,
315
+                                                          game ? TextureStorage::GAME
316
+                                                            : TextureStorage::SYSTEM),
317
+                         ImVec2(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3));
330
         }
318
         }
331
 
319
 
320
+        SoundManager::display();
321
+
322
+        /*
323
+        static bool visibleTex = false;
324
+        static bool visibleTile = false;
325
+        static bool visibleAnim = false;
326
+        static bool visibleSprite = false;
327
+
328
+
332
         if (ImGui::CollapsingHeader("Textile Viewer")) {
329
         if (ImGui::CollapsingHeader("Textile Viewer")) {
333
             if (TextureManager::numTiles() > 0) {
330
             if (TextureManager::numTiles() > 0) {
334
                 static int index = 0;
331
                 static int index = 0;
596
 
593
 
597
     imguiShader.use();
594
     imguiShader.use();
598
     imguiShader.loadUniform(0, Window::getSize());
595
     imguiShader.loadUniform(0, Window::getSize());
599
-    imguiShader.loadUniform(1, fontTex, TextureStorage::SYSTEM);
600
     vert.bindBuffer(0, 2);
596
     vert.bindBuffer(0, 2);
601
     uv.bindBuffer(1, 2);
597
     uv.bindBuffer(1, 2);
602
     col.bindBuffer(2, 4);
598
     col.bindBuffer(2, 4);
634
             uv.bufferData(uvs);
630
             uv.bufferData(uvs);
635
             col.bufferData(colors);
631
             col.bufferData(colors);
636
 
632
 
633
+            auto bm = static_cast<BufferManager*>(commands[n].texture_id);
634
+            assert(bm != nullptr);
635
+            imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
636
+
637
             glScissor(commands[n].clip_rect.x,
637
             glScissor(commands[n].clip_rect.x,
638
                       Window::getSize().y - commands[n].clip_rect.w,
638
                       Window::getSize().y - commands[n].clip_rect.w,
639
                       commands[n].clip_rect.z - commands[n].clip_rect.x,
639
                       commands[n].clip_rect.z - commands[n].clip_rect.x,

+ 567
- 247
src/deps/imgui/imgui.cpp
File diff suppressed because it is too large
View File


+ 116
- 50
src/deps/imgui/imgui.h View File

1
-// ImGui library v1.30 wip
1
+// ImGui library v1.31 wip
2
 // See .cpp file for commentary.
2
 // See .cpp file for commentary.
3
 // See ImGui::ShowTestWindow() for sample code.
3
 // See ImGui::ShowTestWindow() for sample code.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
6
 
6
 
7
 #pragma once
7
 #pragma once
8
 
8
 
9
+struct ImDrawCmd;
9
 struct ImDrawList;
10
 struct ImDrawList;
10
 struct ImFont;
11
 struct ImFont;
11
 struct ImFontAtlas;
12
 struct ImFontAtlas;
68
 
69
 
69
 namespace ImGui
70
 namespace ImGui
70
 {
71
 {
71
-    // Proxy functions to access the MemAllocFn/MemFreeFn/MemReallocFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
72
+    // Proxy functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
72
     IMGUI_API void*       MemAlloc(size_t sz);
73
     IMGUI_API void*       MemAlloc(size_t sz);
73
     IMGUI_API void        MemFree(void* ptr);
74
     IMGUI_API void        MemFree(void* ptr);
74
-    IMGUI_API void*       MemRealloc(void* ptr, size_t sz);
75
 }
75
 }
76
 
76
 
77
 // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). 
77
 // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). 
114
     inline const value_type&    back() const                    { IM_ASSERT(Size > 0); return Data[Size-1]; }
114
     inline const value_type&    back() const                    { IM_ASSERT(Size > 0); return Data[Size-1]; }
115
     inline void                 swap(ImVector<T>& rhs)          { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
115
     inline void                 swap(ImVector<T>& rhs)          { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
116
 
116
 
117
-    inline void                 reserve(size_t new_capacity)    { Data = (value_type*)ImGui::MemRealloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
118
     inline void                 resize(size_t new_size)         { if (new_size > Capacity) reserve(new_size); Size = new_size; }
117
     inline void                 resize(size_t new_size)         { if (new_size > Capacity) reserve(new_size); Size = new_size; }
118
+    inline void                 reserve(size_t new_capacity)    
119
+    { 
120
+        if (new_capacity <= Capacity) return;
121
+        T* new_data = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type));
122
+        memcpy(new_data, Data, Size * sizeof(value_type));
123
+        ImGui::MemFree(Data);
124
+        Data = new_data;
125
+        Capacity = new_capacity; 
126
+    }
119
 
127
 
120
     inline void                 push_back(const value_type& v)  { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
128
     inline void                 push_back(const value_type& v)  { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
121
     inline void                 pop_back()                      { IM_ASSERT(Size > 0); Size--; }
129
     inline void                 pop_back()                      { IM_ASSERT(Size > 0); Size--; }
243
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
251
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
244
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
252
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
245
     IMGUI_API bool          SmallButton(const char* label);
253
     IMGUI_API bool          SmallButton(const char* label);
246
-    IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 tint_col = 0xFFFFFFFF, ImU32 border_col = 0x00000000);
254
+    IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
255
+    IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
256
+    IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
247
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
257
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
248
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
258
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
249
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
259
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
302
     IMGUI_API void          LogText(const char* fmt, ...);                                      // pass text data straight to log (without being displayed)
312
     IMGUI_API void          LogText(const char* fmt, ...);                                      // pass text data straight to log (without being displayed)
303
 
313
 
304
     // Utilities
314
     // Utilities
305
-    IMGUI_API bool          IsItemHovered();                                                    // was the last item active area hovered by mouse?
306
-    IMGUI_API bool          IsItemFocused();                                                    // was the last item focused for keyboard input?
315
+    IMGUI_API bool          IsItemHovered();                                                    // was the last item hovered by mouse?
316
+    IMGUI_API bool          IsItemActive();                                                     // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
307
     IMGUI_API ImVec2        GetItemBoxMin();                                                    // get bounding box of last item
317
     IMGUI_API ImVec2        GetItemBoxMin();                                                    // get bounding box of last item
308
     IMGUI_API ImVec2        GetItemBoxMax();                                                    // get bounding box of last item
318
     IMGUI_API ImVec2        GetItemBoxMax();                                                    // get bounding box of last item
309
     IMGUI_API bool          IsClipped(const ImVec2& item_size);                                 // to perform coarse clipping on user's side (as an optimization)
319
     IMGUI_API bool          IsClipped(const ImVec2& item_size);                                 // to perform coarse clipping on user's side (as an optimization)
320
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
330
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
321
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
331
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
322
 
332
 
333
+    IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
334
+    IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
335
+    IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
336
+
337
+    // Obsolete (will be removed)
338
+    IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
339
+
323
 } // namespace ImGui
340
 } // namespace ImGui
324
 
341
 
325
 // Flags for ImGui::Begin()
342
 // Flags for ImGui::Begin()
326
 enum ImGuiWindowFlags_
343
 enum ImGuiWindowFlags_
327
 {
344
 {
328
     // Default: 0
345
     // Default: 0
329
-    ImGuiWindowFlags_ShowBorders            = 1 << 0,
330
-    ImGuiWindowFlags_NoTitleBar             = 1 << 1,
331
-    ImGuiWindowFlags_NoResize               = 1 << 2,
332
-    ImGuiWindowFlags_NoMove                 = 1 << 3,
333
-    ImGuiWindowFlags_NoScrollbar            = 1 << 4,
334
-    ImGuiWindowFlags_NoScrollWithMouse      = 1 << 5,
335
-    ImGuiWindowFlags_AlwaysAutoResize       = 1 << 6,
336
-    ImGuiWindowFlags_NoSavedSettings        = 1 << 7,   // Never load/save settings in .ini file
337
-    ImGuiWindowFlags_ChildWindow            = 1 << 8,   // For internal use by BeginChild()
338
-    ImGuiWindowFlags_ChildWindowAutoFitX    = 1 << 9,   // For internal use by BeginChild()
339
-    ImGuiWindowFlags_ChildWindowAutoFitY    = 1 << 10,  // For internal use by BeginChild()
340
-    ImGuiWindowFlags_ComboBox               = 1 << 11,  // For internal use by ComboBox()
341
-    ImGuiWindowFlags_Tooltip                = 1 << 12   // For internal use by Render() when using Tooltip
346
+    ImGuiWindowFlags_NoTitleBar             = 1 << 0,   // Disable title-bar
347
+    ImGuiWindowFlags_NoResize               = 1 << 1,   // Disable user resizing with the lower-right grip
348
+    ImGuiWindowFlags_NoMove                 = 1 << 2,   // Disable user moving the window
349
+    ImGuiWindowFlags_NoScrollbar            = 1 << 3,   // Disable scroll bar (window can still scroll with mouse or programatically)
350
+    ImGuiWindowFlags_NoScrollWithMouse      = 1 << 4,   // Disable user scrolling with mouse wheel
351
+    ImGuiWindowFlags_NoCollapse             = 1 << 5,   // Disable user collapsing window by double-clicking on it
352
+    ImGuiWindowFlags_AlwaysAutoResize       = 1 << 6,   // Resize every window to its content every frame
353
+    ImGuiWindowFlags_ShowBorders            = 1 << 7,   // Show borders around windows and items
354
+    ImGuiWindowFlags_NoSavedSettings        = 1 << 8,   // Never load/save settings in .ini file
355
+    // [Internal]
356
+    ImGuiWindowFlags_ChildWindow            = 1 << 9,   // For internal use by BeginChild()
357
+    ImGuiWindowFlags_ChildWindowAutoFitX    = 1 << 10,  // For internal use by BeginChild()
358
+    ImGuiWindowFlags_ChildWindowAutoFitY    = 1 << 11,  // For internal use by BeginChild()
359
+    ImGuiWindowFlags_ComboBox               = 1 << 12,  // For internal use by ComboBox()
360
+    ImGuiWindowFlags_Tooltip                = 1 << 13   // For internal use by BeginTooltip()
342
 };
361
 };
343
 
362
 
344
 // Flags for ImGui::InputText()
363
 // Flags for ImGui::InputText()
497
     ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
516
     ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
498
     float         FontGlobalScale;          // = 1.0f               // Global scale all fonts
517
     float         FontGlobalScale;          // = 1.0f               // Global scale all fonts
499
     bool          FontAllowUserScaling;     // = false              // Allow user scaling text of individual window with CTRL+Wheel.
518
     bool          FontAllowUserScaling;     // = false              // Allow user scaling text of individual window with CTRL+Wheel.
519
+    ImVec2        DisplayVisibleMin;        // <unset> (0.0f,0.0f)  // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
520
+    ImVec2        DisplayVisibleMax;        // <unset> (0.0f,0.0f)  // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
500
 
521
 
501
     //------------------------------------------------------------------
522
     //------------------------------------------------------------------
502
     // User Functions
523
     // User Functions
511
     const char* (*GetClipboardTextFn)();
532
     const char* (*GetClipboardTextFn)();
512
     void        (*SetClipboardTextFn)(const char* text);
533
     void        (*SetClipboardTextFn)(const char* text);
513
 
534
 
514
-    // Optional: override memory allocations (default to posix malloc/realloc/free)
535
+    // Optional: override memory allocations (default to posix malloc/free). MemFreeFn() may be called with a NULL pointer.
515
     void*       (*MemAllocFn)(size_t sz);
536
     void*       (*MemAllocFn)(size_t sz);
516
-    void*       (*MemReallocFn)(void* ptr, size_t sz);
517
     void        (*MemFreeFn)(void* ptr);
537
     void        (*MemFreeFn)(void* ptr);
518
 
538
 
519
     // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese inputs in Windows)
539
     // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese inputs in Windows)
525
 
545
 
526
     ImVec2      MousePos;                   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
546
     ImVec2      MousePos;                   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
527
     bool        MouseDown[5];               // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
547
     bool        MouseDown[5];               // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
528
-    float       MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text.  
548
+    float       MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text. 
549
+    bool        MouseDrawCursor;            // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
529
     bool        KeyCtrl;                    // Keyboard modifier pressed: Control
550
     bool        KeyCtrl;                    // Keyboard modifier pressed: Control
530
     bool        KeyShift;                   // Keyboard modifier pressed: Shift
551
     bool        KeyShift;                   // Keyboard modifier pressed: Shift
531
     bool        KeysDown[512];              // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
552
     bool        KeysDown[512];              // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
637
     struct Pair 
658
     struct Pair 
638
     { 
659
     { 
639
         ImGuiID key; 
660
         ImGuiID key; 
640
-        union { int val_i; float val_f; };        
661
+        union { int val_i; float val_f; void* val_p; };        
641
         Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } 
662
         Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } 
642
         Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } 
663
         Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } 
664
+        Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } 
643
     };
665
     };
644
     ImVector<Pair>    Data;
666
     ImVector<Pair>    Data;
645
 
667
 
646
     // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
668
     // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
647
     // - Set***() functions find pair, insertion on demand if missing.
669
     // - Set***() functions find pair, insertion on demand if missing.
648
-    // - Get***Ptr() functions find pair, insertion on demand if missing, return pointer. Useful if you intend to do Get+Set. 
649
-    //   A typical use case where this is very convenient:
650
-    //      float* pvar = ImGui::GetIntPtr(key); ImGui::SliderInt("var", pvar, 0, 100); some_var += *pvar;
651
     // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
670
     // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
652
     IMGUI_API void    Clear();
671
     IMGUI_API void    Clear();
653
     IMGUI_API int     GetInt(ImGuiID key, int default_val = 0) const;
672
     IMGUI_API int     GetInt(ImGuiID key, int default_val = 0) const;
654
     IMGUI_API void    SetInt(ImGuiID key, int val);
673
     IMGUI_API void    SetInt(ImGuiID key, int val);
655
-    IMGUI_API int*    GetIntPtr(ImGuiID key, int default_val = 0);
656
     IMGUI_API float   GetFloat(ImGuiID key, float default_val = 0.0f) const;
674
     IMGUI_API float   GetFloat(ImGuiID key, float default_val = 0.0f) const;
657
     IMGUI_API void    SetFloat(ImGuiID key, float val);
675
     IMGUI_API void    SetFloat(ImGuiID key, float val);
658
-    IMGUI_API float*  GetFloatPtr(ImGuiID key, float default_val = 0);
659
-    IMGUI_API void    SetAllInt(int val);    // Use on your own storage if you know only integer are being stored.
676
+    IMGUI_API void*   GetVoidPtr(ImGuiID key) const; // default_val is NULL
677
+    IMGUI_API void    SetVoidPtr(ImGuiID key, void* val);
678
+
679
+    // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. 
680
+    // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
681
+    // - A typical use case where this is convenient:
682
+    //      float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
683
+    // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
684
+    IMGUI_API int*    GetIntRef(ImGuiID key, int default_val = 0);
685
+    IMGUI_API float*  GetFloatRef(ImGuiID key, float default_val = 0);
686
+
687
+    // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
688
+    IMGUI_API void    SetAllInt(int val);
660
 };
689
 };
661
 
690
 
662
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
691
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
677
     void InsertChars(int pos, const char* text, const char* text_end = NULL);
706
     void InsertChars(int pos, const char* text, const char* text_end = NULL);
678
 };
707
 };
679
 
708
 
709
+// ImColor() is just a helper that implicity converts to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
710
+// None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either formats.
711
+struct ImColor
712
+{
713
+    ImVec4              Value;
714
+
715
+    ImColor(int r, int g, int b, int a = 255)                       { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
716
+    ImColor(float r, float g, float b, float a = 1.0f)              { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
717
+    ImColor(const ImVec4& col)                                      { Value = col; }
718
+
719
+    operator ImU32() const                                          { return ImGui::ColorConvertFloat4ToU32(Value); }
720
+    operator ImVec4() const                                         { return Value; }
721
+
722
+    static ImColor HSV(float h, float s, float v, float a = 1.0f)   { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
723
+};
724
+
680
 //-----------------------------------------------------------------------------
725
 //-----------------------------------------------------------------------------
681
 // Draw List
726
 // Draw List
682
-// Hold a series of drawing commands. The user provides a renderer for ImDrawList
727
+// Hold a series of drawing commands. The user provides a renderer for ImDrawList.
683
 //-----------------------------------------------------------------------------
728
 //-----------------------------------------------------------------------------
684
 
729
 
730
+// Draw callbacks for advanced uses.
731
+// NB- You most likely DO NOT need to care about draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that)
732
+// Draw callback are useful for example if you want to render a complex 3D scene inside a UI element.
733
+// The expected behavior from your rendering loop is:
734
+//   if (cmd.user_callback != NULL)
735
+//       cmd.user_callback(parent_list, cmd);
736
+//   else
737
+//       RenderTriangles()
738
+// It is up to you to decide if your rendering loop or the callback should be responsible for backup/restoring rendering state.
739
+typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
740
+
741
+// Typically, 1 command = 1 gpu draw call
685
 struct ImDrawCmd
742
 struct ImDrawCmd
686
 {
743
 {
687
-    unsigned int    vtx_count;
688
-    ImVec4          clip_rect;
689
-    ImTextureID     texture_id;     // Copy of user-provided 'TexID' from ImFont or passed to Image*() functions. Ignore if not using images or multiple fonts.
744
+    unsigned int    vtx_count;                  // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array.
745
+    ImVec4          clip_rect;                  // Clipping rectangle (x1, y1, x2, y2)
746
+    ImTextureID     texture_id;                 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
747
+    ImDrawCallback  user_callback;              // If != NULL, call the function instead of rendering the vertices. vtx_count will be 0. clip_rect and texture_id will be set normally.
748
+    void*           user_callback_data;         // The draw callback code can access this.
690
 };
749
 };
691
 
750
 
751
+// Vertex layout
692
 #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
752
 #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
693
-// Default vertex layout
694
 struct ImDrawVert
753
 struct ImDrawVert
695
 {
754
 {
696
     ImVec2  pos;
755
     ImVec2  pos;
705
 #endif
764
 #endif
706
 
765
 
707
 // Draw command list
766
 // Draw command list
708
-// This is the low-level list of polygon that ImGui:: functions are creating. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
709
-// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged.
767
+// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
768
+// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
710
 // If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
769
 // If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
711
 // You can interleave normal ImGui:: calls and adding primitives to the current draw list.
770
 // You can interleave normal ImGui:: calls and adding primitives to the current draw list.
712
 // Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
771
 // Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
713
 struct ImDrawList
772
 struct ImDrawList
714
 {
773
 {
715
     // This is what you have to render
774
     // This is what you have to render
716
-    ImVector<ImDrawCmd>     commands;           // commands
717
-    ImVector<ImDrawVert>    vtx_buffer;         // each command consume ImDrawCmd::vtx_count of those
775
+    ImVector<ImDrawCmd>     commands;           // Commands. Typically 1 command = 1 gpu draw call.
776
+    ImVector<ImDrawVert>    vtx_buffer;         // Vertex buffer. Each command consume ImDrawCmd::vtx_count of those
718
 
777
 
719
     // [Internal to ImGui]
778
     // [Internal to ImGui]
720
-    ImVector<ImVec4>        clip_rect_stack;    // [internal]
721
-    ImVector<ImTextureID>   texture_id_stack;   // [internal] 
722
-    ImDrawVert*             vtx_write;          // [internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
779
+    ImVector<ImVec4>        clip_rect_stack;    // [Internal]
780
+    ImVector<ImTextureID>   texture_id_stack;   // [Internal] 
781
+    ImDrawVert*             vtx_write;          // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
723
 
782
 
724
     ImDrawList() { Clear(); }
783
     ImDrawList() { Clear(); }
725
-
726
     IMGUI_API void  Clear();
784
     IMGUI_API void  Clear();
727
-    IMGUI_API void  SetClipRect(const ImVec4& clip_rect);
728
     IMGUI_API void  PushClipRect(const ImVec4& clip_rect);
785
     IMGUI_API void  PushClipRect(const ImVec4& clip_rect);
729
     IMGUI_API void  PopClipRect();
786
     IMGUI_API void  PopClipRect();
730
-    IMGUI_API void  SetTextureID(const ImTextureID& texture_id);
731
     IMGUI_API void  PushTextureID(const ImTextureID& texture_id);
787
     IMGUI_API void  PushTextureID(const ImTextureID& texture_id);
732
     IMGUI_API void  PopTextureID();
788
     IMGUI_API void  PopTextureID();
733
-    IMGUI_API void  ReserveVertices(unsigned int vtx_count);
734
-    IMGUI_API void  AddVtx(const ImVec2& pos, ImU32 col);
735
-    IMGUI_API void  AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv);
736
-    IMGUI_API void  AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col);
737
 
789
 
738
     // Primitives   
790
     // Primitives   
739
     IMGUI_API void  AddLine(const ImVec2& a, const ImVec2& b, ImU32 col);
791
     IMGUI_API void  AddLine(const ImVec2& a, const ImVec2& b, ImU32 col);
744
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
796
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
745
     IMGUI_API void  AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
797
     IMGUI_API void  AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
746
     IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
798
     IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
747
-    IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col);
799
+    IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
800
+
801
+    // Advanced
802
+    IMGUI_API void  AddCallback(ImDrawCallback callback, void* callback_data);   // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
803
+    IMGUI_API void  AddDrawCmd();               // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
804
+
805
+    // Internal helpers
806
+    IMGUI_API void  ReserveVertices(unsigned int vtx_count);
807
+    IMGUI_API void  AddVtx(const ImVec2& pos, ImU32 col);
808
+    IMGUI_API void  AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv);
809
+    IMGUI_API void  AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col);
810
+    IMGUI_API void  UpdateClipRect();
811
+    IMGUI_API void  UpdateTextureID();
748
 };
812
 };
749
 
813
 
750
 // Load and rasterize multiple TTF fonts into a same texture.
814
 // Load and rasterize multiple TTF fonts into a same texture.
769
     // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
833
     // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
770
     // After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
834
     // After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
771
     // RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
835
     // RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
836
+    // Pitch = Width * BytesPerPixels
772
     IMGUI_API void              GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 1 byte per-pixel
837
     IMGUI_API void              GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 1 byte per-pixel
773
     IMGUI_API void              GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 4 bytes-per-pixel
838
     IMGUI_API void              GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 4 bytes-per-pixel
774
     IMGUI_API void              SetTexID(void* id)  { TexID = id; }
839
     IMGUI_API void              SetTexID(void* id)  { TexID = id; }
795
     ImVector<ImFontAtlasData*>  InputData;          // Internal data
860
     ImVector<ImFontAtlasData*>  InputData;          // Internal data
796
     IMGUI_API bool              Build();            // Build pixels data. This is automatically for you by the GetTexData*** functions.
861
     IMGUI_API bool              Build();            // Build pixels data. This is automatically for you by the GetTexData*** functions.
797
     IMGUI_API void              ClearInputData();   // Clear the input TTF data.
862
     IMGUI_API void              ClearInputData();   // Clear the input TTF data.
863
+    IMGUI_API void              RenderCustomTexData();
798
 };
864
 };
799
 
865
 
800
 // TTF font loading and rendering
866
 // TTF font loading and rendering

+ 5
- 35
src/deps/imgui/stb_textedit.h View File

1
-// stb_textedit.h - v1.5  - public domain - Sean Barrett
1
+// stb_textedit.h - v1.4  - public domain - Sean Barrett
2
 // Development of this library was sponsored by RAD Game Tools
2
 // Development of this library was sponsored by RAD Game Tools
3
 //
3
 //
4
 // This C header file implements the guts of a multi-line text-editing
4
 // This C header file implements the guts of a multi-line text-editing
30
 //
30
 //
31
 // VERSION HISTORY
31
 // VERSION HISTORY
32
 //
32
 //
33
-//   1.5  (2014-09-10) add support for secondary keys for OS X
34
 //   1.4  (2014-08-17) fix signed/unsigned warnings
33
 //   1.4  (2014-08-17) fix signed/unsigned warnings
35
 //   1.3  (2014-06-19) fix mouse clicking to round to nearest char boundary
34
 //   1.3  (2014-06-19) fix mouse clicking to round to nearest char boundary
36
 //   1.2  (2014-05-27) fix some RAD types that had crept into the new code
35
 //   1.2  (2014-05-27) fix some RAD types that had crept into the new code
44
 //
43
 //
45
 //   Ulf Winklemann: move-by-word in 1.1
44
 //   Ulf Winklemann: move-by-word in 1.1
46
 //   Scott Graham: mouse selection bugfix in 1.3
45
 //   Scott Graham: mouse selection bugfix in 1.3
47
-//   Fabian Giesen: secondary key inputs in 1.5
48
 //
46
 //
49
 // USAGE
47
 // USAGE
50
 //
48
 //
144
 //                                 required for WORDLEFT/WORDRIGHT
142
 //                                 required for WORDLEFT/WORDRIGHT
145
 //    STB_TEXTEDIT_K_WORDLEFT    keyboard input to move cursor left one word // e.g. ctrl-LEFT
143
 //    STB_TEXTEDIT_K_WORDLEFT    keyboard input to move cursor left one word // e.g. ctrl-LEFT
146
 //    STB_TEXTEDIT_K_WORDRIGHT   keyboard input to move cursor right one word // e.g. ctrl-RIGHT
144
 //    STB_TEXTEDIT_K_WORDRIGHT   keyboard input to move cursor right one word // e.g. ctrl-RIGHT
147
-//    STB_TEXTEDIT_K_LINESTART2  secondary keyboard input to move cursor to start of line
148
-//    STB_TEXTEDIT_K_LINEEND2    secondary keyboard input to move cursor to end of line
149
-//    STB_TEXTEDIT_K_TEXTSTART2  secondary keyboard input to move cursor to start of text
150
-//    STB_TEXTEDIT_K_TEXTEND2    secondary keyboard input to move cursor to end of text
151
 //
145
 //
152
 // Todo:
146
 // Todo:
153
 //    STB_TEXTEDIT_K_PGUP        keyboard input to move cursor up a page
147
 //    STB_TEXTEDIT_K_PGUP        keyboard input to move cursor up a page
923
          state->has_preferred_x = 0;
917
          state->has_preferred_x = 0;
924
          break;
918
          break;
925
          
919
          
926
-#ifdef STB_TEXTEDIT_K_TEXTSTART2
927
-      case STB_TEXTEDIT_K_TEXTSTART2:
928
-#endif
929
       case STB_TEXTEDIT_K_TEXTSTART:
920
       case STB_TEXTEDIT_K_TEXTSTART:
930
          state->cursor = state->select_start = state->select_end = 0;
921
          state->cursor = state->select_start = state->select_end = 0;
931
          state->has_preferred_x = 0;
922
          state->has_preferred_x = 0;
932
          break;
923
          break;
933
 
924
 
934
-#ifdef STB_TEXTEDIT_K_TEXTEND2
935
-      case STB_TEXTEDIT_K_TEXTEND2:
936
-#endif
937
       case STB_TEXTEDIT_K_TEXTEND:
925
       case STB_TEXTEDIT_K_TEXTEND:
938
          state->cursor = STB_TEXTEDIT_STRINGLEN(str);
926
          state->cursor = STB_TEXTEDIT_STRINGLEN(str);
939
          state->select_start = state->select_end = 0;
927
          state->select_start = state->select_end = 0;
940
          state->has_preferred_x = 0;
928
          state->has_preferred_x = 0;
941
          break;
929
          break;
942
         
930
         
943
-#ifdef STB_TEXTEDIT_K_TEXTSTART2
944
-      case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
945
-#endif
946
       case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT:
931
       case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT:
947
          stb_textedit_prep_selection_at_cursor(state);
932
          stb_textedit_prep_selection_at_cursor(state);
948
          state->cursor = state->select_end = 0;
933
          state->cursor = state->select_end = 0;
949
          state->has_preferred_x = 0;
934
          state->has_preferred_x = 0;
950
          break;
935
          break;
951
 
936
 
952
-#ifdef STB_TEXTEDIT_K_TEXTEND2
953
-      case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT:
954
-#endif
955
       case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT:
937
       case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT:
956
          stb_textedit_prep_selection_at_cursor(state);
938
          stb_textedit_prep_selection_at_cursor(state);
957
          state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str);
939
          state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str);
959
          break;
941
          break;
960
 
942
 
961
 
943
 
962
-#ifdef STB_TEXTEDIT_K_LINESTART2
963
-      case STB_TEXTEDIT_K_LINESTART2:
964
-#endif
965
       case STB_TEXTEDIT_K_LINESTART: {
944
       case STB_TEXTEDIT_K_LINESTART: {
966
          StbFindState find;
945
          StbFindState find;
967
          stb_textedit_clamp(str, state);
946
          stb_textedit_clamp(str, state);
972
          break;
951
          break;
973
       }
952
       }
974
 
953
 
975
-#ifdef STB_TEXTEDIT_K_LINEEND2
976
-      case STB_TEXTEDIT_K_LINEEND2:
977
-#endif
978
       case STB_TEXTEDIT_K_LINEEND: {
954
       case STB_TEXTEDIT_K_LINEEND: {
979
          StbFindState find;
955
          StbFindState find;
980
          stb_textedit_clamp(str, state);
956
          stb_textedit_clamp(str, state);
985
          break;
961
          break;
986
       }
962
       }
987
 
963
 
988
-#ifdef STB_TEXTEDIT_K_LINESTART2
989
-      case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT:
990
-#endif
991
       case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: {
964
       case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: {
992
          StbFindState find;
965
          StbFindState find;
993
          stb_textedit_clamp(str, state);
966
          stb_textedit_clamp(str, state);
998
          break;
971
          break;
999
       }
972
       }
1000
 
973
 
1001
-#ifdef STB_TEXTEDIT_K_LINEEND2
1002
-      case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
1003
-#endif
1004
       case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
974
       case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
1005
          StbFindState find;
975
          StbFindState find;
1006
          stb_textedit_clamp(str, state);
976
          stb_textedit_clamp(str, state);
1038
          int n = state->undo_rec[0].insert_length, i;
1008
          int n = state->undo_rec[0].insert_length, i;
1039
          // delete n characters from all other records
1009
          // delete n characters from all other records
1040
          state->undo_char_point = state->undo_char_point - (short) n;  // vsnet05
1010
          state->undo_char_point = state->undo_char_point - (short) n;  // vsnet05
1041
-         memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
1011
+         memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
1042
          for (i=0; i < state->undo_point; ++i)
1012
          for (i=0; i < state->undo_point; ++i)
1043
             if (state->undo_rec[i].char_storage >= 0)
1013
             if (state->undo_rec[i].char_storage >= 0)
1044
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it
1014
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it
1045
       }
1015
       }
1046
       --state->undo_point;
1016
       --state->undo_point;
1047
-      memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
1017
+      memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0])));
1048
    }
1018
    }
1049
 }
1019
 }
1050
 
1020
 
1062
          int n = state->undo_rec[k].insert_length, i;
1032
          int n = state->undo_rec[k].insert_length, i;
1063
          // delete n characters from all other records
1033
          // delete n characters from all other records
1064
          state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
1034
          state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
1065
-         memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
1035
+         memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
1066
          for (i=state->redo_point; i < k; ++i)
1036
          for (i=state->redo_point; i < k; ++i)
1067
             if (state->undo_rec[i].char_storage >= 0)
1037
             if (state->undo_rec[i].char_storage >= 0)
1068
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
1038
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
1069
       }
1039
       }
1070
       ++state->redo_point;
1040
       ++state->redo_point;
1071
-      memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
1041
+      memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
1072
    }
1042
    }
1073
 }
1043
 }
1074
 
1044
 

+ 104
- 95
src/deps/imgui/stb_truetype.h View File

379
    typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
379
    typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
380
    typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
380
    typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
381
 
381
 
382
+   #ifdef STBTT_STATIC
383
+   #define STBTT_DEF static
384
+   #else
385
+   #define STBTT_DEF extern
386
+   #endif
387
+
382
    // #define your own STBTT_sort() to override this to avoid qsort
388
    // #define your own STBTT_sort() to override this to avoid qsort
383
    #ifndef STBTT_sort
389
    #ifndef STBTT_sort
384
    #include <stdlib.h>
390
    #include <stdlib.h>
448
    float xoff,yoff,xadvance;
454
    float xoff,yoff,xadvance;
449
 } stbtt_bakedchar;
455
 } stbtt_bakedchar;
450
 
456
 
451
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
457
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
452
                                 float pixel_height,                     // height of font in pixels
458
                                 float pixel_height,                     // height of font in pixels
453
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
459
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
454
                                 int first_char, int num_chars,          // characters to bake
460
                                 int first_char, int num_chars,          // characters to bake
464
    float x1,y1,s1,t1; // bottom-right
470
    float x1,y1,s1,t1; // bottom-right
465
 } stbtt_aligned_quad;
471
 } stbtt_aligned_quad;
466
 
472
 
467
-extern void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
473
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
468
                                int char_index,             // character to display
474
                                int char_index,             // character to display
469
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
475
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
470
                                stbtt_aligned_quad *q,      // output: quad to draw
476
                                stbtt_aligned_quad *q,      // output: quad to draw
497
 
503
 
498
 typedef struct stbtt_pack_context stbtt_pack_context;
504
 typedef struct stbtt_pack_context stbtt_pack_context;
499
 typedef struct stbtt_fontinfo stbtt_fontinfo;
505
 typedef struct stbtt_fontinfo stbtt_fontinfo;
506
+#ifndef STB_RECT_PACK_VERSION
507
+typedef struct stbrp_rect stbrp_rect;
508
+#endif
500
 
509
 
501
-extern int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
510
+STBTT_DEF int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
502
 // Initializes a packing context stored in the passed-in stbtt_pack_context.
511
 // Initializes a packing context stored in the passed-in stbtt_pack_context.
503
 // Future calls using this context will pack characters into the bitmap passed
512
 // Future calls using this context will pack characters into the bitmap passed
504
 // in here: a 1-channel bitmap that is weight x height. stride_in_bytes is
513
 // in here: a 1-channel bitmap that is weight x height. stride_in_bytes is
509
 //
518
 //
510
 // Returns 0 on failure, 1 on success.
519
 // Returns 0 on failure, 1 on success.
511
 
520
 
512
-extern void stbtt_PackEnd  (stbtt_pack_context *spc);
521
+STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc);
513
 // Cleans up the packing context and frees all memory.
522
 // Cleans up the packing context and frees all memory.
514
 
523
 
515
 #define STBTT_POINT_SIZE(x)   (-(x))
524
 #define STBTT_POINT_SIZE(x)   (-(x))
516
 
525
 
517
-extern int  stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
526
+STBTT_DEF int  stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
518
                                 int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
527
                                 int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
519
 // Creates character bitmaps from the font_index'th font found in fontdata (use
528
 // Creates character bitmaps from the font_index'th font found in fontdata (use
520
 // font_index=0 if you don't know what that is). It creates num_chars_in_range
529
 // font_index=0 if you don't know what that is). It creates num_chars_in_range
537
    stbtt_packedchar *chardata_for_range; // output
546
    stbtt_packedchar *chardata_for_range; // output
538
 } stbtt_pack_range;
547
 } stbtt_pack_range;
539
 
548
 
540
-extern int  stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
549
+STBTT_DEF int  stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
541
 // Creates character bitmaps from multiple ranges of characters stored in
550
 // Creates character bitmaps from multiple ranges of characters stored in
542
 // ranges. This will usually create a better-packed bitmap than multiple
551
 // ranges. This will usually create a better-packed bitmap than multiple
543
 // calls to stbtt_PackFontRange.
552
 // calls to stbtt_PackFontRange.
544
 
553
 
545
-extern int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
546
-extern int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
554
+STBTT_DEF int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
555
+STBTT_DEF int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
547
 // Those functions are called by stbtt_PackFontRanges(). If you want to
556
 // Those functions are called by stbtt_PackFontRanges(). If you want to
548
 // pack multiple fonts or custom data into a same texture, you may copy
557
 // pack multiple fonts or custom data into a same texture, you may copy
549
 // the contents of stbtt_PackFontRanges() and create a custom version 
558
 // the contents of stbtt_PackFontRanges() and create a custom version 
550
 // using those functions.
559
 // using those functions.
551
 
560
 
552
-extern void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
561
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
553
 // Oversampling a font increases the quality by allowing higher-quality subpixel
562
 // Oversampling a font increases the quality by allowing higher-quality subpixel
554
 // positioning, and is especially valuable at smaller text sizes.
563
 // positioning, and is especially valuable at smaller text sizes.
555
 //
564
 //
561
 // oversampled textures with bilinear filtering. Look at the readme in
570
 // oversampled textures with bilinear filtering. Look at the readme in
562
 // stb/tests/oversample for information about oversampled fonts
571
 // stb/tests/oversample for information about oversampled fonts
563
 
572
 
564
-extern void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph,  // same data as above
573
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph,  // same data as above
565
                                int char_index,             // character to display
574
                                int char_index,             // character to display
566
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
575
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
567
                                stbtt_aligned_quad *q,      // output: quad to draw
576
                                stbtt_aligned_quad *q,      // output: quad to draw
587
 //
596
 //
588
 //
597
 //
589
 
598
 
590
-extern int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
599
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
591
 // Each .ttf/.ttc file may have more than one font. Each font has a sequential
600
 // Each .ttf/.ttc file may have more than one font. Each font has a sequential
592
 // index number starting from 0. Call this function to get the font offset for
601
 // index number starting from 0. Call this function to get the font offset for
593
 // a given index; it returns -1 if the index is out of range. A regular .ttf
602
 // a given index; it returns -1 if the index is out of range. A regular .ttf
611
    int indexToLocFormat;              // format needed to map from glyph index to glyph
620
    int indexToLocFormat;              // format needed to map from glyph index to glyph
612
 } stbtt_fontinfo;
621
 } stbtt_fontinfo;
613
 
622
 
614
-extern int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
623
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
615
 // Given an offset into the file that defines a font, this function builds
624
 // Given an offset into the file that defines a font, this function builds
616
 // the necessary cached info for the rest of the system. You must allocate
625
 // the necessary cached info for the rest of the system. You must allocate
617
 // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
626
 // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
623
 //
632
 //
624
 // CHARACTER TO GLYPH-INDEX CONVERSIOn
633
 // CHARACTER TO GLYPH-INDEX CONVERSIOn
625
 
634
 
626
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
635
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
627
 // If you're going to perform multiple operations on the same character
636
 // If you're going to perform multiple operations on the same character
628
 // and you want a speed-up, call this function with the character you're
637
 // and you want a speed-up, call this function with the character you're
629
 // going to process, then use glyph-based functions instead of the
638
 // going to process, then use glyph-based functions instead of the
635
 // CHARACTER PROPERTIES
644
 // CHARACTER PROPERTIES
636
 //
645
 //
637
 
646
 
638
-extern float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
647
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
639
 // computes a scale factor to produce a font whose "height" is 'pixels' tall.
648
 // computes a scale factor to produce a font whose "height" is 'pixels' tall.
640
 // Height is measured as the distance from the highest ascender to the lowest
649
 // Height is measured as the distance from the highest ascender to the lowest
641
 // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
650
 // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
643
 //       scale = pixels / (ascent - descent)
652
 //       scale = pixels / (ascent - descent)
644
 // so if you prefer to measure height by the ascent only, use a similar calculation.
653
 // so if you prefer to measure height by the ascent only, use a similar calculation.
645
 
654
 
646
-extern float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
655
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
647
 // computes a scale factor to produce a font whose EM size is mapped to
656
 // computes a scale factor to produce a font whose EM size is mapped to
648
 // 'pixels' tall. This is probably what traditional APIs compute, but
657
 // 'pixels' tall. This is probably what traditional APIs compute, but
649
 // I'm not positive.
658
 // I'm not positive.
650
 
659
 
651
-extern void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
660
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
652
 // ascent is the coordinate above the baseline the font extends; descent
661
 // ascent is the coordinate above the baseline the font extends; descent
653
 // is the coordinate below the baseline the font extends (i.e. it is typically negative)
662
 // is the coordinate below the baseline the font extends (i.e. it is typically negative)
654
 // lineGap is the spacing between one row's descent and the next row's ascent...
663
 // lineGap is the spacing between one row's descent and the next row's ascent...
656
 //   these are expressed in unscaled coordinates, so you must multiply by
665
 //   these are expressed in unscaled coordinates, so you must multiply by
657
 //   the scale factor for a given size
666
 //   the scale factor for a given size
658
 
667
 
659
-extern void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
668
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
660
 // the bounding box around all possible characters
669
 // the bounding box around all possible characters
661
 
670
 
662
-extern void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
671
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
663
 // leftSideBearing is the offset from the current horizontal position to the left edge of the character
672
 // leftSideBearing is the offset from the current horizontal position to the left edge of the character
664
 // advanceWidth is the offset from the current horizontal position to the next horizontal position
673
 // advanceWidth is the offset from the current horizontal position to the next horizontal position
665
 //   these are expressed in unscaled coordinates
674
 //   these are expressed in unscaled coordinates
666
 
675
 
667
-extern int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
676
+STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
668
 // an additional amount to add to the 'advance' value between ch1 and ch2
677
 // an additional amount to add to the 'advance' value between ch1 and ch2
669
 
678
 
670
-extern int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
679
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
671
 // Gets the bounding box of the visible part of the glyph, in unscaled coordinates
680
 // Gets the bounding box of the visible part of the glyph, in unscaled coordinates
672
 
681
 
673
-extern void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
674
-extern int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
675
-extern int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
682
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
683
+STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
684
+STBTT_DEF int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
676
 // as above, but takes one or more glyph indices for greater efficiency
685
 // as above, but takes one or more glyph indices for greater efficiency
677
 
686
 
678
 
687
 
700
    } stbtt_vertex;
709
    } stbtt_vertex;
701
 #endif
710
 #endif
702
 
711
 
703
-extern int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
712
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
704
 // returns non-zero if nothing is drawn for this glyph
713
 // returns non-zero if nothing is drawn for this glyph
705
 
714
 
706
-extern int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
707
-extern int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
715
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
716
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
708
 // returns # of vertices and fills *vertices with the pointer to them
717
 // returns # of vertices and fills *vertices with the pointer to them
709
 //   these are expressed in "unscaled" coordinates
718
 //   these are expressed in "unscaled" coordinates
710
 //
719
 //
715
 // draws a quadratic bezier from previous endpoint to
724
 // draws a quadratic bezier from previous endpoint to
716
 // its x,y, using cx,cy as the bezier control point.
725
 // its x,y, using cx,cy as the bezier control point.
717
 
726
 
718
-extern void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
727
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
719
 // frees the data allocated above
728
 // frees the data allocated above
720
 
729
 
721
 //////////////////////////////////////////////////////////////////////////////
730
 //////////////////////////////////////////////////////////////////////////////
723
 // BITMAP RENDERING
732
 // BITMAP RENDERING
724
 //
733
 //
725
 
734
 
726
-extern void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
735
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
727
 // frees the bitmap allocated below
736
 // frees the bitmap allocated below
728
 
737
 
729
-extern unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
738
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
730
 // allocates a large-enough single-channel 8bpp bitmap and renders the
739
 // allocates a large-enough single-channel 8bpp bitmap and renders the
731
 // specified character/glyph at the specified scale into it, with
740
 // specified character/glyph at the specified scale into it, with
732
 // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
741
 // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
735
 //
744
 //
736
 // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
745
 // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
737
 
746
 
738
-extern unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
747
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
739
 // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
748
 // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
740
 // shift for the character
749
 // shift for the character
741
 
750
 
742
-extern void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
751
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
743
 // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
752
 // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
744
 // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
753
 // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
745
 // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
754
 // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
746
 // width and height and positioning info for it first.
755
 // width and height and positioning info for it first.
747
 
756
 
748
-extern void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
757
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
749
 // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
758
 // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
750
 // shift for the character
759
 // shift for the character
751
 
760
 
752
-extern void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
761
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
753
 // get the bbox of the bitmap centered around the glyph origin; so the
762
 // get the bbox of the bitmap centered around the glyph origin; so the
754
 // bitmap width is ix1-ix0, height is iy1-iy0, and location to place
763
 // bitmap width is ix1-ix0, height is iy1-iy0, and location to place
755
 // the bitmap top left is (leftSideBearing*scale,iy0).
764
 // the bitmap top left is (leftSideBearing*scale,iy0).
756
 // (Note that the bitmap uses y-increases-down, but the shape uses
765
 // (Note that the bitmap uses y-increases-down, but the shape uses
757
 // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
766
 // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
758
 
767
 
759
-extern void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
768
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
760
 // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
769
 // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
761
 // shift for the character
770
 // shift for the character
762
 
771
 
763
 // the following functions are equivalent to the above functions, but operate
772
 // the following functions are equivalent to the above functions, but operate
764
 // on glyph indices instead of Unicode codepoints (for efficiency)
773
 // on glyph indices instead of Unicode codepoints (for efficiency)
765
-extern unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
766
-extern unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
767
-extern void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
768
-extern void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
769
-extern void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
770
-extern void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
774
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
775
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
776
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
777
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
778
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
779
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
771
 
780
 
772
 
781
 
773
 // @TODO: don't expose this structure
782
 // @TODO: don't expose this structure
777
    unsigned char *pixels;
786
    unsigned char *pixels;
778
 } stbtt__bitmap;
787
 } stbtt__bitmap;
779
 
788
 
780
-extern void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
789
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
781
 
790
 
782
 //////////////////////////////////////////////////////////////////////////////
791
 //////////////////////////////////////////////////////////////////////////////
783
 //
792
 //
801
 //             You have to have called stbtt_InitFont() first.
810
 //             You have to have called stbtt_InitFont() first.
802
 
811
 
803
 
812
 
804
-extern int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
813
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
805
 // returns the offset (not index) of the font that matches, or -1 if none
814
 // returns the offset (not index) of the font that matches, or -1 if none
806
 //   if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
815
 //   if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
807
 //   if you use any other flag, use a font name like "Arial"; this checks
816
 //   if you use any other flag, use a font name like "Arial"; this checks
812
 #define STBTT_MACSTYLE_UNDERSCORE   4
821
 #define STBTT_MACSTYLE_UNDERSCORE   4
813
 #define STBTT_MACSTYLE_NONE         8   // <= not same as 0, this makes us check the bitfield is 0
822
 #define STBTT_MACSTYLE_NONE         8   // <= not same as 0, this makes us check the bitfield is 0
814
 
823
 
815
-extern int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
824
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
816
 // returns 1/0 whether the first string interpreted as utf8 is identical to
825
 // returns 1/0 whether the first string interpreted as utf8 is identical to
817
 // the second string interpreted as big-endian utf16... useful for strings from next func
826
 // the second string interpreted as big-endian utf16... useful for strings from next func
818
 
827
 
819
-extern const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
828
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
820
 // returns the string (which may be big-endian double byte, e.g. for unicode)
829
 // returns the string (which may be big-endian double byte, e.g. for unicode)
821
 // and puts the length in bytes in *length.
830
 // and puts the length in bytes in *length.
822
 //
831
 //
915
 
924
 
916
 #else
925
 #else
917
 
926
 
918
-   stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
919
-   stbtt_int16 ttSHORT(const stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
920
-   stbtt_uint32 ttULONG(const stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
921
-   stbtt_int32 ttLONG(const stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
927
+   static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
928
+   static stbtt_int16 ttSHORT(const stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
929
+   static stbtt_uint32 ttULONG(const stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
930
+   static stbtt_int32 ttLONG(const stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
922
 
931
 
923
 #endif
932
 #endif
924
 
933
 
949
    return 0;
958
    return 0;
950
 }
959
 }
951
 
960
 
952
-int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
961
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
953
 {
962
 {
954
    // if it's just a font, there's only one valid index
963
    // if it's just a font, there's only one valid index
955
    if (stbtt__isfont(font_collection))
964
    if (stbtt__isfont(font_collection))
968
    return -1;
977
    return -1;
969
 }
978
 }
970
 
979
 
971
-int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
980
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
972
 {
981
 {
973
    stbtt_uint8 *data = (stbtt_uint8 *) data2;
982
    stbtt_uint8 *data = (stbtt_uint8 *) data2;
974
    stbtt_uint32 cmap, t;
983
    stbtt_uint32 cmap, t;
1025
    return 1;
1034
    return 1;
1026
 }
1035
 }
1027
 
1036
 
1028
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
1037
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
1029
 {
1038
 {
1030
    stbtt_uint8 *data = info->data;
1039
    stbtt_uint8 *data = info->data;
1031
    stbtt_uint32 index_map = info->index_map;
1040
    stbtt_uint32 index_map = info->index_map;
1117
    return 0;
1126
    return 0;
1118
 }
1127
 }
1119
 
1128
 
1120
-int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
1129
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
1121
 {
1130
 {
1122
    return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
1131
    return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
1123
 }
1132
 }
1149
    return g1==g2 ? -1 : g1; // if length is 0, return -1
1158
    return g1==g2 ? -1 : g1; // if length is 0, return -1
1150
 }
1159
 }
1151
 
1160
 
1152
-int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
1161
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
1153
 {
1162
 {
1154
    int g = stbtt__GetGlyfOffset(info, glyph_index);
1163
    int g = stbtt__GetGlyfOffset(info, glyph_index);
1155
    if (g < 0) return 0;
1164
    if (g < 0) return 0;
1161
    return 1;
1170
    return 1;
1162
 }
1171
 }
1163
 
1172
 
1164
-int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
1173
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
1165
 {
1174
 {
1166
    return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
1175
    return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
1167
 }
1176
 }
1168
 
1177
 
1169
-int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
1178
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
1170
 {
1179
 {
1171
    stbtt_int16 numberOfContours;
1180
    stbtt_int16 numberOfContours;
1172
    int g = stbtt__GetGlyfOffset(info, glyph_index);
1181
    int g = stbtt__GetGlyfOffset(info, glyph_index);
1191
    return num_vertices;
1200
    return num_vertices;
1192
 }
1201
 }
1193
 
1202
 
1194
-int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
1203
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
1195
 {
1204
 {
1196
    stbtt_int16 numberOfContours;
1205
    stbtt_int16 numberOfContours;
1197
    stbtt_uint8 *endPtsOfContours;
1206
    stbtt_uint8 *endPtsOfContours;
1417
    return num_vertices;
1426
    return num_vertices;
1418
 }
1427
 }
1419
 
1428
 
1420
-void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
1429
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
1421
 {
1430
 {
1422
    stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
1431
    stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
1423
    if (glyph_index < numOfLongHorMetrics) {
1432
    if (glyph_index < numOfLongHorMetrics) {
1429
    }
1438
    }
1430
 }
1439
 }
1431
 
1440
 
1432
-int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
1441
+STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
1433
 {
1442
 {
1434
    stbtt_uint8 *data = info->data + info->kern;
1443
    stbtt_uint8 *data = info->data + info->kern;
1435
    stbtt_uint32 needle, straw;
1444
    stbtt_uint32 needle, straw;
1459
    return 0;
1468
    return 0;
1460
 }
1469
 }
1461
 
1470
 
1462
-int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
1471
+STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
1463
 {
1472
 {
1464
    if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs
1473
    if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs
1465
       return 0;
1474
       return 0;
1466
    return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
1475
    return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
1467
 }
1476
 }
1468
 
1477
 
1469
-void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
1478
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
1470
 {
1479
 {
1471
    stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
1480
    stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
1472
 }
1481
 }
1473
 
1482
 
1474
-void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
1483
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
1475
 {
1484
 {
1476
    if (ascent ) *ascent  = ttSHORT(info->data+info->hhea + 4);
1485
    if (ascent ) *ascent  = ttSHORT(info->data+info->hhea + 4);
1477
    if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
1486
    if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
1478
    if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
1487
    if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
1479
 }
1488
 }
1480
 
1489
 
1481
-void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
1490
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
1482
 {
1491
 {
1483
    *x0 = ttSHORT(info->data + info->head + 36);
1492
    *x0 = ttSHORT(info->data + info->head + 36);
1484
    *y0 = ttSHORT(info->data + info->head + 38);
1493
    *y0 = ttSHORT(info->data + info->head + 38);
1486
    *y1 = ttSHORT(info->data + info->head + 42);
1495
    *y1 = ttSHORT(info->data + info->head + 42);
1487
 }
1496
 }
1488
 
1497
 
1489
-float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
1498
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
1490
 {
1499
 {
1491
    int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
1500
    int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
1492
    return (float) height / fheight;
1501
    return (float) height / fheight;
1493
 }
1502
 }
1494
 
1503
 
1495
-float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
1504
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
1496
 {
1505
 {
1497
    int unitsPerEm = ttUSHORT(info->data + info->head + 18);
1506
    int unitsPerEm = ttUSHORT(info->data + info->head + 18);
1498
    return pixels / unitsPerEm;
1507
    return pixels / unitsPerEm;
1499
 }
1508
 }
1500
 
1509
 
1501
-void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
1510
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
1502
 {
1511
 {
1503
    STBTT_free(v, info->userdata);
1512
    STBTT_free(v, info->userdata);
1504
 }
1513
 }
1508
 // antialiasing software rasterizer
1517
 // antialiasing software rasterizer
1509
 //
1518
 //
1510
 
1519
 
1511
-void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1520
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1512
 {
1521
 {
1513
    int x0,y0,x1,y1;
1522
    int x0,y0,x1,y1;
1514
    if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
1523
    if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
1526
    }
1535
    }
1527
 }
1536
 }
1528
 
1537
 
1529
-void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1538
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1530
 {
1539
 {
1531
    stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
1540
    stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
1532
 }
1541
 }
1533
 
1542
 
1534
-void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1543
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1535
 {
1544
 {
1536
    stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
1545
    stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
1537
 }
1546
 }
1538
 
1547
 
1539
-void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1548
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1540
 {
1549
 {
1541
    stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
1550
    stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
1542
 }
1551
 }
1817
 }
1826
 }
1818
 
1827
 
1819
 // returns number of contours
1828
 // returns number of contours
1820
-stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
1829
+static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
1821
 {
1830
 {
1822
    stbtt__point *points=0;
1831
    stbtt__point *points=0;
1823
    int num_points=0;
1832
    int num_points=0;
1886
    return NULL;
1895
    return NULL;
1887
 }
1896
 }
1888
 
1897
 
1889
-void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
1898
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
1890
 {
1899
 {
1891
    float scale = scale_x > scale_y ? scale_y : scale_x;
1900
    float scale = scale_x > scale_y ? scale_y : scale_x;
1892
    int winding_count, *winding_lengths;
1901
    int winding_count, *winding_lengths;
1898
    }
1907
    }
1899
 }
1908
 }
1900
 
1909
 
1901
-void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
1910
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
1902
 {
1911
 {
1903
    STBTT_free(bitmap, userdata);
1912
    STBTT_free(bitmap, userdata);
1904
 }
1913
 }
1905
 
1914
 
1906
-unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1915
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1907
 {
1916
 {
1908
    int ix0,iy0,ix1,iy1;
1917
    int ix0,iy0,ix1,iy1;
1909
    stbtt__bitmap gbm;
1918
    stbtt__bitmap gbm;
1940
    return gbm.pixels;
1949
    return gbm.pixels;
1941
 }   
1950
 }   
1942
 
1951
 
1943
-unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1952
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1944
 {
1953
 {
1945
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
1954
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
1946
 }
1955
 }
1947
 
1956
 
1948
-void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
1957
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
1949
 {
1958
 {
1950
    int ix0,iy0;
1959
    int ix0,iy0;
1951
    stbtt_vertex *vertices;
1960
    stbtt_vertex *vertices;
1964
    STBTT_free(vertices, info->userdata);
1973
    STBTT_free(vertices, info->userdata);
1965
 }
1974
 }
1966
 
1975
 
1967
-void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
1976
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
1968
 {
1977
 {
1969
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
1978
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
1970
 }
1979
 }
1971
 
1980
 
1972
-unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1981
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1973
 {
1982
 {
1974
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
1983
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
1975
 }   
1984
 }   
1976
 
1985
 
1977
-void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
1986
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
1978
 {
1987
 {
1979
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
1988
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
1980
 }
1989
 }
1981
 
1990
 
1982
-unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1991
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1983
 {
1992
 {
1984
    return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
1993
    return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
1985
 }   
1994
 }   
1986
 
1995
 
1987
-void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
1996
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
1988
 {
1997
 {
1989
    stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
1998
    stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
1990
 }
1999
 }
1995
 //
2004
 //
1996
 // This is SUPER-CRAPPY packing to keep source code small
2005
 // This is SUPER-CRAPPY packing to keep source code small
1997
 
2006
 
1998
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
2007
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
1999
                                 float pixel_height,                     // height of font in pixels
2008
                                 float pixel_height,                     // height of font in pixels
2000
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
2009
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
2001
                                 int first_char, int num_chars,          // characters to bake
2010
                                 int first_char, int num_chars,          // characters to bake
2040
    return bottom_y;
2049
    return bottom_y;
2041
 }
2050
 }
2042
 
2051
 
2043
-void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
2052
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
2044
 {
2053
 {
2045
    float d3d_bias = opengl_fillrule ? 0 : -0.5f;
2054
    float d3d_bias = opengl_fillrule ? 0 : -0.5f;
2046
    float ipw = 1.0f / pw, iph = 1.0f / ph;
2055
    float ipw = 1.0f / pw, iph = 1.0f / ph;
2097
    unsigned char x;
2106
    unsigned char x;
2098
 } stbrp_node;
2107
 } stbrp_node;
2099
 
2108
 
2100
-typedef struct
2109
+struct stbrp_rect
2101
 {
2110
 {
2102
    stbrp_coord x,y;
2111
    stbrp_coord x,y;
2103
    int id,w,h,was_packed;
2112
    int id,w,h,was_packed;
2104
-} stbrp_rect;
2113
+};
2105
 
2114
 
2106
 static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
2115
 static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
2107
 {
2116
 {
2143
 // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
2152
 // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
2144
 // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
2153
 // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
2145
 
2154
 
2146
-int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
2155
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
2147
 {
2156
 {
2148
    stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context)            ,alloc_context);
2157
    stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context)            ,alloc_context);
2149
    int            num_nodes = pw - padding;
2158
    int            num_nodes = pw - padding;
2174
    return 1;
2183
    return 1;
2175
 }
2184
 }
2176
 
2185
 
2177
-void stbtt_PackEnd  (stbtt_pack_context *spc)
2186
+STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc)
2178
 {
2187
 {
2179
    STBTT_free(spc->nodes    , spc->user_allocator_context);
2188
    STBTT_free(spc->nodes    , spc->user_allocator_context);
2180
    STBTT_free(spc->pack_info, spc->user_allocator_context);
2189
    STBTT_free(spc->pack_info, spc->user_allocator_context);
2181
 }
2190
 }
2182
 
2191
 
2183
-void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
2192
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
2184
 {
2193
 {
2185
    STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
2194
    STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
2186
    STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
2195
    STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
2313
 }
2322
 }
2314
 
2323
 
2315
 // rects array must be big enough to accommodate all characters in the given ranges
2324
 // rects array must be big enough to accommodate all characters in the given ranges
2316
-int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2325
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2317
 {
2326
 {
2318
    int i,j,k;
2327
    int i,j,k;
2319
 
2328
 
2343
 }
2352
 }
2344
 
2353
 
2345
 // rects array must be big enough to accommodate all characters in the given ranges
2354
 // rects array must be big enough to accommodate all characters in the given ranges
2346
-int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2355
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2347
 {
2356
 {
2348
    float recip_h = 1.0f / spc->h_oversample;
2357
    float recip_h = 1.0f / spc->h_oversample;
2349
    float recip_v = 1.0f / spc->v_oversample;
2358
    float recip_v = 1.0f / spc->v_oversample;
2413
    return return_value;
2422
    return return_value;
2414
 }
2423
 }
2415
 
2424
 
2416
-int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
2425
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
2417
 {
2426
 {
2418
    stbtt_fontinfo info;
2427
    stbtt_fontinfo info;
2419
    int i,j,n, return_value = 1;
2428
    int i,j,n, return_value = 1;
2447
    return return_value;
2456
    return return_value;
2448
 }
2457
 }
2449
 
2458
 
2450
-int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
2459
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
2451
             int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
2460
             int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
2452
 {
2461
 {
2453
    stbtt_pack_range range;
2462
    stbtt_pack_range range;
2458
    return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
2467
    return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
2459
 }
2468
 }
2460
 
2469
 
2461
-void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
2470
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
2462
 {
2471
 {
2463
    float ipw = 1.0f / pw, iph = 1.0f / ph;
2472
    float ipw = 1.0f / pw, iph = 1.0f / ph;
2464
    stbtt_packedchar *b = chardata + char_index;
2473
    stbtt_packedchar *b = chardata + char_index;
2531
    return i;
2540
    return i;
2532
 }
2541
 }
2533
 
2542
 
2534
-int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) 
2543
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) 
2535
 {
2544
 {
2536
    return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2);
2545
    return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2);
2537
 }
2546
 }
2538
 
2547
 
2539
 // returns results in whatever encoding you request... but note that 2-byte encodings
2548
 // returns results in whatever encoding you request... but note that 2-byte encodings
2540
 // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
2549
 // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
2541
-const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
2550
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
2542
 {
2551
 {
2543
    stbtt_int32 i,count,stringOffset;
2552
    stbtt_int32 i,count,stringOffset;
2544
    stbtt_uint8 *fc = font->data;
2553
    stbtt_uint8 *fc = font->data;
2635
    return 0;
2644
    return 0;
2636
 }
2645
 }
2637
 
2646
 
2638
-int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
2647
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
2639
 {
2648
 {
2640
    stbtt_int32 i;
2649
    stbtt_int32 i;
2641
    for (i=0;;++i) {
2650
    for (i=0;;++i) {

+ 3
- 4
src/deps/stb/stb.cpp View File

18
 #define STBRP_ASSERT assert
18
 #define STBRP_ASSERT assert
19
 #include "stb/stb_rect_pack.h"
19
 #include "stb/stb_rect_pack.h"
20
 
20
 
21
-//! \TODO bring back when imgui allows it
22
-//#define STB_TRUETYPE_IMPLEMENTATION
23
-//#define STBTT_assert(x) assert(x)
24
-//#include "stb/stb_truetype.h"
21
+#define STB_TRUETYPE_IMPLEMENTATION
22
+#define STBTT_assert(x) assert(x)
23
+#include "stb/stb_truetype.h"
25
 
24
 

Loading…
Cancel
Save