glyphrun.odin (2863B)
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 //! Flags used by \ref BLGlyphRun. 19 GlyphRunFlags :: enum u32 { 20 //! No flags. 21 NO_FLAGS = 0, 22 23 //! Glyph-run contains UCS-4 string and not glyphs (glyph-buffer only). 24 FLAG_UCS4_CONTENT = 268435456, 25 26 //! Glyph-run was created from text that was not a valid unicode. 27 FLAG_INVALID_TEXT = 536870912, 28 29 //! Not the whole text was mapped to glyphs (contains undefined glyphs). 30 FLAG_UNDEFINED_GLYPHS = 1073741824, 31 32 //! Encountered invalid font data during text / glyph processing. 33 FLAG_INVALID_FONT_DATA = 2147483648, 34 FLAG_FORCE_UINT = 4294967295, 35 } 36 37 //! Placement of glyphs stored in a \ref BLGlyphRun. 38 GlyphPlacementType :: enum u32 { 39 //! No placement (custom handling by \ref BLPathSinkFunc). 40 NONE = 0, 41 42 //! Each glyph has a BLGlyphPlacement (advance + offset). 43 ADVANCE_OFFSET = 1, 44 45 //! Each glyph has a BLPoint offset in design-space units. 46 DESIGN_UNITS = 2, 47 48 //! Each glyph has a BLPoint offset in user-space units. 49 USER_UNITS = 3, 50 51 //! Each glyph has a BLPoint offset in absolute units. 52 ABSOLUTE_UNITS = 4, 53 54 //! Maximum value of `BLGlyphPlacementType`. 55 MAX_VALUE = 4, 56 FORCE_UINT = 4294967295, 57 } 58 59 //! BLGlyphRun describes a set of consecutive glyphs and their placements. 60 //! 61 //! BLGlyphRun should only be used to pass glyph IDs and their placements to the rendering context. The purpose of 62 //! BLGlyphRun is to allow rendering glyphs, which could be shaped by various shaping engines (Blend2D, Harfbuzz, etc). 63 //! 64 //! BLGlyphRun allows to render glyphs that are stored as uint32_t[] array or part of a bigger structure (for example 65 //! `hb_glyph_info_t` used by HarfBuzz). Glyph placements at the moment use Blend2D's \ref BLGlyphPlacement or \ref 66 //! BLPoint, but it's possible to extend the data type in the future. 67 //! 68 //! See `BLGlyphRunPlacement` for placement modes provided by Blend2D. 69 GlyphRun :: struct { 70 //! \name Members 71 //! \{ 72 73 //! Glyph id data (abstract, incremented by `glyph_advance`). 74 glyph_data: rawptr, 75 76 //! Glyph placement data (abstract, incremented by `placement_advance`). 77 placement_data: rawptr, 78 79 //! Size of the glyph-run in glyph units. 80 size: c.size_t, 81 82 //! Reserved for future use, muse be zero. 83 reserved: u8, 84 85 //! Type of placement, see \ref BLGlyphPlacementType. 86 placement_type: u8, 87 88 //! Advance of `glyph_data` array. 89 glyph_advance: i8, 90 91 //! Advance of `placement_data` array. 92 placement_advance: i8, 93 94 //! Glyph-run flags. 95 flags: u32, 96 } 97