odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

fontfeaturesettings.odin (4189B)


      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 //! Font feature settings [C API].
     19 FontFeatureSettingsCore :: struct {
     20 	_d: ObjectDetail,
     21 }
     22 
     23 //! \cond INTERNAL
     24 //! Font feature settings [C API Impl].
     25 //!
     26 //! \note This Impl's layout is fully compatible with \ref BLArrayImpl.
     27 FontFeatureSettingsImpl :: struct {
     28 	//! Pointer to feature items.
     29 	data: ^FontFeatureItem,
     30 
     31 	//! Number of feature items in `data`.
     32 	size: c.size_t,
     33 
     34 	//! Capacity of `data`.
     35 	capacity: c.size_t,
     36 }
     37 
     38 @(default_calling_convention="c", link_prefix="bl_")
     39 foreign lib {
     40 	//! \endcond
     41 	font_feature_settings_init         :: proc(self: ^FontFeatureSettingsCore) -> Result ---
     42 	font_feature_settings_init_move    :: proc(self: ^FontFeatureSettingsCore, other: ^FontFeatureSettingsCore) -> Result ---
     43 	font_feature_settings_init_weak    :: proc(self: ^FontFeatureSettingsCore, other: ^FontFeatureSettingsCore) -> Result ---
     44 	font_feature_settings_destroy      :: proc(self: ^FontFeatureSettingsCore) -> Result ---
     45 	font_feature_settings_reset        :: proc(self: ^FontFeatureSettingsCore) -> Result ---
     46 	font_feature_settings_clear        :: proc(self: ^FontFeatureSettingsCore) -> Result ---
     47 	font_feature_settings_shrink       :: proc(self: ^FontFeatureSettingsCore) -> Result ---
     48 	font_feature_settings_assign_move  :: proc(self: ^FontFeatureSettingsCore, other: ^FontFeatureSettingsCore) -> Result ---
     49 	font_feature_settings_assign_weak  :: proc(self: ^FontFeatureSettingsCore, other: ^FontFeatureSettingsCore) -> Result ---
     50 	font_feature_settings_get_size     :: proc(self: ^FontFeatureSettingsCore) -> c.size_t ---
     51 	font_feature_settings_get_capacity :: proc(self: ^FontFeatureSettingsCore) -> c.size_t ---
     52 	font_feature_settings_get_view     :: proc(self: ^FontFeatureSettingsCore, out: ^FontFeatureSettingsView) -> Result ---
     53 	font_feature_settings_has_value    :: proc(self: ^FontFeatureSettingsCore, feature_tag: Tag) -> i32 ---
     54 	font_feature_settings_get_value    :: proc(self: ^FontFeatureSettingsCore, feature_tag: Tag) -> u32 ---
     55 	font_feature_settings_set_value    :: proc(self: ^FontFeatureSettingsCore, feature_tag: Tag, value: u32) -> Result ---
     56 	font_feature_settings_remove_value :: proc(self: ^FontFeatureSettingsCore, feature_tag: Tag) -> Result ---
     57 	font_feature_settings_equals       :: proc(a: ^FontFeatureSettingsCore, b: ^FontFeatureSettingsCore) -> i32 ---
     58 }
     59 
     60 //! Associates a font feature tag with a value. Tag describes the feature (as provided by the font) and `value`
     61 //! describes its value. Some features only allow boolean values 0 and 1 and some allow values up to 65535.
     62 //! Values above 65535 are invalid, however, only \ref BL_FONT_FEATURE_INVALID_VALUE should be used as invalid
     63 //! value in general.
     64 //!
     65 //! Registered OpenType features:
     66 //!   - https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags
     67 //!   - https://helpx.adobe.com/typekit/using/open-type-syntax.html
     68 FontFeatureItem :: struct {
     69 	//! \name Members
     70 	//! \{
     71 	
     72 	//! Feature tag (32-bit).
     73 	tag: Tag,
     74 
     75 	//! Feature value.
     76 	//!
     77 	//! \note values greater than 65535 are invalid.
     78 	value: u32,
     79 }
     80 
     81 //! A view unifying the representation of an internal storage used by \ref BLFontFeatureSettings.
     82 FontFeatureSettingsView :: struct {
     83 	//! \name Members
     84 	//! \{
     85 	
     86 	//! Pointer to font feature items, where each item describes a tag and its value.
     87 	//!
     88 	//! \note If the container is in SSO mode the `data` member will point to `sso_data`.
     89 	data: ^FontFeatureItem,
     90 
     91 	//! Count of items in `data.
     92 	size: c.size_t,
     93 
     94 	//! Unpacked SSO items into \ref BLFontFeatureItem array.
     95 	//!
     96 	//! \note This member won't be initialized or zeroed in case \ref BLFontFeatureSettings is not in SSO mode. And if the
     97 	//! container is in SSO mode only the number of items used will be overwritten by \ref BLFontFeatureSettings::get_view().
     98 	sso_data: [36]FontFeatureItem,
     99 }
    100