From 513c410eb998f2e38745a553395edb6e0a25dc88 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 15 Aug 2023 15:01:40 -0700 Subject: [PATCH] freetype: update bindings to include Paint API --- deps/freetype/bindings.h | 1 + deps/freetype/src/lib.rs | 382 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 383 insertions(+) diff --git a/deps/freetype/bindings.h b/deps/freetype/bindings.h index d11b11aa16b..dcbc87032de 100644 --- a/deps/freetype/bindings.h +++ b/deps/freetype/bindings.h @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/deps/freetype/src/lib.rs b/deps/freetype/src/lib.rs index 638653dabe9..a96f0f1c899 100644 --- a/deps/freetype/src/lib.rs +++ b/deps/freetype/src/lib.rs @@ -12,6 +12,49 @@ pub type FT_UInt32 = u32; pub type FT_Int64 = i64; pub type FT_UInt64 = u64; +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub const fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { + Self::new() + } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { + Self::new() + } +} +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} +} +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } +} +impl ::std::cmp::Eq for __BindgenUnionField {} pub const FT_RENDER_POOL_SIZE: u32 = 16384; pub const FT_MAX_MODULES: u32 = 32; pub const TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES: u32 = 1000000; @@ -104,6 +147,8 @@ pub const FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING: u32 = 4; pub const FT_FSTYPE_EDITABLE_EMBEDDING: u32 = 8; pub const FT_FSTYPE_NO_SUBSETTING: u32 = 256; pub const FT_FSTYPE_BITMAP_EMBEDDING_ONLY: u32 = 512; +pub const FT_PALETTE_FOR_LIGHT_BACKGROUND: u32 = 1; +pub const FT_PALETTE_FOR_DARK_BACKGROUND: u32 = 2; pub const FT_LCD_FILTER_FIVE_TAPS: u32 = 5; pub const FT_MODULE_FONT_DRIVER: u32 = 1; pub const FT_MODULE_RENDERER: u32 = 2; @@ -1787,6 +1832,343 @@ extern "C" { extern "C" { pub fn FT_Face_SetUnpatentedHinting(face: FT_Face, value: FT_Bool) -> FT_Bool; } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_Color_ { + pub blue: FT_Byte, + pub green: FT_Byte, + pub red: FT_Byte, + pub alpha: FT_Byte, +} +pub type FT_Color = FT_Color_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_Palette_Data_ { + pub num_palettes: FT_UShort, + pub palette_name_ids: *const FT_UShort, + pub palette_flags: *const FT_UShort, + pub num_palette_entries: FT_UShort, + pub palette_entry_name_ids: *const FT_UShort, +} +pub type FT_Palette_Data = FT_Palette_Data_; +extern "C" { + pub fn FT_Palette_Data_Get(face: FT_Face, apalette: *mut FT_Palette_Data) -> FT_Error; +} +extern "C" { + pub fn FT_Palette_Select( + face: FT_Face, + palette_index: FT_UShort, + apalette: *mut *mut FT_Color, + ) -> FT_Error; +} +extern "C" { + pub fn FT_Palette_Set_Foreground_Color(face: FT_Face, foreground_color: FT_Color) -> FT_Error; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_LayerIterator_ { + pub num_layers: FT_UInt, + pub layer: FT_UInt, + pub p: *mut FT_Byte, +} +pub type FT_LayerIterator = FT_LayerIterator_; +extern "C" { + pub fn FT_Get_Color_Glyph_Layer( + face: FT_Face, + base_glyph: FT_UInt, + aglyph_index: *mut FT_UInt, + acolor_index: *mut FT_UInt, + iterator: *mut FT_LayerIterator, + ) -> FT_Bool; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum FT_PaintFormat_ { + FT_COLR_PAINTFORMAT_COLR_LAYERS = 1, + FT_COLR_PAINTFORMAT_SOLID = 2, + FT_COLR_PAINTFORMAT_LINEAR_GRADIENT = 4, + FT_COLR_PAINTFORMAT_RADIAL_GRADIENT = 6, + FT_COLR_PAINTFORMAT_SWEEP_GRADIENT = 8, + FT_COLR_PAINTFORMAT_GLYPH = 10, + FT_COLR_PAINTFORMAT_COLR_GLYPH = 11, + FT_COLR_PAINTFORMAT_TRANSFORM = 12, + FT_COLR_PAINTFORMAT_TRANSLATE = 14, + FT_COLR_PAINTFORMAT_SCALE = 16, + FT_COLR_PAINTFORMAT_ROTATE = 24, + FT_COLR_PAINTFORMAT_SKEW = 28, + FT_COLR_PAINTFORMAT_COMPOSITE = 32, + FT_COLR_PAINT_FORMAT_MAX = 33, + FT_COLR_PAINTFORMAT_UNSUPPORTED = 255, +} +pub use self::FT_PaintFormat_ as FT_PaintFormat; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_ColorStopIterator_ { + pub num_color_stops: FT_UInt, + pub current_color_stop: FT_UInt, + pub p: *mut FT_Byte, + pub read_variable: FT_Bool, +} +pub type FT_ColorStopIterator = FT_ColorStopIterator_; +#[repr(C)] +pub struct FT_ColorIndex_ { + pub palette_index: FT_UInt16, + pub alpha: FT_F2Dot14, +} +pub type FT_ColorIndex = FT_ColorIndex_; +#[repr(C)] +pub struct FT_ColorStop_ { + pub stop_offset: FT_Fixed, + pub color: FT_ColorIndex, +} +pub type FT_ColorStop = FT_ColorStop_; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum FT_PaintExtend_ { + FT_COLR_PAINT_EXTEND_PAD = 0, + FT_COLR_PAINT_EXTEND_REPEAT = 1, + FT_COLR_PAINT_EXTEND_REFLECT = 2, +} +pub use self::FT_PaintExtend_ as FT_PaintExtend; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_ColorLine_ { + pub extend: FT_PaintExtend, + pub color_stop_iterator: FT_ColorStopIterator, +} +pub type FT_ColorLine = FT_ColorLine_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_Affine_23_ { + pub xx: FT_Fixed, + pub xy: FT_Fixed, + pub dx: FT_Fixed, + pub yx: FT_Fixed, + pub yy: FT_Fixed, + pub dy: FT_Fixed, +} +pub type FT_Affine23 = FT_Affine_23_; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum FT_Composite_Mode_ { + FT_COLR_COMPOSITE_CLEAR = 0, + FT_COLR_COMPOSITE_SRC = 1, + FT_COLR_COMPOSITE_DEST = 2, + FT_COLR_COMPOSITE_SRC_OVER = 3, + FT_COLR_COMPOSITE_DEST_OVER = 4, + FT_COLR_COMPOSITE_SRC_IN = 5, + FT_COLR_COMPOSITE_DEST_IN = 6, + FT_COLR_COMPOSITE_SRC_OUT = 7, + FT_COLR_COMPOSITE_DEST_OUT = 8, + FT_COLR_COMPOSITE_SRC_ATOP = 9, + FT_COLR_COMPOSITE_DEST_ATOP = 10, + FT_COLR_COMPOSITE_XOR = 11, + FT_COLR_COMPOSITE_PLUS = 12, + FT_COLR_COMPOSITE_SCREEN = 13, + FT_COLR_COMPOSITE_OVERLAY = 14, + FT_COLR_COMPOSITE_DARKEN = 15, + FT_COLR_COMPOSITE_LIGHTEN = 16, + FT_COLR_COMPOSITE_COLOR_DODGE = 17, + FT_COLR_COMPOSITE_COLOR_BURN = 18, + FT_COLR_COMPOSITE_HARD_LIGHT = 19, + FT_COLR_COMPOSITE_SOFT_LIGHT = 20, + FT_COLR_COMPOSITE_DIFFERENCE = 21, + FT_COLR_COMPOSITE_EXCLUSION = 22, + FT_COLR_COMPOSITE_MULTIPLY = 23, + FT_COLR_COMPOSITE_HSL_HUE = 24, + FT_COLR_COMPOSITE_HSL_SATURATION = 25, + FT_COLR_COMPOSITE_HSL_COLOR = 26, + FT_COLR_COMPOSITE_HSL_LUMINOSITY = 27, + FT_COLR_COMPOSITE_MAX = 28, +} +pub use self::FT_Composite_Mode_ as FT_Composite_Mode; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_Opaque_Paint_ { + pub p: *mut FT_Byte, + pub insert_root_transform: FT_Bool, +} +pub type FT_OpaquePaint = FT_Opaque_Paint_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintColrLayers_ { + pub layer_iterator: FT_LayerIterator, +} +pub type FT_PaintColrLayers = FT_PaintColrLayers_; +#[repr(C)] +pub struct FT_PaintSolid_ { + pub color: FT_ColorIndex, +} +pub type FT_PaintSolid = FT_PaintSolid_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintLinearGradient_ { + pub colorline: FT_ColorLine, + pub p0: FT_Vector, + pub p1: FT_Vector, + pub p2: FT_Vector, +} +pub type FT_PaintLinearGradient = FT_PaintLinearGradient_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintRadialGradient_ { + pub colorline: FT_ColorLine, + pub c0: FT_Vector, + pub r0: FT_Pos, + pub c1: FT_Vector, + pub r1: FT_Pos, +} +pub type FT_PaintRadialGradient = FT_PaintRadialGradient_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintSweepGradient_ { + pub colorline: FT_ColorLine, + pub center: FT_Vector, + pub start_angle: FT_Fixed, + pub end_angle: FT_Fixed, +} +pub type FT_PaintSweepGradient = FT_PaintSweepGradient_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintGlyph_ { + pub paint: FT_OpaquePaint, + pub glyphID: FT_UInt, +} +pub type FT_PaintGlyph = FT_PaintGlyph_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintColrGlyph_ { + pub glyphID: FT_UInt, +} +pub type FT_PaintColrGlyph = FT_PaintColrGlyph_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintTransform_ { + pub paint: FT_OpaquePaint, + pub affine: FT_Affine23, +} +pub type FT_PaintTransform = FT_PaintTransform_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintTranslate_ { + pub paint: FT_OpaquePaint, + pub dx: FT_Fixed, + pub dy: FT_Fixed, +} +pub type FT_PaintTranslate = FT_PaintTranslate_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintScale_ { + pub paint: FT_OpaquePaint, + pub scale_x: FT_Fixed, + pub scale_y: FT_Fixed, + pub center_x: FT_Fixed, + pub center_y: FT_Fixed, +} +pub type FT_PaintScale = FT_PaintScale_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintRotate_ { + pub paint: FT_OpaquePaint, + pub angle: FT_Fixed, + pub center_x: FT_Fixed, + pub center_y: FT_Fixed, +} +pub type FT_PaintRotate = FT_PaintRotate_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintSkew_ { + pub paint: FT_OpaquePaint, + pub x_skew_angle: FT_Fixed, + pub y_skew_angle: FT_Fixed, + pub center_x: FT_Fixed, + pub center_y: FT_Fixed, +} +pub type FT_PaintSkew = FT_PaintSkew_; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_PaintComposite_ { + pub source_paint: FT_OpaquePaint, + pub composite_mode: FT_Composite_Mode, + pub backdrop_paint: FT_OpaquePaint, +} +pub type FT_PaintComposite = FT_PaintComposite_; +#[repr(C)] +pub struct FT_COLR_Paint_ { + pub format: FT_PaintFormat, + pub u: FT_COLR_Paint___bindgen_ty_1, +} +#[repr(C)] +pub struct FT_COLR_Paint___bindgen_ty_1 { + pub colr_layers: __BindgenUnionField, + pub glyph: __BindgenUnionField, + pub solid: __BindgenUnionField, + pub linear_gradient: __BindgenUnionField, + pub radial_gradient: __BindgenUnionField, + pub sweep_gradient: __BindgenUnionField, + pub transform: __BindgenUnionField, + pub translate: __BindgenUnionField, + pub scale: __BindgenUnionField, + pub rotate: __BindgenUnionField, + pub skew: __BindgenUnionField, + pub composite: __BindgenUnionField, + pub colr_glyph: __BindgenUnionField, + pub bindgen_union_field: [u64; 10usize], +} +pub type FT_COLR_Paint = FT_COLR_Paint_; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum FT_Color_Root_Transform_ { + FT_COLOR_INCLUDE_ROOT_TRANSFORM = 0, + FT_COLOR_NO_ROOT_TRANSFORM = 1, + FT_COLOR_ROOT_TRANSFORM_MAX = 2, +} +pub use self::FT_Color_Root_Transform_ as FT_Color_Root_Transform; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FT_ClipBox_ { + pub bottom_left: FT_Vector, + pub top_left: FT_Vector, + pub top_right: FT_Vector, + pub bottom_right: FT_Vector, +} +pub type FT_ClipBox = FT_ClipBox_; +extern "C" { + pub fn FT_Get_Color_Glyph_Paint( + face: FT_Face, + base_glyph: FT_UInt, + root_transform: FT_Color_Root_Transform, + paint: *mut FT_OpaquePaint, + ) -> FT_Bool; +} +extern "C" { + pub fn FT_Get_Color_Glyph_ClipBox( + face: FT_Face, + base_glyph: FT_UInt, + clip_box: *mut FT_ClipBox, + ) -> FT_Bool; +} +extern "C" { + pub fn FT_Get_Paint_Layers( + face: FT_Face, + iterator: *mut FT_LayerIterator, + paint: *mut FT_OpaquePaint, + ) -> FT_Bool; +} +extern "C" { + pub fn FT_Get_Colorline_Stops( + face: FT_Face, + color_stop: *mut FT_ColorStop, + iterator: *mut FT_ColorStopIterator, + ) -> FT_Bool; +} +extern "C" { + pub fn FT_Get_Paint( + face: FT_Face, + opaque_paint: FT_OpaquePaint, + paint: *mut FT_COLR_Paint, + ) -> FT_Bool; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum FT_LcdFilter_ {