gosu 1.5.0 → 2.0.0.pre6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +233 -0
  3. data/dependencies/SDL/include/SDL_assert.h +320 -0
  4. data/dependencies/SDL/include/SDL_atomic.h +414 -0
  5. data/dependencies/SDL/include/SDL_audio.h +1500 -0
  6. data/dependencies/SDL/include/{SDL3/SDL_bits.h → SDL_bits.h} +27 -47
  7. data/dependencies/SDL/include/{SDL3/SDL_blendmode.h → SDL_blendmode.h} +55 -59
  8. data/dependencies/SDL/include/SDL_clipboard.h +141 -0
  9. data/dependencies/SDL/include/SDL_config.h +331 -0
  10. data/dependencies/SDL/include/SDL_cpuinfo.h +594 -0
  11. data/dependencies/SDL/include/{SDL3/SDL_egl.h → SDL_egl.h} +8 -11
  12. data/dependencies/SDL/include/SDL_endian.h +348 -0
  13. data/dependencies/SDL/include/SDL_error.h +163 -0
  14. data/dependencies/SDL/include/SDL_events.h +1166 -0
  15. data/dependencies/SDL/include/SDL_filesystem.h +149 -0
  16. data/dependencies/SDL/include/SDL_gamecontroller.h +1074 -0
  17. data/dependencies/SDL/include/SDL_gesture.h +117 -0
  18. data/dependencies/SDL/include/SDL_guid.h +100 -0
  19. data/dependencies/SDL/include/SDL_haptic.h +1341 -0
  20. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  21. data/dependencies/SDL/include/SDL_hints.h +2613 -0
  22. data/dependencies/SDL/include/SDL_joystick.h +1069 -0
  23. data/dependencies/SDL/include/SDL_keyboard.h +353 -0
  24. data/dependencies/SDL/include/SDL_keycode.h +358 -0
  25. data/dependencies/SDL/include/SDL_loadso.h +115 -0
  26. data/dependencies/SDL/include/{SDL3/SDL_locale.h → SDL_locale.h} +24 -40
  27. data/dependencies/SDL/include/SDL_log.h +404 -0
  28. data/dependencies/SDL/include/SDL_main.h +282 -0
  29. data/dependencies/SDL/include/{SDL3/SDL_messagebox.h → SDL_messagebox.h} +48 -85
  30. data/dependencies/SDL/include/{SDL3/SDL_metal.h → SDL_metal.h} +29 -29
  31. data/dependencies/SDL/include/{SDL3/SDL_misc.h → SDL_misc.h} +12 -13
  32. data/dependencies/SDL/include/SDL_mouse.h +464 -0
  33. data/dependencies/SDL/include/SDL_mutex.h +545 -0
  34. data/dependencies/SDL/include/SDL_name.h +33 -0
  35. data/dependencies/SDL/include/{SDL3/SDL_opengl.h → SDL_opengl.h} +252 -1221
  36. data/dependencies/SDL/include/{SDL3/SDL_opengles.h → SDL_opengles.h} +7 -6
  37. data/dependencies/SDL/include/{SDL3/SDL_opengles2.h → SDL_opengles2.h} +11 -10
  38. data/dependencies/SDL/include/SDL_pixels.h +644 -0
  39. data/dependencies/SDL/include/SDL_platform.h +261 -0
  40. data/dependencies/SDL/include/{SDL3/SDL_power.h → SDL_power.h} +19 -40
  41. data/dependencies/SDL/include/SDL_quit.h +58 -0
  42. data/dependencies/SDL/include/SDL_rect.h +376 -0
  43. data/dependencies/SDL/include/SDL_render.h +1924 -0
  44. data/dependencies/SDL/include/SDL_revision.h +7 -0
  45. data/dependencies/SDL/include/SDL_rwops.h +841 -0
  46. data/dependencies/SDL/include/{SDL3/SDL_scancode.h → SDL_scancode.h} +68 -60
  47. data/dependencies/SDL/include/SDL_sensor.h +322 -0
  48. data/dependencies/SDL/include/SDL_shape.h +155 -0
  49. data/dependencies/SDL/include/SDL_stdinc.h +838 -0
  50. data/dependencies/SDL/include/SDL_surface.h +997 -0
  51. data/dependencies/SDL/include/SDL_system.h +623 -0
  52. data/dependencies/SDL/include/SDL_syswm.h +386 -0
  53. data/dependencies/SDL/include/{SDL3/SDL_test.h → SDL_test.h} +22 -16
  54. data/dependencies/SDL/include/{SDL3/SDL_test_assert.h → SDL_test_assert.h} +34 -27
  55. data/dependencies/SDL/include/{SDL3/SDL_test_common.h → SDL_test_common.h} +52 -109
  56. data/dependencies/SDL/include/{SDL3/SDL_test_compare.h → SDL_test_compare.h} +14 -22
  57. data/dependencies/SDL/include/{SDL3/SDL_test_crc32.h → SDL_test_crc32.h} +30 -27
  58. data/dependencies/SDL/include/{SDL3/SDL_test_font.h → SDL_test_font.h} +49 -50
  59. data/dependencies/SDL/include/{SDL3/SDL_test_fuzzer.h → SDL_test_fuzzer.h} +79 -64
  60. data/dependencies/SDL/include/{SDL3/SDL_test_harness.h → SDL_test_harness.h} +30 -47
  61. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  62. data/dependencies/SDL/include/{SDL3/SDL_platform.h → SDL_test_log.h} +26 -25
  63. data/dependencies/SDL/include/{SDL3/SDL_test_md5.h → SDL_test_md5.h} +28 -21
  64. data/dependencies/SDL/include/{SDL3/SDL_test_memory.h → SDL_test_memory.h} +16 -19
  65. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  66. data/dependencies/SDL/include/SDL_thread.h +464 -0
  67. data/dependencies/SDL/include/SDL_timer.h +222 -0
  68. data/dependencies/SDL/include/SDL_touch.h +150 -0
  69. data/dependencies/SDL/include/{SDL3/SDL_copying.h → SDL_types.h} +9 -2
  70. data/dependencies/SDL/include/SDL_version.h +204 -0
  71. data/dependencies/SDL/include/SDL_video.h +2178 -0
  72. data/dependencies/SDL/include/SDL_vulkan.h +215 -0
  73. data/dependencies/SDL/include/begin_code.h +187 -0
  74. data/dependencies/SDL/include/{SDL3/SDL_close_code.h → close_code.h} +6 -7
  75. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  76. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  77. data/dependencies/SDL_sound/SDL_sound.c +215 -136
  78. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  79. data/dependencies/SDL_sound/SDL_sound_aiff.c +54 -55
  80. data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
  81. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +41 -24
  82. data/dependencies/SDL_sound/SDL_sound_flac.c +12 -32
  83. data/dependencies/SDL_sound/SDL_sound_internal.h +48 -33
  84. data/dependencies/SDL_sound/SDL_sound_modplug.c +29 -21
  85. data/dependencies/SDL_sound/SDL_sound_mp3.c +13 -35
  86. data/dependencies/SDL_sound/SDL_sound_raw.c +15 -14
  87. data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
  88. data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
  89. data/dependencies/SDL_sound/SDL_sound_vorbis.c +25 -34
  90. data/dependencies/SDL_sound/SDL_sound_wav.c +82 -86
  91. data/dependencies/SDL_sound/dr_flac.h +1281 -1845
  92. data/dependencies/SDL_sound/dr_mp3.h +617 -1035
  93. data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
  94. data/dependencies/SDL_sound/libmodplug/libmodplug.h +4 -5
  95. data/dependencies/SDL_sound/libmodplug/load_ams.c +3 -6
  96. data/dependencies/SDL_sound/libmodplug/load_dsm.c +1 -2
  97. data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
  98. data/dependencies/SDL_sound/libmodplug/modplug.h +1 -2
  99. data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
  100. data/dependencies/SDL_sound/libmodplug/sndfile.c +0 -3
  101. data/dependencies/SDL_sound/libmodplug/sndmix.c +3 -7
  102. data/dependencies/SDL_sound/stb_vorbis.h +343 -397
  103. data/dependencies/mojoAL/AL/alc.h +2 -2
  104. data/dependencies/mojoAL/mojoal.c +1878 -2113
  105. data/dependencies/stb/stb_image.h +1381 -1192
  106. data/dependencies/stb/stb_image_write.h +129 -329
  107. data/dependencies/stb/stb_truetype.h +60 -304
  108. data/dependencies/utf8proc/utf8proc.c +75 -133
  109. data/dependencies/utf8proc/utf8proc.h +50 -131
  110. data/dependencies/utf8proc/utf8proc_data.h +15658 -16213
  111. data/ext/gosu-ffi/extconf.rb +28 -11
  112. data/ext/gosu-ffi/gosu-ffi.def +0 -3
  113. data/ffi/Gosu.cpp +29 -52
  114. data/ffi/Gosu.h +4 -4
  115. data/ffi/Gosu_Color.cpp +36 -80
  116. data/ffi/Gosu_FFI_internal.h +13 -12
  117. data/ffi/Gosu_Font.cpp +11 -16
  118. data/ffi/Gosu_Font.h +4 -4
  119. data/ffi/Gosu_Image.cpp +36 -69
  120. data/ffi/Gosu_Image.h +5 -16
  121. data/include/Gosu/Bitmap.hpp +1 -1
  122. data/include/Gosu/Color.hpp +4 -5
  123. data/include/Gosu/Graphics.hpp +0 -2
  124. data/include/Gosu/Image.hpp +1 -1
  125. data/include/Gosu/Math.hpp +5 -5
  126. data/include/Gosu/Utility.hpp +1 -27
  127. data/include/Gosu/Version.hpp +2 -2
  128. data/lib/SDL2.dll +0 -0
  129. data/lib/gosu/channel.rb +0 -1
  130. data/lib/gosu/color.rb +13 -36
  131. data/lib/gosu/compat.rb +14 -106
  132. data/lib/gosu/constants.rb +24 -24
  133. data/lib/gosu/ffi.rb +13 -24
  134. data/lib/gosu/font.rb +13 -19
  135. data/lib/gosu/gosu.rb +61 -101
  136. data/lib/gosu/image.rb +34 -72
  137. data/lib/gosu/sample.rb +0 -1
  138. data/lib/gosu/song.rb +0 -1
  139. data/lib/gosu/text_input.rb +1 -15
  140. data/lib/gosu/window.rb +10 -31
  141. data/lib64/SDL2.dll +0 -0
  142. data/rdoc/gosu.rb +0 -2
  143. data/src/Audio.cpp +16 -22
  144. data/src/AudioFileSDLSound.cpp +5 -5
  145. data/src/BinPacker.cpp +4 -5
  146. data/src/Bitmap.cpp +9 -16
  147. data/src/Buffer.cpp +14 -5
  148. data/src/ClipRectStack.hpp +83 -17
  149. data/src/Directories.cpp +1 -1
  150. data/src/DrawOp.hpp +17 -14
  151. data/src/DrawOpQueue.hpp +31 -25
  152. data/src/Font.cpp +1 -1
  153. data/src/GosuGLView.cpp +7 -1
  154. data/src/Graphics.cpp +25 -32
  155. data/src/GraphicsImpl.hpp +24 -0
  156. data/src/Image.cpp +2 -2
  157. data/src/Input.cpp +70 -66
  158. data/src/Macro.cpp +26 -43
  159. data/src/Macro.hpp +16 -22
  160. data/src/Math.cpp +7 -20
  161. data/src/OffScreenTarget.cpp +10 -3
  162. data/src/OpenGLContext.cpp +8 -7
  163. data/src/OpenGLContext.hpp +2 -2
  164. data/src/RenderState.hpp +54 -30
  165. data/src/Resolution.cpp +38 -48
  166. data/src/TexChunk.cpp +2 -2
  167. data/src/TextInput.cpp +9 -9
  168. data/src/Texture.cpp +1 -1
  169. data/src/TiledDrawable.cpp +7 -6
  170. data/src/TrueTypeFontUnix.cpp +9 -12
  171. data/src/Utility.cpp +26 -39
  172. data/src/UtilityWin.cpp +2 -6
  173. data/src/Window.cpp +34 -54
  174. metadata +93 -99
  175. data/dependencies/SDL/include/SDL3/SDL.h +0 -91
  176. data/dependencies/SDL/include/SDL3/SDL_assert.h +0 -710
  177. data/dependencies/SDL/include/SDL3/SDL_asyncio.h +0 -550
  178. data/dependencies/SDL/include/SDL3/SDL_atomic.h +0 -692
  179. data/dependencies/SDL/include/SDL3/SDL_audio.h +0 -2382
  180. data/dependencies/SDL/include/SDL3/SDL_begin_code.h +0 -553
  181. data/dependencies/SDL/include/SDL3/SDL_camera.h +0 -535
  182. data/dependencies/SDL/include/SDL3/SDL_clipboard.h +0 -331
  183. data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +0 -374
  184. data/dependencies/SDL/include/SDL3/SDL_dialog.h +0 -343
  185. data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +0 -234
  186. data/dependencies/SDL/include/SDL3/SDL_endian.h +0 -645
  187. data/dependencies/SDL/include/SDL3/SDL_error.h +0 -226
  188. data/dependencies/SDL/include/SDL3/SDL_events.h +0 -1651
  189. data/dependencies/SDL/include/SDL3/SDL_filesystem.h +0 -537
  190. data/dependencies/SDL/include/SDL3/SDL_gamepad.h +0 -1657
  191. data/dependencies/SDL/include/SDL3/SDL_gpu.h +0 -4637
  192. data/dependencies/SDL/include/SDL3/SDL_guid.h +0 -106
  193. data/dependencies/SDL/include/SDL3/SDL_haptic.h +0 -1461
  194. data/dependencies/SDL/include/SDL3/SDL_hidapi.h +0 -571
  195. data/dependencies/SDL/include/SDL3/SDL_hints.h +0 -5041
  196. data/dependencies/SDL/include/SDL3/SDL_init.h +0 -508
  197. data/dependencies/SDL/include/SDL3/SDL_intrin.h +0 -410
  198. data/dependencies/SDL/include/SDL3/SDL_iostream.h +0 -1379
  199. data/dependencies/SDL/include/SDL3/SDL_joystick.h +0 -1385
  200. data/dependencies/SDL/include/SDL3/SDL_keyboard.h +0 -615
  201. data/dependencies/SDL/include/SDL3/SDL_keycode.h +0 -348
  202. data/dependencies/SDL/include/SDL3/SDL_loadso.h +0 -145
  203. data/dependencies/SDL/include/SDL3/SDL_log.h +0 -541
  204. data/dependencies/SDL/include/SDL3/SDL_main.h +0 -704
  205. data/dependencies/SDL/include/SDL3/SDL_main_impl.h +0 -149
  206. data/dependencies/SDL/include/SDL3/SDL_mouse.h +0 -813
  207. data/dependencies/SDL/include/SDL3/SDL_mutex.h +0 -1117
  208. data/dependencies/SDL/include/SDL3/SDL_oldnames.h +0 -1339
  209. data/dependencies/SDL/include/SDL3/SDL_pen.h +0 -198
  210. data/dependencies/SDL/include/SDL3/SDL_pixels.h +0 -1441
  211. data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +0 -497
  212. data/dependencies/SDL/include/SDL3/SDL_process.h +0 -441
  213. data/dependencies/SDL/include/SDL3/SDL_properties.h +0 -572
  214. data/dependencies/SDL/include/SDL3/SDL_rect.h +0 -528
  215. data/dependencies/SDL/include/SDL3/SDL_render.h +0 -3034
  216. data/dependencies/SDL/include/SDL3/SDL_revision.h +0 -56
  217. data/dependencies/SDL/include/SDL3/SDL_sensor.h +0 -321
  218. data/dependencies/SDL/include/SDL3/SDL_stdinc.h +0 -6186
  219. data/dependencies/SDL/include/SDL3/SDL_storage.h +0 -686
  220. data/dependencies/SDL/include/SDL3/SDL_surface.h +0 -1769
  221. data/dependencies/SDL/include/SDL3/SDL_system.h +0 -840
  222. data/dependencies/SDL/include/SDL3/SDL_test_log.h +0 -83
  223. data/dependencies/SDL/include/SDL3/SDL_thread.h +0 -602
  224. data/dependencies/SDL/include/SDL3/SDL_time.h +0 -249
  225. data/dependencies/SDL/include/SDL3/SDL_timer.h +0 -454
  226. data/dependencies/SDL/include/SDL3/SDL_touch.h +0 -184
  227. data/dependencies/SDL/include/SDL3/SDL_tray.h +0 -544
  228. data/dependencies/SDL/include/SDL3/SDL_version.h +0 -198
  229. data/dependencies/SDL/include/SDL3/SDL_video.h +0 -3497
  230. data/dependencies/SDL/include/SDL3/SDL_vulkan.h +0 -287
  231. data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
  232. data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
  233. data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +0 -755
  234. data/lib/SDL3.dll +0 -0
  235. data/lib64/SDL3.dll +0 -0
  236. data/src/ClipRectStack.cpp +0 -38
  237. /data/dependencies/SDL/include/{SDL3/SDL_opengl_glext.h → SDL_opengl_glext.h} +0 -0
  238. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2.h → SDL_opengles2_gl2.h} +0 -0
  239. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2ext.h → SDL_opengles2_gl2ext.h} +0 -0
  240. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2platform.h → SDL_opengles2_gl2platform.h} +0 -0
  241. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_khrplatform.h → SDL_opengles2_khrplatform.h} +0 -0
@@ -1,4 +1,4 @@
1
- // stb_truetype.h - v1.28 - public domain
1
+ // stb_truetype.h - v1.26 - public domain
2
2
  // authored from 2009-2021 by Sean Barrett / RAD Game Tools
3
3
  //
4
4
  // =======================================================================
@@ -45,7 +45,7 @@
45
45
  // Cass Everitt Martins Mozeiko github:aloucks
46
46
  // stoiko (Haemimont Games) Cap Petschulat github:oyvindjam
47
47
  // Brian Hook Omar Cornut github:vassvik
48
- // Walter van Niftrik Ryan Griege github:Cerallin
48
+ // Walter van Niftrik Ryan Griege
49
49
  // David Gow Peter LaValle
50
50
  // David Given Sergey Popov
51
51
  // Ivan-Assen Ivanov Giumo X. Clanjor
@@ -54,14 +54,10 @@
54
54
  // Hou Qiming Derek Vinyard
55
55
  // Rob Loach Cort Stratton
56
56
  // Kenney Phillis Jr. Brian Costabile
57
- // Ken Voskuil (kaesve) Yakov Galka
58
- // Neil Bickford Matthias Dorfelt
59
- // Isaac "Atridas" Serrano
57
+ // Ken Voskuil (kaesve)
60
58
  //
61
59
  // VERSION HISTORY
62
60
  //
63
- // 1.28 (2026-11-12) several fixes
64
- // 1.27 (2026-11-08) many fixes, support vertical layout, underlines, font name
65
61
  // 1.26 (2021-08-28) fix broken rasterizer
66
62
  // 1.25 (2021-07-11) many fixes
67
63
  // 1.24 (2020-02-05) fix warning
@@ -205,10 +201,10 @@
205
201
  // Baseline:
206
202
  // You need to select a y-coordinate that is the baseline of where
207
203
  // your text will appear. Call GetFontBoundingBox to get the baseline-relative
208
- // bounding box for all characters. SF*y1 will be the distance in pixels
204
+ // bounding box for all characters. SF*-y0 will be the distance in pixels
209
205
  // that the worst-case character could extend above the baseline, so if
210
206
  // you want the top edge of characters to appear at the top of the
211
- // screen where y=0, then you would set the baseline to SF*y1.
207
+ // screen where y=0, then you would set the baseline to SF*-y0.
212
208
  //
213
209
  // Current point:
214
210
  // Set the current point where the first character will appear. The
@@ -219,10 +215,10 @@
219
215
  // the current point based on that.
220
216
  //
221
217
  // Displaying a character:
222
- // Call a function to compute the bounding box of the character. It will contain
223
- // signed values relative to <current_point, baseline>. I.e. if it returns x0,y0,
224
- // x1,y1, then the character should be displayed in the rectangle from
225
- // <current_point+x0,baseline+y0> to <current_point+x1,baseline+y1>.
218
+ // Compute the bounding box of the character. It will contain signed values
219
+ // relative to <current_point, baseline>. I.e. if it returns x0,y0,x1,y1,
220
+ // then the character should be displayed in the rectangle from
221
+ // <current_point+SF*x0, baseline+SF*y0> to <current_point+SF*x1,baseline+SF*y1).
226
222
  //
227
223
  // Advancing for the next character:
228
224
  // Call GlyphHMetrics, and compute 'current_point += SF * advance'.
@@ -234,10 +230,10 @@
234
230
  //
235
231
  // - Use the functions with Subpixel at the end to allow your characters
236
232
  // to have subpixel positioning. Since the font is anti-aliased, not
237
- // hinted, this is very important for quality. (This is not possible with
233
+ // hinted, this is very import for quality. (This is not possible with
238
234
  // baked fonts.)
239
235
  //
240
- // - Kerning is supported, and if you're supporting subpixel rendering
236
+ // - Kerning is now supported, and if you're supporting subpixel rendering
241
237
  // then kerning is worth using to give your text a polished look.
242
238
  //
243
239
  // Performance:
@@ -326,7 +322,7 @@ void my_stbtt_print(float x, float y, char *text)
326
322
  //
327
323
  //////////////////////////////////////////////////////////////////////////////
328
324
  //
329
- // Compilable program (does no cleanup): get a single bitmap, print as ASCII art
325
+ // Complete program (this compiles): get a single bitmap, print as ASCII art
330
326
  //
331
327
  #if 0
332
328
  #include <stdio.h>
@@ -341,10 +337,10 @@ int main(int argc, char **argv)
341
337
  unsigned char *bitmap;
342
338
  int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20);
343
339
 
344
- fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); // fclose() omitted for clarity
340
+ fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb"));
345
341
 
346
342
  stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
347
- bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); // stbtt_FreeBitmap() omitted for clarity
343
+ bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0);
348
344
 
349
345
  for (j=0; j < h; ++j) {
350
346
  for (i=0; i < w; ++i)
@@ -370,7 +366,7 @@ int main(int argc, char **argv)
370
366
  //
371
367
  //////////////////////////////////////////////////////////////////////////////
372
368
  //
373
- // Complete program: print "Hello World!" banner, with bugs & no cleanup
369
+ // Complete program: print "Hello World!" banner, with bugs
374
370
  //
375
371
  #if 0
376
372
  char buffer[24<<20];
@@ -624,7 +620,7 @@ typedef struct
624
620
  {
625
621
  float font_size;
626
622
  int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint
627
- const int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints
623
+ int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints
628
624
  int num_chars;
629
625
  stbtt_packedchar *chardata_for_range; // output
630
626
  unsigned char h_oversample, v_oversample; // don't set these, they're used internally
@@ -655,7 +651,7 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
655
651
  STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
656
652
  // If skip != 0, this tells stb_truetype to skip any codepoints for which
657
653
  // there is no corresponding glyph. If skip=0, which is the default, then
658
- // codepoints without a glyph received the font's "missing character" glyph,
654
+ // codepoints without a glyph recived the font's "missing character" glyph,
659
655
  // typically an empty box by convention.
660
656
 
661
657
  STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
@@ -722,7 +718,7 @@ struct stbtt_fontinfo
722
718
 
723
719
  int numGlyphs; // number of glyphs, needed for range checking
724
720
 
725
- int loca,head,glyf,hhea,hmtx,vhea,vmtx,kern,gpos,svg; // table locations as offset from start of .ttf
721
+ int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf
726
722
  int index_map; // a cmap mapping for our chosen character encoding
727
723
  int indexToLocFormat; // format needed to map from glyph index to glyph
728
724
 
@@ -744,7 +740,7 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, in
744
740
 
745
741
  //////////////////////////////////////////////////////////////////////////////
746
742
  //
747
- // CHARACTER TO GLYPH-INDEX CONVERSION
743
+ // CHARACTER TO GLYPH-INDEX CONVERSIOn
748
744
 
749
745
  STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
750
746
  // If you're going to perform multiple operations on the same character
@@ -767,10 +763,6 @@ STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixe
767
763
  // scale = pixels / (ascent - descent)
768
764
  // so if you prefer to measure height by the ascent only, use a similar calculation.
769
765
 
770
- STBTT_DEF float stbtt_ScaleForPixelWidth(const stbtt_fontinfo *info, float pixels);
771
- // computes a scale factor to produce a font whose width is 'pixels' wide.
772
- // Width is measured as the distance from the left-side-bearing to the right-side-bearing
773
-
774
766
  STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
775
767
  // computes a scale factor to produce a font whose EM size is mapped to
776
768
  // 'pixels' tall. This is probably what traditional APIs compute, but
@@ -784,9 +776,6 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in
784
776
  // these are expressed in unscaled coordinates, so you must multiply by
785
777
  // the scale factor for a given size
786
778
 
787
- STBTT_DEF void stbtt_GetFontHMetrics(const stbtt_fontinfo *info, int *vertTypoAscender, int *vertTypoDescender, int *vertTypoLineGap);
788
-
789
-
790
779
  STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap);
791
780
  // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2
792
781
  // table (specific to MS/Windows TTF files).
@@ -796,11 +785,6 @@ STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAsc
796
785
  STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
797
786
  // the bounding box around all possible characters
798
787
 
799
- STBTT_DEF int stbtt_GetFontUnderlineMetrics(const stbtt_fontinfo *info, int *position, int *thickness);
800
- // the underline position and thickness as defined in the "post" table
801
- //
802
- // Returns 1 on success (table present), 0 on failure.
803
-
804
788
  STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
805
789
  // leftSideBearing is the offset from the current horizontal position to the left edge of the character
806
790
  // advanceWidth is the offset from the current horizontal position to the next horizontal position
@@ -813,7 +797,6 @@ STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, i
813
797
  // Gets the bounding box of the visible part of the glyph, in unscaled coordinates
814
798
 
815
799
  STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
816
- STBTT_DEF void stbtt_GetGlyphVMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceHeight, int *topSideBearing);
817
800
  STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
818
801
  STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
819
802
  // as above, but takes one or more glyph indices for greater efficiency
@@ -898,7 +881,7 @@ STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, fl
898
881
  // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
899
882
 
900
883
  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);
901
- // the same as stbtt_GetCodepointBitmap, but you can specify a subpixel
884
+ // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
902
885
  // shift for the character
903
886
 
904
887
  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);
@@ -1055,12 +1038,9 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l
1055
1038
  // and puts the length in bytes in *length.
1056
1039
  //
1057
1040
  // some of the values for the IDs are below; for more see the truetype spec:
1058
- // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
1041
+ // http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
1059
1042
  // http://www.microsoft.com/typography/otspec/name.htm
1060
1043
 
1061
- STBTT_DEF int stbtt_GetFontNameDefault(const stbtt_fontinfo *font, char *output_buffer, size_t output_buffer_len);
1062
- // return the default english full name of the font as utf-8
1063
-
1064
1044
  enum { // platformID
1065
1045
  STBTT_PLATFORM_ID_UNICODE =0,
1066
1046
  STBTT_PLATFORM_ID_MAC =1,
@@ -1404,7 +1384,6 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
1404
1384
  {
1405
1385
  stbtt_uint32 cmap, t;
1406
1386
  stbtt_int32 i,numTables;
1407
- stbtt_uint32 symbol_map=0;
1408
1387
 
1409
1388
  info->data = data;
1410
1389
  info->fontstart = fontstart;
@@ -1416,8 +1395,6 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
1416
1395
  info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required
1417
1396
  info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required
1418
1397
  info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required
1419
- info->vhea = stbtt__find_table(data, fontstart, "vhea"); // not required
1420
- info->vmtx = stbtt__find_table(data, fontstart, "vmtx"); // not required
1421
1398
  info->kern = stbtt__find_table(data, fontstart, "kern"); // not required
1422
1399
  info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required
1423
1400
 
@@ -1500,9 +1477,6 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
1500
1477
  // MS/Unicode
1501
1478
  info->index_map = cmap + ttULONG(data+encoding_record+4);
1502
1479
  break;
1503
- case STBTT_MS_EID_SYMBOL:
1504
- symbol_map = cmap + ttULONG(data+encoding_record+4);
1505
- break;
1506
1480
  }
1507
1481
  break;
1508
1482
  case STBTT_PLATFORM_ID_UNICODE:
@@ -1512,9 +1486,6 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
1512
1486
  break;
1513
1487
  }
1514
1488
  }
1515
- if (info->index_map == 0)
1516
- info->index_map = symbol_map;
1517
-
1518
1489
  if (info->index_map == 0)
1519
1490
  return 0;
1520
1491
 
@@ -1528,7 +1499,6 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
1528
1499
  stbtt_uint32 index_map = info->index_map;
1529
1500
 
1530
1501
  stbtt_uint16 format = ttUSHORT(data + index_map + 0);
1531
-
1532
1502
  if (format == 0) { // apple byte encoding
1533
1503
  stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
1534
1504
  if (unicode_codepoint < bytes-6)
@@ -1574,35 +1544,19 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
1574
1544
  search += 2;
1575
1545
 
1576
1546
  {
1577
- stbtt_uint16 offset, start, last, index;
1578
- stbtt_int16 delta;
1547
+ stbtt_uint16 offset, start, last;
1579
1548
  stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);
1580
1549
 
1581
- // get the actual range for this segment
1582
1550
  start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
1583
1551
  last = ttUSHORT(data + endCount + 2*item);
1584
1552
  if (unicode_codepoint < start || unicode_codepoint > last)
1585
1553
  return 0;
1586
1554
 
1587
1555
  offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
1588
- delta = ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item);
1589
-
1590
- // "if idRangeOffset is 0, the idDelta value is added directly to the character code"
1591
1556
  if (offset == 0)
1592
- return (stbtt_uint16) (unicode_codepoint + delta);
1593
-
1594
- // "If the idRangeOffset value for the segment is not 0, ..."
1595
- // "glyphIndexAddress = idRangeOffset[i] + 2 * (c - startCode[i]) + (Ptr) &idRangeOffset[i]"
1596
- index = ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
1557
+ return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
1597
1558
 
1598
- // "Once the glyph indexing operation is complete, the glyph ID at the indicated address
1599
- // is checked. If it's not 0 (that is, if it's not the missing glyph), the value is added
1600
- // to idDelta[i] to get the actual glyph ID to use."
1601
- if (index != 0) {
1602
- index = (stbtt_uint16) (index + delta);
1603
- }
1604
-
1605
- return index;
1559
+ return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
1606
1560
  }
1607
1561
  } else if (format == 12 || format == 13) {
1608
1562
  stbtt_uint32 ngroups = ttULONG(data+index_map+12);
@@ -1671,7 +1625,7 @@ static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, in
1671
1625
  STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
1672
1626
  {
1673
1627
  if (info->cff.size) {
1674
- return stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
1628
+ stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
1675
1629
  } else {
1676
1630
  int g = stbtt__GetGlyfOffset(info, glyph_index);
1677
1631
  if (g < 0) return 0;
@@ -1813,8 +1767,8 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
1813
1767
  if (i != 0)
1814
1768
  num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
1815
1769
 
1816
- // now start the new one... avoid looking ahead if we're at the end of a contour
1817
- start_off = !(flags & 1) && i < ttUSHORT(endPtsOfContours+j*2);
1770
+ // now start the new one
1771
+ start_off = !(flags & 1);
1818
1772
  if (start_off) {
1819
1773
  // if we start off with an off-curve point, then when we need to find a point on the curve
1820
1774
  // where we can start, and we need to save some state for when we wraparound.
@@ -1897,35 +1851,23 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s
1897
1851
  mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
1898
1852
  }
1899
1853
 
1900
- // Find transformation scales. Per TrueType spec, these are used
1901
- // ONLY to rescale the offsets (mtx[4], mtx[5]) when
1902
- // SCALED_COMPONENT_OFFSET (flag bit 11, 0x800) is set. They must
1903
- // NOT scale the linear part of the transform — doing so squares
1904
- // the scale factor and is the cause of composite sub-components
1905
- // rendering at wrong sizes in COLR emoji fonts (OpenMoji, Noto
1906
- // Color Emoji, Microsoft Fluent Emoji).
1854
+ // Find transformation scales.
1907
1855
  m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
1908
1856
  n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
1909
- // Default: UNSCALED offsets (Microsoft convention; matches modern
1910
- // font tooling). Only SCALED_COMPONENT_OFFSET (bit 11) set without
1911
- // UNSCALED_COMPONENT_OFFSET (bit 12) triggers the offset rescale.
1912
- if ((flags & (1<<11)) && !(flags & (1<<12))) {
1913
- mtx[4] *= m; mtx[5] *= n;
1914
- }
1915
1857
 
1916
1858
  // Get indexed glyph.
1917
1859
  comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts);
1918
1860
  if (comp_num_verts > 0) {
1919
- // Transform vertices: v' = M·v + t. No double-scaling.
1861
+ // Transform vertices.
1920
1862
  for (i = 0; i < comp_num_verts; ++i) {
1921
1863
  stbtt_vertex* v = &comp_verts[i];
1922
1864
  stbtt_vertex_type x,y;
1923
1865
  x=v->x; y=v->y;
1924
- v->x = (stbtt_vertex_type)(mtx[0]*x + mtx[2]*y + mtx[4]);
1925
- v->y = (stbtt_vertex_type)(mtx[1]*x + mtx[3]*y + mtx[5]);
1866
+ v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
1867
+ v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
1926
1868
  x=v->cx; y=v->cy;
1927
- v->cx = (stbtt_vertex_type)(mtx[0]*x + mtx[2]*y + mtx[4]);
1928
- v->cy = (stbtt_vertex_type)(mtx[1]*x + mtx[3]*y + mtx[5]);
1869
+ v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
1870
+ v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
1929
1871
  }
1930
1872
  // Append vertices.
1931
1873
  tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata);
@@ -2061,7 +2003,7 @@ static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int gly
2061
2003
  start = end;
2062
2004
  }
2063
2005
  }
2064
- if (fdselector == -1) return stbtt__new_buf(NULL, 0);
2006
+ if (fdselector == -1) stbtt__new_buf(NULL, 0);
2065
2007
  return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector));
2066
2008
  }
2067
2009
 
@@ -2372,12 +2314,6 @@ STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_inde
2372
2314
  }
2373
2315
  }
2374
2316
 
2375
- STBTT_DEF void stbtt_GetGlyphVMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceHeight, int *topSideBearing)
2376
- {
2377
- if (advanceHeight) *advanceHeight = ttSHORT(info->data + info->vmtx + 4*glyph_index);
2378
- if (topSideBearing) *topSideBearing = ttSHORT(info->data + info->vmtx + 4*glyph_index + 2);
2379
- }
2380
-
2381
2317
  STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info)
2382
2318
  {
2383
2319
  stbtt_uint8 *data = info->data + info->kern;
@@ -2570,7 +2506,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in
2570
2506
  data = info->data + info->gpos;
2571
2507
 
2572
2508
  if (ttUSHORT(data+0) != 1) return 0; // Major version 1
2573
- if (ttUSHORT(data+2) > 1) return 0; // Minor version 0, or 1
2509
+ if (ttUSHORT(data+2) != 0) return 0; // Minor version 0
2574
2510
 
2575
2511
  lookupListOffset = ttUSHORT(data+8);
2576
2512
  lookupList = data + lookupListOffset;
@@ -2583,28 +2519,15 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in
2583
2519
  stbtt_uint16 lookupType = ttUSHORT(lookupTable);
2584
2520
  stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
2585
2521
  stbtt_uint8 *subTableOffsets = lookupTable + 6;
2586
- if (lookupType != 2 && // Pair Adjustment Positioning Subtable
2587
- lookupType != 9) // Positioning Subtable Extension
2522
+ if (lookupType != 2) // Pair Adjustment Positioning Subtable
2588
2523
  continue;
2589
2524
 
2590
2525
  for (sti=0; sti<subTableCount; sti++) {
2591
2526
  stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
2592
2527
  stbtt_uint8 *table = lookupTable + subtableOffset;
2593
- stbtt_uint16 posFormat;
2594
- stbtt_uint16 coverageOffset;
2595
- stbtt_int32 coverageIndex;
2596
- if (lookupType == 9) {
2597
- stbtt_uint32 exOffset;
2598
- if (ttUSHORT(table + 0) != 1) // Format 1
2599
- continue;
2600
- if (ttUSHORT(table + 2) != 2) // PairPos Subtable
2601
- continue;
2602
- exOffset = ttULONG(table + 4);
2603
- table += exOffset;
2604
- }
2605
- posFormat = ttUSHORT(table);
2606
- coverageOffset = ttUSHORT(table + 2);
2607
- coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
2528
+ stbtt_uint16 posFormat = ttUSHORT(table);
2529
+ stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
2530
+ stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
2608
2531
  if (coverageIndex == -1) continue;
2609
2532
 
2610
2533
  switch (posFormat) {
@@ -2613,10 +2536,8 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in
2613
2536
  int straw, needle;
2614
2537
  stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
2615
2538
  stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
2616
- if ((valueFormat1 == 4 ||
2617
- valueFormat1 == 68) &&
2618
- valueFormat2 == 0) { // Support more formats?
2619
- stbtt_int32 valueRecordPairSizeInBytes = valueFormat1 == 68 ? 4 : 2;
2539
+ if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats?
2540
+ stbtt_int32 valueRecordPairSizeInBytes = 2;
2620
2541
  stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
2621
2542
  stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
2622
2543
  stbtt_uint8 *pairValueTable = table + pairPosOffset;
@@ -2654,9 +2575,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in
2654
2575
  case 2: {
2655
2576
  stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
2656
2577
  stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
2657
- if ((valueFormat1 == 4 ||
2658
- valueFormat1 == 68) &&
2659
- valueFormat2 == 0) { // Support more formats?
2578
+ if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats?
2660
2579
  stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
2661
2580
  stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
2662
2581
  int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
@@ -2666,16 +2585,13 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in
2666
2585
  stbtt_uint16 class2Count = ttUSHORT(table + 14);
2667
2586
  stbtt_uint8 *class1Records, *class2Records;
2668
2587
  stbtt_int16 xAdvance;
2669
- stbtt_int32 valueRecordPairSizeInBytes;
2670
2588
 
2671
2589
  if (glyph1class < 0 || glyph1class >= class1Count) return 0; // malformed
2672
2590
  if (glyph2class < 0 || glyph2class >= class2Count) return 0; // malformed
2673
2591
 
2674
- valueRecordPairSizeInBytes = valueFormat1 == 68 ? 4 : 2;
2675
-
2676
2592
  class1Records = table + 16;
2677
- class2Records = class1Records + valueRecordPairSizeInBytes * (glyph1class * class2Count);
2678
- xAdvance = ttSHORT(class2Records + valueRecordPairSizeInBytes * glyph2class);
2593
+ class2Records = class1Records + 2 * (glyph1class * class2Count);
2594
+ xAdvance = ttSHORT(class2Records + 2 * glyph2class);
2679
2595
  return xAdvance;
2680
2596
  } else
2681
2597
  return 0;
@@ -2696,10 +2612,9 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int
2696
2612
  int xAdvance = 0;
2697
2613
 
2698
2614
  if (info->gpos)
2699
- xAdvance = stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
2700
-
2701
- if (info->kern && xAdvance == 0)
2702
- xAdvance = stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
2615
+ xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
2616
+ else if (info->kern)
2617
+ xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
2703
2618
 
2704
2619
  return xAdvance;
2705
2620
  }
@@ -2716,11 +2631,6 @@ STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepo
2716
2631
  stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
2717
2632
  }
2718
2633
 
2719
- STBTT_DEF void stbtt_GetCodepointVMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceHeight, int *topSideBearing)
2720
- {
2721
- stbtt_GetGlyphVMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceHeight, topSideBearing);
2722
- }
2723
-
2724
2634
  STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
2725
2635
  {
2726
2636
  if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4);
@@ -2728,13 +2638,6 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in
2728
2638
  if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
2729
2639
  }
2730
2640
 
2731
- STBTT_DEF void stbtt_GetFontHMetrics(const stbtt_fontinfo *info, int *vertTypoAscender, int *vertTypoDescender, int *vertTypoLineGap)
2732
- {
2733
- if (vertTypoAscender ) *vertTypoAscender = ttSHORT(info->data+info->vhea + 4);
2734
- if (vertTypoDescender) *vertTypoDescender = ttSHORT(info->data+info->vhea + 6);
2735
- if (vertTypoLineGap) *vertTypoLineGap = ttSHORT(info->data+info->vhea + 8);
2736
- }
2737
-
2738
2641
  STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap)
2739
2642
  {
2740
2643
  int tab = stbtt__find_table(info->data, info->fontstart, "OS/2");
@@ -2754,28 +2657,12 @@ STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int
2754
2657
  *y1 = ttSHORT(info->data + info->head + 42);
2755
2658
  }
2756
2659
 
2757
- STBTT_DEF int stbtt_GetFontUnderlineMetrics(const stbtt_fontinfo *info, int *position, int *thickness)
2758
- {
2759
- int tab = stbtt__find_table(info->data, info->fontstart, "post");
2760
- if (!tab)
2761
- return 0;
2762
- *position = ttSHORT(info->data + tab + 8);
2763
- *thickness = ttSHORT(info->data + tab + 10);
2764
- return 1;
2765
- }
2766
-
2767
2660
  STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
2768
2661
  {
2769
2662
  int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
2770
2663
  return (float) height / fheight;
2771
2664
  }
2772
2665
 
2773
- STBTT_DEF float stbtt_ScaleForPixelWidth(const stbtt_fontinfo *info, float width)
2774
- {
2775
- int fwidth = ttSHORT(info->data + info->hhea + 10) - ttSHORT(info->data + info->hhea + 12);
2776
- return (float) width / fwidth;
2777
- }
2778
-
2779
2666
  STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
2780
2667
  {
2781
2668
  int unitsPerEm = ttUSHORT(info->data + info->head + 18);
@@ -3308,10 +3195,8 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
3308
3195
 
3309
3196
  // check if final y_crossing is blown up; no test case for this
3310
3197
  if (y_final > y_bottom) {
3311
- int denom = (x2 - (x1+1));
3312
3198
  y_final = y_bottom;
3313
- if (denom != 0)
3314
- dy = (y_final - y_crossing ) / denom; // if denom=0, y_final = y_crossing, so y_final <= y_bottom
3199
+ dy = (y_final - y_crossing ) / (x2 - (x1+1)); // if denom=0, y_final = y_crossing, so y_final <= y_bottom
3315
3200
  }
3316
3201
 
3317
3202
  // in second pixel, area covered by line segment found in first pixel
@@ -4322,7 +4207,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info
4322
4207
  // rects array must be big enough to accommodate all characters in the given ranges
4323
4208
  STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
4324
4209
  {
4325
- int i,j,k, missing_range = -1, missing_glyph = -1, return_value = 1;
4210
+ int i,j,k, missing_glyph = -1, return_value = 1;
4326
4211
 
4327
4212
  // save current values
4328
4213
  int old_h_over = spc->h_oversample;
@@ -4388,14 +4273,12 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const
4388
4273
  bc->xoff2 = (x0 + r->w) * recip_h + sub_x;
4389
4274
  bc->yoff2 = (y0 + r->h) * recip_v + sub_y;
4390
4275
 
4391
- if (glyph == 0) {
4392
- missing_range = i;
4276
+ if (glyph == 0)
4393
4277
  missing_glyph = j;
4394
- }
4395
4278
  } else if (spc->skip_missing) {
4396
4279
  return_value = 0;
4397
4280
  } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) {
4398
- ranges[i].chardata_for_range[j] = ranges[missing_range].chardata_for_range[missing_glyph];
4281
+ ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph];
4399
4282
  } else {
4400
4283
  return_value = 0; // if any fail, report failure
4401
4284
  }
@@ -4419,7 +4302,7 @@ STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect
4419
4302
  STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
4420
4303
  {
4421
4304
  stbtt_fontinfo info;
4422
- int i, j, n, return_value;
4305
+ int i,j,n, return_value = 1;
4423
4306
  //stbrp_context *context = (stbrp_context *) spc->pack_info;
4424
4307
  stbrp_rect *rects;
4425
4308
 
@@ -4576,7 +4459,7 @@ static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2],
4576
4459
  }
4577
4460
  }
4578
4461
 
4579
- static int stbtt__equal(float *a, float *b)
4462
+ static int equal(float *a, float *b)
4580
4463
  {
4581
4464
  return (a[0] == b[0] && a[1] == b[1]);
4582
4465
  }
@@ -4624,7 +4507,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
4624
4507
  q1[1] = (float)y1;
4625
4508
  q2[0] = (float)x2;
4626
4509
  q2[1] = (float)y2;
4627
- if (stbtt__equal(q0,q1) || stbtt__equal(q1,q2)) {
4510
+ if (equal(q0,q1) || equal(q1,q2)) {
4628
4511
  x0 = (int)verts[i-1].x;
4629
4512
  y0 = (int)verts[i-1].y;
4630
4513
  x1 = (int)verts[i ].x;
@@ -4701,13 +4584,8 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
4701
4584
  stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1);
4702
4585
 
4703
4586
  // if empty, return NULL
4704
- if (ix0 == ix1 || iy0 == iy1) {
4705
- if (width) *width = 0;
4706
- if (height) *height = 0;
4707
- if (xoff) *xoff = 0;
4708
- if (yoff) *yoff = 0;
4587
+ if (ix0 == ix1 || iy0 == iy1)
4709
4588
  return NULL;
4710
- }
4711
4589
 
4712
4590
  ix0 -= padding;
4713
4591
  iy0 -= padding;
@@ -4726,8 +4604,6 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
4726
4604
  scale_y = -scale_y;
4727
4605
 
4728
4606
  {
4729
- // distance from singular values (in the same units as the pixel grid)
4730
- const float eps = 1./1024, eps2 = eps*eps;
4731
4607
  int x,y,i,j;
4732
4608
  float *precompute;
4733
4609
  stbtt_vertex *verts;
@@ -4740,15 +4616,15 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
4740
4616
  float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
4741
4617
  float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;
4742
4618
  float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
4743
- precompute[i] = (dist < eps) ? 0.0f : 1.0f / dist;
4619
+ precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;
4744
4620
  } else if (verts[i].type == STBTT_vcurve) {
4745
4621
  float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;
4746
4622
  float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;
4747
4623
  float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;
4748
4624
  float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
4749
4625
  float len2 = bx*bx + by*by;
4750
- if (len2 >= eps2)
4751
- precompute[i] = 1.0f / len2;
4626
+ if (len2 != 0.0f)
4627
+ precompute[i] = 1.0f / (bx*bx + by*by);
4752
4628
  else
4753
4629
  precompute[i] = 0.0f;
4754
4630
  } else
@@ -4813,8 +4689,8 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
4813
4689
  float a = 3*(ax*bx + ay*by);
4814
4690
  float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);
4815
4691
  float c = mx*ax+my*ay;
4816
- if (STBTT_fabs(a) < eps2) { // if a is 0, it's linear
4817
- if (STBTT_fabs(b) >= eps2) {
4692
+ if (a == 0.0) { // if a is 0, it's linear
4693
+ if (b != 0.0) {
4818
4694
  res[num++] = -c/b;
4819
4695
  }
4820
4696
  } else {
@@ -4964,126 +4840,6 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l
4964
4840
  return NULL;
4965
4841
  }
4966
4842
 
4967
- // convert utf16 to utf8 and return the length required to output NUL-terminated; buffer_len of 0 means to just query length
4968
- // if you pass a buffer that's too small, it'll NULL terminate and return the actual length computed
4969
- STBTT_DEF int stbtt__ConvertUTF16BEtoUTF8(char *buffer, size_t buffer_len, unsigned char *src, size_t src_len_raw)
4970
- {
4971
- int src_len = (int) src_len_raw;
4972
- int write_max = 0;
4973
- int i = 0, write, off = 0;
4974
- write = (buffer_len != 0);
4975
- write_max = (int) (buffer_len-1);
4976
-
4977
- if ((size_t) src_len != src_len_raw)
4978
- return -1;
4979
-
4980
- if (write) {
4981
- if (write_max < 0 || ((size_t) write_max+1 != buffer_len && write_max != 0))
4982
- return -1;
4983
- }
4984
-
4985
- if (buffer_len == 1) {
4986
- buffer[0] = 0;
4987
- return 1;
4988
- }
4989
-
4990
- while (off < src_len) {
4991
- stbtt_uint16 ch = src[off+0]*256 + src[off+1];
4992
- off += 2;
4993
- if (ch < 0x80) {
4994
- if (write) {
4995
- if (i >= write_max) { buffer[i] = 0; return i+1; }
4996
- buffer[i] = (char) ch;
4997
- }
4998
- ++i;
4999
- } else if (ch < 0x800) {
5000
- if (write) {
5001
- if (i+1 >= write_max) { buffer[i] = 0; return i+1; }
5002
- buffer[i+0] = (char) ( 0xc0 + (ch >> 6) );
5003
- buffer[i+1] = (char) ( 0x80 + (ch & 0x3f) );
5004
- }
5005
- i += 2;
5006
- } else if (ch >= 0xd800 && ch < 0xdc00) {
5007
- stbtt_uint32 c;
5008
- stbtt_uint16 ch2 = src[off+0]*256 + src[off+1];
5009
- off += 2;
5010
- if (write) {
5011
- if (i+3 >= write_max) { buffer[i] = 0; return i+1; }
5012
- c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000;
5013
- buffer[i+0] = (char) ( 0xf0 + (c >> 18) );
5014
- buffer[i+1] = (char) ( 0x80 + ((c >> 12) & 0x3f) );
5015
- buffer[i+2] = (char) ( 0x80 + ((c >> 6) & 0x3f) );
5016
- buffer[i+3] = (char) ( 0x80 + ((c ) & 0x3f) );
5017
- }
5018
- i += 4;
5019
- } else if (ch >= 0xdc00 && ch < 0xe000) {
5020
- if (write)
5021
- buffer[i] = 0;
5022
- return -1;
5023
- } else {
5024
- if (write) {
5025
- if (i+2 >= write_max) { buffer[i] = 0; return i+1; }
5026
- buffer[i+0] = (char) ( 0xe0 + (ch >> 12) );
5027
- buffer[i+1] = (char) ( 0x80 + ((ch >> 6) & 0x3f) );
5028
- buffer[i+2] = (char) ( 0x80 + ((ch ) & 0x3f) );
5029
- }
5030
- i += 3;
5031
- }
5032
- }
5033
- if (write) {
5034
- STBTT_assert(i <= write_max);
5035
- buffer[i] = 0;
5036
- }
5037
- return i+1;
5038
- }
5039
-
5040
- // Returns the english full name of the font as UTF-8
5041
- STBTT_DEF int stbtt_GetFontNameDefault(const stbtt_fontinfo *font, char *buffer, size_t buffer_len)
5042
- {
5043
- stbtt_int32 i,count,stringOffset;
5044
- stbtt_uint8 *fc = font->data;
5045
- stbtt_uint32 offset = font->fontstart;
5046
- stbtt_uint32 nm = stbtt__find_table(fc, offset, "name");
5047
- if (!nm) return -1;
5048
-
5049
- count = ttUSHORT(fc+nm+2);
5050
- stringOffset = nm + ttUSHORT(fc+nm+4);
5051
- for (i=0; i < count; ++i) {
5052
- char* str;
5053
- stbtt_uint16 platformId;
5054
- stbtt_uint16 encodingId;
5055
- stbtt_uint16 languageId;
5056
- size_t length;
5057
- stbtt_uint32 loc = nm + 6 + 12 * i;
5058
- if (ttUSHORT(fc+loc+6) != 4) continue;
5059
- platformId = ttUSHORT(fc+loc+0);
5060
- encodingId = ttUSHORT(fc+loc+2);
5061
- languageId = ttUSHORT(fc+loc+4);
5062
- if (!(platformId == STBTT_PLATFORM_ID_MAC && languageId == STBTT_MAC_LANG_ENGLISH) && !(platformId == STBTT_PLATFORM_ID_MICROSOFT && languageId == STBTT_MS_LANG_ENGLISH))
5063
- continue;
5064
-
5065
- length = ttUSHORT(fc+loc+8);
5066
- str = (char *) (fc+stringOffset+ttUSHORT(fc+loc+10));
5067
- if (platformId == STBTT_PLATFORM_ID_UNICODE || (platformId == STBTT_PLATFORM_ID_MICROSOFT && (encodingId == 1 || encodingId == 10)))
5068
- return stbtt__ConvertUTF16BEtoUTF8(buffer, buffer_len, (unsigned char *) str, length);
5069
- else {
5070
- if (buffer == NULL)
5071
- return (int) length;
5072
-
5073
- if (length < buffer_len) {
5074
- memcpy(buffer, str, length);
5075
- buffer[length] = 0;
5076
- return (int) length;
5077
- } else {
5078
- memcpy(buffer, str, buffer_len-1);
5079
- buffer[buffer_len-1] = 0;
5080
- return (int) length;
5081
- }
5082
- }
5083
- }
5084
- return -1;
5085
- }
5086
-
5087
4843
  static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id)
5088
4844
  {
5089
4845
  stbtt_int32 i;