koffi 2.1.1 → 2.1.2
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.
- package/ChangeLog.md +6 -0
- package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_x64.tar.gz +0 -0
- package/doc/templates/badges.html +3 -0
- package/package.json +2 -2
- package/src/abi_arm64.cc +35 -1
- package/src/abi_x64_win.cc +2 -8
- package/src/abi_x86.cc +1 -7
- package/src/ffi.hh +1 -1
- package/src/util.hh +6 -0
- package/test/raylib.js +37 -5
- package/vendor/libcc/libcc.cc +430 -196
- package/vendor/libcc/libcc.hh +1417 -1283
- package/vendor/raylib/BINDINGS.md +87 -70
- package/vendor/raylib/CHANGELOG +263 -50
- package/vendor/raylib/CMakeLists.txt +12 -0
- package/vendor/raylib/CMakeOptions.txt +8 -1
- package/vendor/raylib/CONVENTIONS.md +2 -3
- package/vendor/raylib/FAQ.md +137 -0
- package/vendor/raylib/HISTORY.md +62 -29
- package/vendor/raylib/LICENSE +1 -1
- package/vendor/raylib/README.md +22 -17
- package/vendor/raylib/ROADMAP.md +8 -7
- package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
- package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
- package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
- package/vendor/raylib/cmake/raylib-config.cmake +52 -49
- package/vendor/raylib/examples/CMakeLists.txt +14 -9
- package/vendor/raylib/examples/Makefile +112 -125
- package/vendor/raylib/examples/Makefile.Android +1 -1
- package/vendor/raylib/examples/Makefile.Web +145 -158
- package/vendor/raylib/examples/README.md +141 -141
- package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
- package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
- package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
- package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
- package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
- package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
- package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
- package/vendor/raylib/examples/build.zig +17 -6
- package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
- package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
- package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
- package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
- package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
- package/vendor/raylib/examples/core/core_basic_window.c +8 -3
- package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
- package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
- package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
- package/vendor/raylib/examples/core/core_drop_files.c +20 -12
- package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
- package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
- package/vendor/raylib/examples/core/core_input_keys.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
- package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
- package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
- package/vendor/raylib/examples/core/core_random_values.c +8 -3
- package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
- package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
- package/vendor/raylib/examples/core/core_split_screen.c +8 -3
- package/vendor/raylib/examples/core/core_storage_values.c +109 -3
- package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
- package/vendor/raylib/examples/core/core_window_flags.c +8 -3
- package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
- package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
- package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
- package/vendor/raylib/examples/core/core_world_screen.c +9 -4
- package/vendor/raylib/examples/examples_template.c +8 -3
- package/vendor/raylib/examples/models/models_animation.c +11 -7
- package/vendor/raylib/examples/models/models_billboard.c +9 -4
- package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
- package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
- package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
- package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
- package/vendor/raylib/examples/models/models_heightmap.c +9 -4
- package/vendor/raylib/examples/models/models_loading.c +21 -17
- package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
- package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
- package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
- package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
- package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
- package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
- package/vendor/raylib/examples/models/models_skybox.c +16 -12
- package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
- package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
- package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
- package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
- package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
- package/vendor/raylib/examples/others/easings_testbed.c +10 -8
- package/vendor/raylib/examples/others/easings_testbed.png +0 -0
- package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
- package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
- package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
- package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
- package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
- package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
- package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
- package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
- package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
- package/vendor/raylib/examples/shaders/rlights.h +14 -27
- package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
- package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
- package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
- package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
- package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
- package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
- package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
- package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
- package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
- package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
- package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
- package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
- package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
- package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
- package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
- package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
- package/vendor/raylib/examples/text/text_font_filters.c +14 -11
- package/vendor/raylib/examples/text/text_font_loading.c +9 -4
- package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
- package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
- package/vendor/raylib/examples/text/text_format_text.c +8 -3
- package/vendor/raylib/examples/text/text_input_box.c +8 -3
- package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
- package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
- package/vendor/raylib/examples/text/text_unicode.c +9 -7
- package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
- package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
- package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
- package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
- package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
- package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
- package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
- package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
- package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
- package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
- package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
- package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
- package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
- package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
- package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
- package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
- package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
- package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
- package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
- package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
- package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
- package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
- package/vendor/raylib/parser/LICENSE +1 -1
- package/vendor/raylib/parser/Makefile +28 -0
- package/vendor/raylib/parser/README.md +49 -5
- package/vendor/raylib/parser/output/raylib_api.json +10717 -0
- package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
- package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
- package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
- package/vendor/raylib/parser/raylib_parser.c +1174 -196
- package/vendor/raylib/projects/4coder/Makefile +2 -4
- package/vendor/raylib/projects/4coder/main.c +0 -1
- package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
- package/vendor/raylib/projects/CMake/README.md +27 -0
- package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
- package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
- package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
- package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
- package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
- package/vendor/raylib/projects/README.md +1 -1
- package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
- package/vendor/raylib/projects/VSCode/Makefile +8 -11
- package/vendor/raylib/projects/VSCode/main.c +53 -26
- package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
- package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
- package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
- package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
- package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
- package/vendor/raylib/src/CMakeLists.txt +6 -7
- package/vendor/raylib/src/Makefile +209 -103
- package/vendor/raylib/src/build.zig +56 -20
- package/vendor/raylib/src/config.h +32 -27
- package/vendor/raylib/src/external/cgltf.h +342 -104
- package/vendor/raylib/src/external/dr_wav.h +487 -225
- package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
- package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
- package/vendor/raylib/src/external/jar_xm.h +2 -1
- package/vendor/raylib/src/external/miniaudio.h +62251 -42061
- package/vendor/raylib/src/external/qoi.h +671 -0
- package/vendor/raylib/src/external/stb_vorbis.h +1 -1
- package/vendor/raylib/src/external/vox_loader.h +30 -25
- package/vendor/raylib/src/minshell.html +82 -0
- package/vendor/raylib/src/raudio.c +359 -201
- package/vendor/raylib/src/raylib.dll.rc +5 -5
- package/vendor/raylib/src/raylib.dll.rc.data +0 -0
- package/vendor/raylib/src/raylib.h +95 -63
- package/vendor/raylib/src/raylib.rc +5 -5
- package/vendor/raylib/src/raylib.rc.data +0 -0
- package/vendor/raylib/src/raymath.h +391 -133
- package/vendor/raylib/src/rcamera.h +32 -41
- package/vendor/raylib/src/rcore.c +775 -471
- package/vendor/raylib/src/rgestures.h +5 -5
- package/vendor/raylib/src/rglfw.c +3 -3
- package/vendor/raylib/src/rlgl.h +184 -144
- package/vendor/raylib/src/rmodels.c +207 -144
- package/vendor/raylib/src/rshapes.c +105 -47
- package/vendor/raylib/src/rtext.c +255 -38
- package/vendor/raylib/src/rtextures.c +167 -71
- package/vendor/raylib/src/shell.html +63 -63
- package/vendor/raylib/src/utils.c +49 -3
- package/vendor/raylib/src/utils.h +3 -3
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/vendor/raylib/CONTRIBUTORS.md +0 -63
- package/vendor/raylib/SPONSORS.md +0 -68
- package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
- package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
- package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
- package/vendor/raylib/examples/models/rlights.h +0 -183
- package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
- package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
- package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
- package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
- package/vendor/raylib/examples/physics/physics_demo.c +0 -128
- package/vendor/raylib/examples/physics/physics_demo.png +0 -0
- package/vendor/raylib/examples/physics/physics_friction.c +0 -142
- package/vendor/raylib/examples/physics/physics_friction.png +0 -0
- package/vendor/raylib/examples/physics/physics_movement.c +0 -128
- package/vendor/raylib/examples/physics/physics_movement.png +0 -0
- package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
- package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
- package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
- package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
- package/vendor/raylib/parser/raylib_api.json +0 -6668
- package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
- package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
- package/vendor/raylib/src/extras/physac.h +0 -1977
- package/vendor/raylib/src/extras/rmem.h +0 -751
- package/vendor/raylib/src/raudio.h +0 -198
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* CONFIGURATION:
|
|
6
6
|
*
|
|
7
|
+
* #define SUPPORT_MODULE_RTEXT
|
|
8
|
+
* rtext module is included in the build
|
|
9
|
+
*
|
|
7
10
|
* #define SUPPORT_FILEFORMAT_FNT
|
|
8
11
|
* #define SUPPORT_FILEFORMAT_TTF
|
|
9
12
|
* Selected desired fileformats to be supported for loading. Some of those formats are
|
|
@@ -22,12 +25,12 @@
|
|
|
22
25
|
*
|
|
23
26
|
* DEPENDENCIES:
|
|
24
27
|
* stb_truetype - Load TTF file and rasterize characters data
|
|
25
|
-
* stb_rect_pack - Rectangles packing
|
|
28
|
+
* stb_rect_pack - Rectangles packing algorithms, required for font atlas generation
|
|
26
29
|
*
|
|
27
30
|
*
|
|
28
31
|
* LICENSE: zlib/libpng
|
|
29
32
|
*
|
|
30
|
-
* Copyright (c) 2013-
|
|
33
|
+
* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
|
|
31
34
|
*
|
|
32
35
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
|
33
36
|
* will the authors be held liable for any damages arising from the use of this software.
|
|
@@ -53,6 +56,8 @@
|
|
|
53
56
|
#include "config.h" // Defines module configuration flags
|
|
54
57
|
#endif
|
|
55
58
|
|
|
59
|
+
#if defined(SUPPORT_MODULE_RTEXT)
|
|
60
|
+
|
|
56
61
|
#include "utils.h" // Required for: LoadFileText()
|
|
57
62
|
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 -> Only DrawTextPro()
|
|
58
63
|
|
|
@@ -224,7 +229,7 @@ extern void LoadFontDefault(void)
|
|
|
224
229
|
//------------------------------------------------------------------------------
|
|
225
230
|
|
|
226
231
|
// Allocate space for our characters info data
|
|
227
|
-
// NOTE: This memory
|
|
232
|
+
// NOTE: This memory must be freed at end! --> Done by CloseWindow()
|
|
228
233
|
defaultFont.glyphs = (GlyphInfo *)RL_MALLOC(defaultFont.glyphCount*sizeof(GlyphInfo));
|
|
229
234
|
defaultFont.recs = (Rectangle *)RL_MALLOC(defaultFont.glyphCount*sizeof(Rectangle));
|
|
230
235
|
|
|
@@ -311,7 +316,7 @@ Font LoadFont(const char *fileName)
|
|
|
311
316
|
Font font = { 0 };
|
|
312
317
|
|
|
313
318
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
|
314
|
-
if (IsFileExtension(fileName, ".ttf
|
|
319
|
+
if (IsFileExtension(fileName, ".ttf") || IsFileExtension(fileName, ".otf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
|
|
315
320
|
else
|
|
316
321
|
#endif
|
|
317
322
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
|
@@ -329,7 +334,11 @@ Font LoadFont(const char *fileName)
|
|
|
329
334
|
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
|
|
330
335
|
font = GetFontDefault();
|
|
331
336
|
}
|
|
332
|
-
else
|
|
337
|
+
else
|
|
338
|
+
{
|
|
339
|
+
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance)
|
|
340
|
+
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS);
|
|
341
|
+
}
|
|
333
342
|
|
|
334
343
|
return font;
|
|
335
344
|
}
|
|
@@ -515,7 +524,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
|
|
515
524
|
|
|
516
525
|
UnloadImage(atlas);
|
|
517
526
|
|
|
518
|
-
|
|
527
|
+
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", font.baseSize, font.glyphCount);
|
|
519
528
|
}
|
|
520
529
|
else font = GetFontDefault();
|
|
521
530
|
}
|
|
@@ -677,20 +686,20 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
|
|
|
677
686
|
// NOTE 2: SDF font characters already contain an internal padding,
|
|
678
687
|
// so image size would result bigger than default font type
|
|
679
688
|
float requiredArea = 0;
|
|
680
|
-
for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(
|
|
681
|
-
float guessSize = sqrtf(requiredArea)*1.
|
|
682
|
-
int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2)));
|
|
689
|
+
for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(fontSize + 2*padding));
|
|
690
|
+
float guessSize = sqrtf(requiredArea)*1.4f;
|
|
691
|
+
int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
|
|
683
692
|
|
|
684
693
|
atlas.width = imageSize; // Atlas bitmap width
|
|
685
694
|
atlas.height = imageSize; // Atlas bitmap height
|
|
686
|
-
atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height);
|
|
695
|
+
atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp)
|
|
687
696
|
atlas.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
|
|
688
697
|
atlas.mipmaps = 1;
|
|
689
698
|
|
|
690
699
|
// DEBUG: We can see padding in the generated image setting a gray background...
|
|
691
700
|
//for (int i = 0; i < atlas.width*atlas.height; i++) ((unsigned char *)atlas.data)[i] = 100;
|
|
692
701
|
|
|
693
|
-
if (packMethod == 0) // Use basic packing
|
|
702
|
+
if (packMethod == 0) // Use basic packing algorithm
|
|
694
703
|
{
|
|
695
704
|
int offsetX = padding;
|
|
696
705
|
int offsetY = padding;
|
|
@@ -725,11 +734,23 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
|
|
|
725
734
|
// height is bigger than fontSize, it could be up to (fontSize + 8)
|
|
726
735
|
offsetY += (fontSize + 2*padding);
|
|
727
736
|
|
|
728
|
-
if (offsetY > (atlas.height - fontSize - padding))
|
|
737
|
+
if (offsetY > (atlas.height - fontSize - padding))
|
|
738
|
+
{
|
|
739
|
+
for(int j = i + 1; j < glyphCount; j++)
|
|
740
|
+
{
|
|
741
|
+
TRACELOG(LOG_WARNING, "FONT: Failed to package character (%i)", j);
|
|
742
|
+
// make sure remaining recs contain valid data
|
|
743
|
+
recs[j].x = 0;
|
|
744
|
+
recs[j].y = 0;
|
|
745
|
+
recs[j].width = 0;
|
|
746
|
+
recs[j].height = 0;
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
729
750
|
}
|
|
730
751
|
}
|
|
731
752
|
}
|
|
732
|
-
else if (packMethod == 1) // Use Skyline rect packing
|
|
753
|
+
else if (packMethod == 1) // Use Skyline rect packing algorithm (stb_pack_rect)
|
|
733
754
|
{
|
|
734
755
|
stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context));
|
|
735
756
|
stbrp_node *nodes = (stbrp_node *)RL_MALLOC(glyphCount*sizeof(*nodes));
|
|
@@ -816,15 +837,170 @@ void UnloadFont(Font font)
|
|
|
816
837
|
}
|
|
817
838
|
}
|
|
818
839
|
|
|
840
|
+
// Export font as code file, returns true on success
|
|
841
|
+
bool ExportFontAsCode(Font font, const char *fileName)
|
|
842
|
+
{
|
|
843
|
+
bool success = false;
|
|
844
|
+
|
|
845
|
+
#ifndef TEXT_BYTES_PER_LINE
|
|
846
|
+
#define TEXT_BYTES_PER_LINE 20
|
|
847
|
+
#endif
|
|
848
|
+
|
|
849
|
+
#define MAX_FONT_DATA_SIZE 1024*1024 // 1 MB
|
|
850
|
+
|
|
851
|
+
// Get file name from path
|
|
852
|
+
char fileNamePascal[256] = { 0 };
|
|
853
|
+
strcpy(fileNamePascal, TextToPascal(GetFileNameWithoutExt(fileName)));
|
|
854
|
+
|
|
855
|
+
// NOTE: Text data buffer size is estimated considering image data size in bytes
|
|
856
|
+
// and requiring 6 char bytes for every byte: "0x00, "
|
|
857
|
+
char *txtData = (char *)RL_CALLOC(MAX_FONT_DATA_SIZE, sizeof(char));
|
|
858
|
+
|
|
859
|
+
int byteCount = 0;
|
|
860
|
+
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n");
|
|
861
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
862
|
+
byteCount += sprintf(txtData + byteCount, "// FontAsCode exporter v1.0 - Font data exported as an array of bytes //\n");
|
|
863
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
864
|
+
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
|
|
865
|
+
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
|
|
866
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
867
|
+
byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
|
|
868
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
869
|
+
byteCount += sprintf(txtData + byteCount, "// ---------------------------------------------------------------------------------- //\n");
|
|
870
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
871
|
+
byteCount += sprintf(txtData + byteCount, "// TODO: Fill the information and license of the exported font here: //\n");
|
|
872
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
873
|
+
byteCount += sprintf(txtData + byteCount, "// Font name: .... //\n");
|
|
874
|
+
byteCount += sprintf(txtData + byteCount, "// Font creator: .... //\n");
|
|
875
|
+
byteCount += sprintf(txtData + byteCount, "// Font LICENSE: .... //\n");
|
|
876
|
+
byteCount += sprintf(txtData + byteCount, "// //\n");
|
|
877
|
+
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n");
|
|
878
|
+
|
|
879
|
+
// Support font export and initialization
|
|
880
|
+
// NOTE: This mechanism is highly coupled to raylib
|
|
881
|
+
Image image = LoadImageFromTexture(font.texture);
|
|
882
|
+
if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "Font export as code: Font image format is not GRAY+ALPHA!");
|
|
883
|
+
int imageDataSize = GetPixelDataSize(image.width, image.height, image.format);
|
|
884
|
+
|
|
885
|
+
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
|
|
886
|
+
//ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE);
|
|
887
|
+
|
|
888
|
+
#define SUPPORT_COMPRESSED_FONT_ATLAS
|
|
889
|
+
#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
|
|
890
|
+
// WARNING: Data is compressed using raylib CompressData() DEFLATE,
|
|
891
|
+
// it requires to be decompressed with raylib DecompressData(), that requires
|
|
892
|
+
// compiling raylib with SUPPORT_COMPRESSION_API config flag enabled
|
|
893
|
+
|
|
894
|
+
// Compress font image data
|
|
895
|
+
int compDataSize = 0;
|
|
896
|
+
unsigned char *compData = CompressData(image.data, imageDataSize, &compDataSize);
|
|
897
|
+
|
|
898
|
+
// Save font image data (compressed)
|
|
899
|
+
byteCount += sprintf(txtData + byteCount, "#define COMPRESSED_DATA_SIZE_FONT_%s %i\n\n", TextToUpper(fileNamePascal), compDataSize);
|
|
900
|
+
byteCount += sprintf(txtData + byteCount, "// Font image pixels data compressed (DEFLATE)\n");
|
|
901
|
+
byteCount += sprintf(txtData + byteCount, "// NOTE: Original pixel data simplified to GRAYSCALE\n");
|
|
902
|
+
byteCount += sprintf(txtData + byteCount, "static unsigned char fontData_%s[COMPRESSED_DATA_SIZE_FONT_%s] = { ", fileNamePascal, TextToUpper(fileNamePascal));
|
|
903
|
+
for (int i = 0; i < compDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%02x,\n " : "0x%02x, "), compData[i]);
|
|
904
|
+
byteCount += sprintf(txtData + byteCount, "0x%02x };\n\n", compData[compDataSize - 1]);
|
|
905
|
+
MemFree(compData);
|
|
906
|
+
#else
|
|
907
|
+
// Save font image data (uncompressed)
|
|
908
|
+
byteCount += sprintf(txtData + byteCount, "// Font image pixels data\n");
|
|
909
|
+
byteCount += sprintf(txtData + byteCount, "// NOTE: 2 bytes per pixel, GRAY + ALPHA channels\n");
|
|
910
|
+
byteCount += sprintf(txtData + byteCount, "static unsigned char fontImageData_%s[%i] = { ", fileNamePascal, imageDataSize);
|
|
911
|
+
for (int i = 0; i < imageDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%02x,\n " : "0x%02x, "), ((unsigned char *)imFont.data)[i]);
|
|
912
|
+
byteCount += sprintf(txtData + byteCount, "0x%02x };\n\n", ((unsigned char *)imFont.data)[imageDataSize - 1]);
|
|
913
|
+
#endif
|
|
914
|
+
|
|
915
|
+
// Save font recs data
|
|
916
|
+
byteCount += sprintf(txtData + byteCount, "// Font characters rectangles data\n");
|
|
917
|
+
byteCount += sprintf(txtData + byteCount, "static const Rectangle fontRecs_%s[%i] = {\n", fileNamePascal, font.glyphCount);
|
|
918
|
+
for (int i = 0; i < font.glyphCount; i++)
|
|
919
|
+
{
|
|
920
|
+
byteCount += sprintf(txtData + byteCount, " { %1.0f, %1.0f, %1.0f , %1.0f },\n", font.recs[i].x, font.recs[i].y, font.recs[i].width, font.recs[i].height);
|
|
921
|
+
}
|
|
922
|
+
byteCount += sprintf(txtData + byteCount, "};\n\n");
|
|
923
|
+
|
|
924
|
+
// Save font glyphs data
|
|
925
|
+
// NOTE: Glyphs image data not saved (grayscale pixels),
|
|
926
|
+
// it could be generated from image and recs
|
|
927
|
+
byteCount += sprintf(txtData + byteCount, "// Font glyphs info data\n");
|
|
928
|
+
byteCount += sprintf(txtData + byteCount, "// NOTE: No glyphs.image data provided\n");
|
|
929
|
+
byteCount += sprintf(txtData + byteCount, "static const GlyphInfo fontGlyphs_%s[%i] = {\n", fileNamePascal, font.glyphCount);
|
|
930
|
+
for (int i = 0; i < font.glyphCount; i++)
|
|
931
|
+
{
|
|
932
|
+
byteCount += sprintf(txtData + byteCount, " { %i, %i, %i, %i, { 0 }},\n", font.glyphs[i].value, font.glyphs[i].offsetX, font.glyphs[i].offsetY, font.glyphs[i].advanceX);
|
|
933
|
+
}
|
|
934
|
+
byteCount += sprintf(txtData + byteCount, "};\n\n");
|
|
935
|
+
|
|
936
|
+
// Custom font loading function
|
|
937
|
+
byteCount += sprintf(txtData + byteCount, "// Font loading function: %s\n", fileNamePascal);
|
|
938
|
+
byteCount += sprintf(txtData + byteCount, "static Font LoadFont_%s(void)\n{\n", fileNamePascal);
|
|
939
|
+
byteCount += sprintf(txtData + byteCount, " Font font = { 0 };\n\n");
|
|
940
|
+
byteCount += sprintf(txtData + byteCount, " font.baseSize = %i;\n", font.baseSize);
|
|
941
|
+
byteCount += sprintf(txtData + byteCount, " font.glyphCount = %i;\n", font.glyphCount);
|
|
942
|
+
byteCount += sprintf(txtData + byteCount, " font.glyphPadding = %i;\n\n", font.glyphPadding);
|
|
943
|
+
byteCount += sprintf(txtData + byteCount, " // Custom font loading\n");
|
|
944
|
+
#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
|
|
945
|
+
byteCount += sprintf(txtData + byteCount, " // NOTE: Compressed font image data (DEFLATE), it requires DecompressData() function\n");
|
|
946
|
+
byteCount += sprintf(txtData + byteCount, " int fontDataSize_%s = 0;\n", fileNamePascal);
|
|
947
|
+
byteCount += sprintf(txtData + byteCount, " unsigned char *data = DecompressData(fontData_%s, COMPRESSED_DATA_SIZE_FONT_%s, &fontDataSize_%s);\n", fileNamePascal, TextToUpper(fileNamePascal), fileNamePascal);
|
|
948
|
+
byteCount += sprintf(txtData + byteCount, " Image imFont = { data, %i, %i, 1, %i };\n\n", image.width, image.height, image.format);
|
|
949
|
+
#else
|
|
950
|
+
byteCount += sprintf(txtData + byteCount, " Image imFont = { fontImageData_%s, %i, %i, 1, %i };\n\n", styleName, image.width, image.height, image.format);
|
|
951
|
+
#endif
|
|
952
|
+
byteCount += sprintf(txtData + byteCount, " // Load texture from image\n");
|
|
953
|
+
byteCount += sprintf(txtData + byteCount, " font.texture = LoadTextureFromImage(imFont);\n");
|
|
954
|
+
#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
|
|
955
|
+
byteCount += sprintf(txtData + byteCount, " UnloadImage(imFont); // Uncompressed data can be unloaded from memory\n\n");
|
|
956
|
+
#endif
|
|
957
|
+
// We have two possible mechanisms to assign font.recs and font.glyphs data,
|
|
958
|
+
// that data is already available as global arrays, we two options to assign that data:
|
|
959
|
+
// - 1. Data copy. This option consumes more memory and Font MUST be unloaded by user, requiring additional code.
|
|
960
|
+
// - 2. Data assignment. This option consumes less memory and Font MUST NOT be unloaded by user because data is on protected DATA segment
|
|
961
|
+
//#define SUPPORT_FONT_DATA_COPY
|
|
962
|
+
#if defined(SUPPORT_FONT_DATA_COPY)
|
|
963
|
+
byteCount += sprintf(txtData + byteCount, " // Copy glyph recs data from global fontRecs\n");
|
|
964
|
+
byteCount += sprintf(txtData + byteCount, " // NOTE: Required to avoid issues if trying to free font\n");
|
|
965
|
+
byteCount += sprintf(txtData + byteCount, " font.recs = (Rectangle *)malloc(font.glyphCount*sizeof(Rectangle));\n");
|
|
966
|
+
byteCount += sprintf(txtData + byteCount, " memcpy(font.recs, fontRecs_%s, font.glyphCount*sizeof(Rectangle));\n\n", fileNamePascal);
|
|
967
|
+
|
|
968
|
+
byteCount += sprintf(txtData + byteCount, " // Copy font glyph info data from global fontChars\n");
|
|
969
|
+
byteCount += sprintf(txtData + byteCount, " // NOTE: Required to avoid issues if trying to free font\n");
|
|
970
|
+
byteCount += sprintf(txtData + byteCount, " font.glyphs = (GlyphInfo *)malloc(font.glyphCount*sizeof(GlyphInfo));\n");
|
|
971
|
+
byteCount += sprintf(txtData + byteCount, " memcpy(font.glyphs, fontGlyphs_%s, font.glyphCount*sizeof(GlyphInfo));\n\n", fileNamePascal);
|
|
972
|
+
#else
|
|
973
|
+
byteCount += sprintf(txtData + byteCount, " // Assign glyph recs and info data directly\n");
|
|
974
|
+
byteCount += sprintf(txtData + byteCount, " // WARNING: This font data must not be unloaded\n");
|
|
975
|
+
byteCount += sprintf(txtData + byteCount, " font.recs = fontRecs_%s;\n", fileNamePascal);
|
|
976
|
+
byteCount += sprintf(txtData + byteCount, " font.glyphs = fontGlyphs_%s;\n\n", fileNamePascal);
|
|
977
|
+
#endif
|
|
978
|
+
byteCount += sprintf(txtData + byteCount, " return font;\n");
|
|
979
|
+
byteCount += sprintf(txtData + byteCount, "}\n");
|
|
980
|
+
|
|
981
|
+
UnloadImage(image);
|
|
982
|
+
|
|
983
|
+
// NOTE: Text data size exported is determined by '\0' (NULL) character
|
|
984
|
+
success = SaveFileText(fileName, txtData);
|
|
985
|
+
|
|
986
|
+
RL_FREE(txtData);
|
|
987
|
+
|
|
988
|
+
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Font as code exported successfully", fileName);
|
|
989
|
+
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export font as code", fileName);
|
|
990
|
+
|
|
991
|
+
return success;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
|
|
819
995
|
// Draw current FPS
|
|
820
996
|
// NOTE: Uses default font
|
|
821
997
|
void DrawFPS(int posX, int posY)
|
|
822
998
|
{
|
|
823
|
-
Color color = LIME;
|
|
999
|
+
Color color = LIME; // Good FPS
|
|
824
1000
|
int fps = GetFPS();
|
|
825
1001
|
|
|
826
|
-
if (fps < 30 && fps >= 15) color = ORANGE; //
|
|
827
|
-
else if (fps < 15) color = RED;
|
|
1002
|
+
if ((fps < 30) && (fps >= 15)) color = ORANGE; // Warning FPS
|
|
1003
|
+
else if (fps < 15) color = RED; // Low FPS
|
|
828
1004
|
|
|
829
1005
|
DrawText(TextFormat("%2i FPS", GetFPS()), posX, posY, 20, color);
|
|
830
1006
|
}
|
|
@@ -875,7 +1051,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
|
|
|
875
1051
|
{
|
|
876
1052
|
// NOTE: Fixed line spacing of 1.5 line-height
|
|
877
1053
|
// TODO: Support custom line spacing defined by user
|
|
878
|
-
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
|
1054
|
+
textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor);
|
|
879
1055
|
textOffsetX = 0.0f;
|
|
880
1056
|
}
|
|
881
1057
|
else
|
|
@@ -917,8 +1093,8 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz
|
|
|
917
1093
|
|
|
918
1094
|
// Character destination rectangle on screen
|
|
919
1095
|
// NOTE: We consider glyphPadding on drawing
|
|
920
|
-
Rectangle dstRec = { position.x + font.glyphs[index].offsetX*scaleFactor - (float)font.glyphPadding*scaleFactor,
|
|
921
|
-
position.y + font.glyphs[index].offsetY*scaleFactor - (float)font.glyphPadding*scaleFactor,
|
|
1096
|
+
Rectangle dstRec = { (int)position.x + font.glyphs[index].offsetX*scaleFactor - (float)font.glyphPadding*scaleFactor,
|
|
1097
|
+
(int)position.y + font.glyphs[index].offsetY*scaleFactor - (float)font.glyphPadding*scaleFactor,
|
|
922
1098
|
(font.recs[index].width + 2.0f*font.glyphPadding)*scaleFactor,
|
|
923
1099
|
(font.recs[index].height + 2.0f*font.glyphPadding)*scaleFactor };
|
|
924
1100
|
|
|
@@ -931,6 +1107,38 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz
|
|
|
931
1107
|
DrawTexturePro(font.texture, srcRec, dstRec, (Vector2){ 0, 0 }, 0.0f, tint);
|
|
932
1108
|
}
|
|
933
1109
|
|
|
1110
|
+
// Draw multiple character (codepoints)
|
|
1111
|
+
void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint)
|
|
1112
|
+
{
|
|
1113
|
+
int textOffsetY = 0; // Offset between lines (on line break '\n')
|
|
1114
|
+
float textOffsetX = 0.0f; // Offset X to next character to draw
|
|
1115
|
+
|
|
1116
|
+
float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
|
|
1117
|
+
|
|
1118
|
+
for (int i = 0; i < count; i++)
|
|
1119
|
+
{
|
|
1120
|
+
int index = GetGlyphIndex(font, codepoints[i]);
|
|
1121
|
+
|
|
1122
|
+
if (codepoints[i] == '\n')
|
|
1123
|
+
{
|
|
1124
|
+
// NOTE: Fixed line spacing of 1.5 line-height
|
|
1125
|
+
// TODO: Support custom line spacing defined by user
|
|
1126
|
+
textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor);
|
|
1127
|
+
textOffsetX = 0.0f;
|
|
1128
|
+
}
|
|
1129
|
+
else
|
|
1130
|
+
{
|
|
1131
|
+
if ((codepoints[i] != ' ') && (codepoints[i] != '\t'))
|
|
1132
|
+
{
|
|
1133
|
+
DrawTextCodepoint(font, codepoints[i], (Vector2){ position.x + textOffsetX, position.y + textOffsetY }, fontSize, tint);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
if (font.glyphs[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + spacing);
|
|
1137
|
+
else textOffsetX += ((float)font.glyphs[index].advanceX*scaleFactor + spacing);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
934
1142
|
// Measure string width for default font
|
|
935
1143
|
int MeasureText(const char *text, int fontSize)
|
|
936
1144
|
{
|
|
@@ -1142,7 +1350,10 @@ bool TextIsEqual(const char *text1, const char *text2)
|
|
|
1142
1350
|
{
|
|
1143
1351
|
bool result = false;
|
|
1144
1352
|
|
|
1145
|
-
if (
|
|
1353
|
+
if ((text1 != NULL) && (text2 != NULL))
|
|
1354
|
+
{
|
|
1355
|
+
if (strcmp(text1, text2) == 0) result = true;
|
|
1356
|
+
}
|
|
1146
1357
|
|
|
1147
1358
|
return result;
|
|
1148
1359
|
}
|
|
@@ -1151,6 +1362,7 @@ bool TextIsEqual(const char *text1, const char *text2)
|
|
|
1151
1362
|
const char *TextSubtext(const char *text, int position, int length)
|
|
1152
1363
|
{
|
|
1153
1364
|
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
1365
|
+
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
1154
1366
|
|
|
1155
1367
|
int textLength = TextLength(text);
|
|
1156
1368
|
|
|
@@ -1174,21 +1386,21 @@ const char *TextSubtext(const char *text, int position, int length)
|
|
|
1174
1386
|
}
|
|
1175
1387
|
|
|
1176
1388
|
// Replace text string
|
|
1177
|
-
// REQUIRES: strstr(), strncpy(), strcpy()
|
|
1178
|
-
// WARNING:
|
|
1389
|
+
// REQUIRES: strlen(), strstr(), strncpy(), strcpy()
|
|
1390
|
+
// WARNING: Allocated memory must be manually freed
|
|
1179
1391
|
char *TextReplace(char *text, const char *replace, const char *by)
|
|
1180
1392
|
{
|
|
1181
1393
|
// Sanity checks and initialization
|
|
1182
1394
|
if (!text || !replace || !by) return NULL;
|
|
1183
1395
|
|
|
1184
|
-
char *result;
|
|
1396
|
+
char *result = NULL;
|
|
1185
1397
|
|
|
1186
|
-
char *insertPoint;
|
|
1187
|
-
char *temp;
|
|
1188
|
-
int replaceLen; // Replace string length of (the string to remove)
|
|
1189
|
-
int byLen; // Replacement length (the string to replace replace by)
|
|
1190
|
-
int lastReplacePos; // Distance between replace and end of last replace
|
|
1191
|
-
int count; // Number of replacements
|
|
1398
|
+
char *insertPoint = NULL; // Next insert point
|
|
1399
|
+
char *temp = NULL; // Temp pointer
|
|
1400
|
+
int replaceLen = 0; // Replace string length of (the string to remove)
|
|
1401
|
+
int byLen = 0; // Replacement length (the string to replace replace by)
|
|
1402
|
+
int lastReplacePos = 0; // Distance between replace and end of last replace
|
|
1403
|
+
int count = 0; // Number of replacements
|
|
1192
1404
|
|
|
1193
1405
|
replaceLen = TextLength(replace);
|
|
1194
1406
|
if (replaceLen == 0) return NULL; // Empty replace causes infinite loop during count
|
|
@@ -1224,7 +1436,7 @@ char *TextReplace(char *text, const char *replace, const char *by)
|
|
|
1224
1436
|
}
|
|
1225
1437
|
|
|
1226
1438
|
// Insert text in a specific position, moves all text forward
|
|
1227
|
-
// WARNING: Allocated memory
|
|
1439
|
+
// WARNING: Allocated memory must be manually freed
|
|
1228
1440
|
char *TextInsert(const char *text, const char *insert, int position)
|
|
1229
1441
|
{
|
|
1230
1442
|
int textLen = TextLength(text);
|
|
@@ -1245,9 +1457,9 @@ char *TextInsert(const char *text, const char *insert, int position)
|
|
|
1245
1457
|
// REQUIRES: memset(), memcpy()
|
|
1246
1458
|
const char *TextJoin(const char **textList, int count, const char *delimiter)
|
|
1247
1459
|
{
|
|
1248
|
-
static char
|
|
1249
|
-
memset(
|
|
1250
|
-
char *textPtr =
|
|
1460
|
+
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
1461
|
+
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
1462
|
+
char *textPtr = buffer;
|
|
1251
1463
|
|
|
1252
1464
|
int totalLength = 0;
|
|
1253
1465
|
int delimiterLen = TextLength(delimiter);
|
|
@@ -1272,7 +1484,7 @@ const char *TextJoin(const char **textList, int count, const char *delimiter)
|
|
|
1272
1484
|
}
|
|
1273
1485
|
}
|
|
1274
1486
|
|
|
1275
|
-
return
|
|
1487
|
+
return buffer;
|
|
1276
1488
|
}
|
|
1277
1489
|
|
|
1278
1490
|
// Split string into multiple strings
|
|
@@ -1342,6 +1554,7 @@ int TextFindIndex(const char *text, const char *find)
|
|
|
1342
1554
|
const char *TextToUpper(const char *text)
|
|
1343
1555
|
{
|
|
1344
1556
|
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
1557
|
+
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
1345
1558
|
|
|
1346
1559
|
for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)
|
|
1347
1560
|
{
|
|
@@ -1364,6 +1577,7 @@ const char *TextToUpper(const char *text)
|
|
|
1364
1577
|
const char *TextToLower(const char *text)
|
|
1365
1578
|
{
|
|
1366
1579
|
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
1580
|
+
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
1367
1581
|
|
|
1368
1582
|
for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)
|
|
1369
1583
|
{
|
|
@@ -1383,6 +1597,7 @@ const char *TextToLower(const char *text)
|
|
|
1383
1597
|
const char *TextToPascal(const char *text)
|
|
1384
1598
|
{
|
|
1385
1599
|
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
1600
|
+
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
1386
1601
|
|
|
1387
1602
|
buffer[0] = (char)toupper(text[0]);
|
|
1388
1603
|
|
|
@@ -1405,8 +1620,8 @@ const char *TextToPascal(const char *text)
|
|
|
1405
1620
|
|
|
1406
1621
|
// Encode text codepoint into UTF-8 text
|
|
1407
1622
|
// REQUIRES: memcpy()
|
|
1408
|
-
// WARNING: Allocated memory
|
|
1409
|
-
char *TextCodepointsToUTF8(int *codepoints, int length)
|
|
1623
|
+
// WARNING: Allocated memory must be manually freed
|
|
1624
|
+
char *TextCodepointsToUTF8(const int *codepoints, int length)
|
|
1410
1625
|
{
|
|
1411
1626
|
// We allocate enough memory fo fit all possible codepoints
|
|
1412
1627
|
// NOTE: 5 bytes for every codepoint should be enough
|
|
@@ -1586,7 +1801,7 @@ int GetCodepoint(const char *text, int *bytesProcessed)
|
|
|
1586
1801
|
if (((octet == 0xe0) && !((octet1 >= 0xa0) && (octet1 <= 0xbf))) ||
|
|
1587
1802
|
((octet == 0xed) && !((octet1 >= 0x80) && (octet1 <= 0x9f)))) { *bytesProcessed = 2; return code; }
|
|
1588
1803
|
|
|
1589
|
-
if ((octet >= 0xe0) && (
|
|
1804
|
+
if ((octet >= 0xe0) && (octet <= 0xef))
|
|
1590
1805
|
{
|
|
1591
1806
|
code = ((octet & 0xf) << 12) | ((octet1 & 0x3f) << 6) | (octet2 & 0x3f);
|
|
1592
1807
|
*bytesProcessed = 3;
|
|
@@ -1662,7 +1877,7 @@ static Font LoadBMFont(const char *fileName)
|
|
|
1662
1877
|
|
|
1663
1878
|
int imWidth = 0;
|
|
1664
1879
|
int imHeight = 0;
|
|
1665
|
-
char imFileName[129];
|
|
1880
|
+
char imFileName[129] = { 0 };
|
|
1666
1881
|
|
|
1667
1882
|
int base = 0; // Useless data
|
|
1668
1883
|
|
|
@@ -1788,3 +2003,5 @@ static Font LoadBMFont(const char *fileName)
|
|
|
1788
2003
|
return font;
|
|
1789
2004
|
}
|
|
1790
2005
|
#endif
|
|
2006
|
+
|
|
2007
|
+
#endif // SUPPORT_MODULE_RTEXT
|