glyphbuffer.odin (3287B)
1 // This file is part of Blend2D project <https://blend2d.com> 2 // 3 // See blend2d.h or LICENSE.md for license and copyright information 4 // SPDX-License-Identifier: Zlib 5 package blend2d 6 7 import "core:c" 8 9 when ODIN_OS == .Windows { 10 foreign import lib "blend2d.lib" 11 } else when ODIN_OS == .Darwin { 12 foreign import lib "libblend2d.a" 13 } else when ODIN_OS == .Linux { 14 foreign import lib "libblend2d.a" 15 } 16 17 18 //! Glyph buffer [Impl]. 19 //! 20 //! \note This is not a `BLObjectImpl` compatible Impl. 21 GlyphBufferImpl :: struct { 22 using _: struct #raw_union { 23 using _: struct { 24 //! Text (UCS4 code-points) or glyph content. 25 content: ^u32, 26 27 //! Glyph placement data. 28 placement_data: ^GlyphPlacement, 29 30 //! Number of either code points or glyph indexes in the glyph-buffer. 31 size: c.size_t, 32 33 //! Reserved, used exclusively by BLGlyphRun. 34 reserved: u32, 35 36 //! Flags shared between BLGlyphRun and BLGlyphBuffer. 37 flags: u32, 38 }, 39 40 //! Glyph run data that can be passed directly to the rendering context. 41 //! 42 //! Glyph run shares data with other members like `content`, `placement_data`, `size`, and `flags`. When working 43 //! with data it's better to access these members directly as they are typed, whereas \ref BLGlyphRun stores 44 //! pointers as `const void*` as it offers more flexibility, which \ref BLGlyphRun doesn't need. 45 glyph_run: GlyphRun, 46 }, 47 48 //! Glyph info data - additional information of each code-point or glyph. 49 info_data: ^GlyphInfo, 50 } 51 52 //! Glyph buffer [C API]. 53 GlyphBufferCore :: struct { 54 impl: ^GlyphBufferImpl, 55 BL_DEFINE_OBJECT_DCAST: proc "c" () -> i32, 56 } 57 58 @(default_calling_convention="c", link_prefix="bl_") 59 foreign lib { 60 glyph_buffer_init :: proc(self: ^GlyphBufferCore) -> Result --- 61 glyph_buffer_init_move :: proc(self: ^GlyphBufferCore, other: ^GlyphBufferCore) -> Result --- 62 glyph_buffer_destroy :: proc(self: ^GlyphBufferCore) -> Result --- 63 glyph_buffer_reset :: proc(self: ^GlyphBufferCore) -> Result --- 64 glyph_buffer_clear :: proc(self: ^GlyphBufferCore) -> Result --- 65 glyph_buffer_get_size :: proc(self: ^GlyphBufferCore) -> c.size_t --- 66 glyph_buffer_get_flags :: proc(self: ^GlyphBufferCore) -> u32 --- 67 glyph_buffer_get_glyph_run :: proc(self: ^GlyphBufferCore) -> ^GlyphRun --- 68 glyph_buffer_get_content :: proc(self: ^GlyphBufferCore) -> ^u32 --- 69 glyph_buffer_get_info_data :: proc(self: ^GlyphBufferCore) -> ^GlyphInfo --- 70 glyph_buffer_get_placement_data :: proc(self: ^GlyphBufferCore) -> ^GlyphPlacement --- 71 glyph_buffer_set_text :: proc(self: ^GlyphBufferCore, text_data: rawptr, size: c.size_t, encoding: TextEncoding) -> Result --- 72 glyph_buffer_set_glyphs :: proc(self: ^GlyphBufferCore, glyph_data: ^u32, size: c.size_t) -> Result --- 73 glyph_buffer_set_glyphs_from_struct :: proc(self: ^GlyphBufferCore, glyph_data: rawptr, size: c.size_t, glyph_id_size: c.size_t, glyph_id_advance: c.intptr_t) -> Result --- 74 glyph_buffer_set_debug_sink :: proc(self: ^GlyphBufferCore, sink: DebugMessageSinkFunc, user_data: rawptr) -> Result --- 75 glyph_buffer_reset_debug_sink :: proc(self: ^GlyphBufferCore) -> Result --- 76 } 77