├── .github └── FUNDING.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── COPYRIGHT ├── Cargo.toml ├── Gir.toml ├── LICENSE ├── Makefile ├── README.md ├── appveyor.yml ├── build.rs ├── src ├── analysis.rs ├── attr_class.rs ├── attr_iterator.rs ├── attr_list.rs ├── attribute.rs ├── auto │ ├── alias.rs │ ├── attr_iterator.rs │ ├── attr_list.rs │ ├── attribute.rs │ ├── color.rs │ ├── constants.rs │ ├── context.rs │ ├── engine_lang.rs │ ├── engine_shape.rs │ ├── enums.rs │ ├── flags.rs │ ├── font.rs │ ├── font_description.rs │ ├── font_face.rs │ ├── font_family.rs │ ├── font_map.rs │ ├── font_metrics.rs │ ├── fontset.rs │ ├── fontset_simple.rs │ ├── functions.rs │ ├── glyph_item.rs │ ├── glyph_item_iter.rs │ ├── glyph_string.rs │ ├── item.rs │ ├── layout.rs │ ├── layout_iter.rs │ ├── layout_line.rs │ ├── matrix.rs │ ├── mod.rs │ ├── renderer.rs │ ├── tab_array.rs │ └── versions.txt ├── coverage.rs ├── functions.rs ├── glyph.rs ├── gravity.rs ├── item.rs ├── language.rs ├── lib.rs ├── prelude.rs └── rectangle.rs └── tests └── check_gir.rs /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: gtk-rs 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/bin/ 2 | target/ 3 | doc/ 4 | configure.in 5 | config.log 6 | config.status 7 | *.dylib 8 | .rust 9 | *.so 10 | *.o 11 | *.swp 12 | Cargo.lock 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gir"] 2 | path = gir 3 | url = https://github.com/gtk-rs/gir.git 4 | [submodule "gir-files"] 5 | path = gir-files 6 | url = https://github.com/gtk-rs/gir-files.git 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: rust 3 | os: 4 | - linux 5 | - osx 6 | rust: 7 | - nightly 8 | - beta 9 | - stable 10 | - 1.40.0 11 | env: 12 | - GTK=3.14 FEATURES= 13 | - GTK=3.24 FEATURES=v1_38 14 | jobs: 15 | exclude: 16 | - os: osx 17 | env: GTK=3.24 FEATURES=v1_38 18 | 19 | addons: 20 | apt: 21 | packages: 22 | - libgtk-3-dev 23 | - libmount-dev 24 | 25 | before_install: 26 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi 27 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink python@2; fi 28 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gtk+3 cairo atk; fi 29 | 30 | script: 31 | - rustc --version 32 | - if [ "$TRAVIS_RUST_VERSION" == "stable" ] && [ "$GTK" == "3.14" ]; then 33 | rustup component add rustfmt; 34 | make regen_check; 35 | fi 36 | - cargo doc --features "dox,embed-lgpl-docs" 37 | - cargo test --features "$FEATURES,embed-lgpl-docs" 38 | # catch any sneaked in lgpl docs 39 | - cargo build --features "$FEATURES,purge-lgpl-docs" --jobs 1 40 | - git diff -R --exit-code 41 | - rustc --version 42 | - mkdir .cargo 43 | - echo 'paths = ["."]' > .cargo/config 44 | - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples 45 | - cd _examples 46 | - ./build_travis.sh 47 | - if [ "$TRAVIS_RUST_VERSION" == "stable" ] && [ "$GTK" == "3.14" ]; then 48 | cd ..; 49 | git clone https://github.com/gtk-rs/checker; 50 | cd checker && cargo build --release; 51 | cd .. && ./checker/target/release/checker .; 52 | fi 53 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | The Gtk-rs Project is copyright 2013-2016, The Gtk-rs Project Developers: 2 | 3 | Adam Crume 4 | Adolfo Ochagavía 5 | Andre Bogus 6 | Anton Konjahin 7 | Arne Dussin 8 | Boden Garman 9 | Brian Kropf 10 | Bryant Mairs 11 | Chris Greenaway 12 | Chris Palmer 13 | Corey Farwell 14 | Daniel Zalevskiy 15 | David Li 16 | Edward Shaw 17 | Edward Yang 18 | Esption 19 | Evgenii Pashkin 20 | Geoffrey French 21 | Gleb Kozyrev 22 | Glenn Watson 23 | Google Inc. 24 | Guillaume Gomez 25 | Gulshan Singh 26 | Jakob Gillich 27 | James Shepherdson 28 | Jeremy Letang 29 | John Vrbanac 30 | kennytm 31 | Laurence Tratt 32 | Lionel Flandrin 33 | Lucas Werkmeister 34 | Lukas Diekmann 35 | Mathijs Henquet 36 | Maxwell Koo 37 | mitaa 38 | Nick Herman 39 | Nicolas Koch 40 | Oliver Schneider 41 | Ömer Sinan Ağacan 42 | Ralph Giles 43 | Paul Dennis 44 | Paul Hendry 45 | Philipp Brüschweiler 46 | Raphael Nestler 47 | Robertas 48 | Romain Gauthier 49 | S.J.R. van Schaik 50 | Sebastian Schulze 51 | Silvio Fricke 52 | Simon Sapin 53 | Steve Klabnik 54 | Tobias Bales 55 | trolleyman 56 | Umur Gedik 57 | UrKr 58 | Vojtech Kral 59 | Zach Oakes 60 | Zach Ploskey 61 | 62 | The Gtk-rs Project is licensed under the MIT license, see the LICENSE file 63 | or . 64 | 65 | This project provides interoperability with various GNOME libraries but doesn't 66 | distribute any parts of them. Distributing compiled libraries and executables 67 | that link to those libraries may be subject to terms of the GNU LGPL, see the 68 | LGPL file. 69 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pango" 3 | documentation = "https://gtk-rs.org/docs/pango/" 4 | homepage = "https://gtk-rs.org/" 5 | authors = ["The Gtk-rs Project Developers"] 6 | keywords = ["pango", "gtk-rs", "gnome"] 7 | readme = "README.md" 8 | version = "0.9.0" 9 | description = "Rust bindings for the Pango library" 10 | repository = "https://github.com/gtk-rs/pango" 11 | license = "MIT" 12 | exclude = [ 13 | "gir-files/*", 14 | ] 15 | 16 | [badges] 17 | appveyor = { repository = "GuillaumeGomez/pango", service = "github" } 18 | travis-ci = { repository = "gtk-rs/pango" } 19 | 20 | [features] 21 | v1_38 = ["pango-sys/v1_38"] 22 | v1_40 = ["v1_38"] 23 | v1_42 = ["v1_40", "pango-sys/v1_42"] 24 | v1_44 = ["v1_42", "pango-sys/v1_44"] 25 | v1_46 = ["v1_44", "pango-sys/v1_46"] 26 | dox = ["pango-sys/dox", "glib/dox"] 27 | purge-lgpl-docs = ["gtk-rs-lgpl-docs"] 28 | embed-lgpl-docs = ["gtk-rs-lgpl-docs"] 29 | 30 | [package.metadata.docs.rs] 31 | features = ["dox", "embed-lgpl-docs"] 32 | 33 | [build-dependencies.gtk-rs-lgpl-docs] 34 | version = "0.1" 35 | optional = true 36 | git = "https://github.com/gtk-rs/lgpl-docs" 37 | 38 | [dependencies] 39 | libc = "0.2" 40 | bitflags = "1.0" 41 | once_cell = "1.0" 42 | pango-sys = { git = "https://github.com/gtk-rs/sys" } 43 | glib = { git = "https://github.com/gtk-rs/glib" } 44 | glib-sys = { git = "https://github.com/gtk-rs/sys" } 45 | gobject-sys = { git = "https://github.com/gtk-rs/sys" } 46 | 47 | [dev-dependencies] 48 | gir-format-check = "^0.1" 49 | -------------------------------------------------------------------------------- /Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | girs_dir = "gir-files" 3 | library = "Pango" 4 | version = "1.0" 5 | target_path = "." 6 | work_mode = "normal" 7 | generate_safety_asserts = false 8 | min_cfg_version = "1.36" 9 | single_version_file = true 10 | deprecate_by_min_version = true 11 | 12 | generate = [ 13 | # "Pango.AttrColor", 14 | # "Pango.AttrFloat", 15 | # "Pango.AttrFontDesc", 16 | # "Pango.AttrFontFeatures", 17 | # "Pango.AttrInt", 18 | # "Pango.AttrLanguage", 19 | # "Pango.AttrShape", 20 | # "Pango.AttrSize", 21 | # "Pango.AttrString", 22 | # "Pango.GlyphGeometry", 23 | # "Pango.GlyphInfo", 24 | # "Pango.GlyphVisAttr", 25 | # "Pango.LogAttr", 26 | # "Pango.Map", 27 | # "Pango.MapEntry", 28 | # "Pango.ScriptForLang", 29 | # "Pango.ScriptIter", 30 | "Pango.Alignment", 31 | "Pango.AttrType", 32 | "Pango.BidiType", 33 | "Pango.Color", 34 | "Pango.CoverageLevel", 35 | "Pango.Direction", 36 | "Pango.EllipsizeMode", 37 | "Pango.EngineLang", 38 | "Pango.EngineShape", 39 | "Pango.FontFace", 40 | "Pango.FontFamily", 41 | "Pango.FontMask", 42 | "Pango.FontMetrics", 43 | "Pango.Fontset", 44 | "Pango.FontsetSimple", 45 | "Pango.Glyph", 46 | "Pango.GlyphItem", 47 | "Pango.GlyphItemIter", 48 | "Pango.GlyphString", 49 | "Pango.GlyphUnit", 50 | "Pango.Gravity", 51 | "Pango.GravityHint", 52 | "Pango.Item", 53 | "Pango.LayoutIter", 54 | "Pango.LayoutLine", 55 | "Pango.LayoutRun", 56 | "Pango.Matrix", 57 | "Pango.Overline", 58 | "Pango.Renderer", 59 | "Pango.RenderPart", 60 | "Pango.Script", 61 | "Pango.Stretch", 62 | "Pango.Style", 63 | "Pango.TabAlign", 64 | "Pango.TabArray", 65 | "Pango.Underline", 66 | "Pango.Variant", 67 | "Pango.Weight", 68 | "Pango.WrapMode", 69 | ] 70 | 71 | manual = [ 72 | "GLib.Error", 73 | "Pango.Analysis", 74 | "Pango.AttrClass", 75 | "Pango.Coverage", 76 | "Pango.Language", 77 | "Pango.Rectangle", 78 | ] 79 | 80 | [[object]] 81 | name = "Pango.*" 82 | status = "generate" 83 | [[object.function]] 84 | name = "extents_to_pixels" 85 | [[object.function.parameter]] 86 | pattern = ".+" 87 | const = true 88 | [[object.function]] 89 | name = "get_mirror_char" 90 | #out param 91 | ignore = true 92 | [[object.function]] 93 | name = "log2vis_get_embedding_levels" 94 | #out param 95 | ignore = true 96 | [[object.function]] 97 | pattern = "attr_.+" 98 | #moved to Attribute 99 | ignore = true 100 | [[object.function]] 101 | name = "itemize" 102 | [[object.function.parameter]] 103 | name = "cached_iter" 104 | const = true 105 | [[object.function]] 106 | name = "itemize_with_base_dir" 107 | [[object.function.parameter]] 108 | name = "cached_iter" 109 | const = true 110 | [[object.function]] 111 | name = "reorder_items" 112 | ignore = true 113 | [[object.function]] 114 | name = "shape_full" 115 | # invalid length computation on Stash instead of str 116 | ignore = true 117 | [[object.function]] 118 | name = "shape_with_flags" 119 | # ivanlid length computation on a Option, it should fallback to 0. 120 | ignore = true 121 | 122 | [[object]] 123 | name = "Pango.Attribute" 124 | status = "generate" 125 | [[object.function]] 126 | name = "get_type" 127 | version = "1.44" 128 | 129 | [[object]] 130 | name = "Pango.AttrIterator" 131 | status = "generate" 132 | [[object.function]] 133 | name = "get_font" 134 | ignore = true 135 | [[object.function]] 136 | name = "get_type" 137 | version = "1.44" 138 | 139 | [[object]] 140 | name = "Pango.AttrList" 141 | status = "generate" 142 | [[object.derive]] 143 | name = "Debug" 144 | [[object.function]] 145 | name = "change" 146 | ignore = true 147 | [[object.function]] 148 | name = "insert" 149 | ignore = true 150 | [[object.function]] 151 | name = "insert_before" 152 | ignore = true 153 | [[object.function]] 154 | name = "equal" 155 | ignore = true 156 | 157 | [[object]] 158 | name = "Pango.Context" 159 | status = "generate" 160 | [[object.function]] 161 | name = "get_metrics" 162 | [[object.function.parameter]] 163 | name = "language" 164 | const = true 165 | [[object.function]] 166 | name = "load_fontset" 167 | [[object.function.parameter]] 168 | name = "language" 169 | const = true 170 | [[object.function]] 171 | name = "set_language" 172 | [[object.function.parameter]] 173 | name = "language" 174 | const = true 175 | 176 | [[object]] 177 | name = "Pango.Font" 178 | status = "generate" 179 | [[object.function]] 180 | name = "descriptions_free" 181 | ignore = true 182 | [[object.function]] 183 | name = "get_metrics" 184 | [[object.function.parameter]] 185 | name = "language" 186 | const = true 187 | [[object.function]] 188 | name = "find_shaper" 189 | [[object.function.parameter]] 190 | name = "language" 191 | const = true 192 | [[object.function]] 193 | name = "get_coverage" 194 | [[object.function.parameter]] 195 | name = "language" 196 | const = true 197 | 198 | [[object]] 199 | name = "Pango.FontDescription" 200 | status = "generate" 201 | [[object.function]] 202 | name = "from_string" 203 | [object.function.return] 204 | nullable = false 205 | [[object.function]] 206 | name = "set_family_static" 207 | ignore = true 208 | [[object.function]] 209 | name = "copy_static" 210 | ignore = true 211 | [[object.function]] 212 | name = "merge_static" 213 | ignore = true 214 | 215 | [[object]] 216 | name = "Pango.FontMap" 217 | status = "generate" 218 | [[object.function]] 219 | name = "load_fontset" 220 | [[object.function.parameter]] 221 | name = "language" 222 | const = true 223 | 224 | [[object]] 225 | name = "Pango.Layout" 226 | status = "generate" 227 | [[object.function]] 228 | name = "xy_to_index" 229 | [object.function.return] 230 | nullable = false 231 | [[object.function]] 232 | name = "set_tabs" 233 | [[object.function.parameter]] 234 | name = "tabs" 235 | const = true 236 | 237 | [[object]] 238 | name = "Pango.ShapeFlags" 239 | version = "1.44" 240 | status = "generate" 241 | 242 | [[object]] 243 | name = "Pango.ShowFlags" 244 | version = "1.44" 245 | status = "generate" 246 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2015, The Gtk-rs Project Developers. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GIR = gir/target/bin/gir 2 | GIR_SRC = gir/Cargo.toml gir/Cargo.lock gir/build.rs $(shell find gir/src -name '*.rs') 3 | GIR_FILES = gir-files/Pango-1.0.gir 4 | 5 | # Run `gir` generating the bindings 6 | gir : src/auto/mod.rs 7 | cargo fmt 8 | 9 | doc: $(GIR) $(GIR_FILES) 10 | $(GIR) -m doc -c Gir.toml 11 | 12 | not_bound: $(GIR) $(GIR_FILES) 13 | $(GIR) -m not_bound -c Gir.toml 14 | 15 | regen_check: $(GIR) $(GIR_FILES) 16 | rm src/auto/* 17 | $(GIR) -c Gir.toml 18 | cargo fmt 19 | git diff -R --exit-code 20 | 21 | src/auto/mod.rs : Gir.toml $(GIR) $(GIR_FILES) 22 | $(GIR) -c Gir.toml 23 | 24 | $(GIR) : $(GIR_SRC) 25 | rm -f gir/target/bin/gir 26 | cargo install --path gir --root gir/target 27 | rm -f gir/target/.crates.toml 28 | 29 | $(GIR_SRC) $(GIR_FILES) : 30 | git submodule update --init 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pango [![Build Status](https://travis-ci.org/gtk-rs/pango.png?branch=master)](https://travis-ci.org/gtk-rs/pango) [![Build status](https://ci.appveyor.com/api/projects/status/9nyo0226rxvikdtm?svg=true)](https://ci.appveyor.com/project/GuillaumeGomez/pango) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gtk-rs/gtk) 2 | 3 | Pango bindings for Rust. 4 | 5 | - [Gtk-rs project site](https://gtk-rs.org/) 6 | 7 | - [Online documentation](https://gtk-rs.org/docs-src/) 8 | 9 | - [Readme](https://github.com/gtk-rs/gtk/blob/master/README.md) in our 10 | [main repo](https://github.com/gtk-rs/gtk) 11 | 12 | ## License 13 | 14 | MIT 15 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - RUST: stable 4 | BITS: 32 5 | - RUST: stable 6 | BITS: 64 7 | 8 | install: 9 | - IF "%BITS%" == "32" SET ARCH=i686 10 | - IF "%BITS%" == "64" SET ARCH=x86_64 11 | - curl -sSf -o rustup-init.exe https://win.rustup.rs 12 | - rustup-init.exe --default-host "%ARCH%-pc-windows-gnu" --default-toolchain %RUST% -y 13 | - SET PATH=C:\Users\appveyor\.cargo\bin;C:\msys64\mingw%BITS%\bin;%PATH%;C:\msys64\usr\bin 14 | - rustc -Vv 15 | - cargo -Vv 16 | - pacman --noconfirm -S mingw-w64-%ARCH%-gtk3 17 | 18 | build_script: 19 | - cargo doc --features "dox" 20 | - cargo test 21 | - cargo test --features v1_42 22 | - mkdir .cargo 23 | - echo paths = ["."] > .cargo\config 24 | - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples 25 | - cd _examples 26 | - cargo build 27 | - cargo build --features gtk_3_24 28 | 29 | test: false 30 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | manage_docs(); 3 | } 4 | 5 | #[cfg(all( 6 | any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"), 7 | not(all(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")) 8 | ))] 9 | fn manage_docs() { 10 | extern crate lgpl_docs; 11 | const PATH: &'static str = "src"; 12 | const IGNORES: &'static [&'static str] = &["lib.rs", "prelude.rs"]; 13 | lgpl_docs::purge(PATH, IGNORES); 14 | if cfg!(feature = "embed-lgpl-docs") { 15 | lgpl_docs::embed(lgpl_docs::Library::Pango, PATH, IGNORES); 16 | } 17 | } 18 | 19 | #[cfg(any( 20 | all(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"), 21 | not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")) 22 | ))] 23 | fn manage_docs() {} 24 | -------------------------------------------------------------------------------- /src/analysis.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018, The Gtk-rs Project Developers. 2 | // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // Licensed under the MIT license, see the LICENSE file or 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use EngineLang; 8 | use EngineShape; 9 | use Font; 10 | use Gravity; 11 | use Language; 12 | use Script; 13 | 14 | #[repr(C)] 15 | pub struct Analysis(pango_sys::PangoAnalysis); 16 | 17 | impl Analysis { 18 | pub fn shape_engine(&self) -> EngineShape { 19 | unsafe { from_glib_none(self.0.shape_engine) } 20 | } 21 | 22 | pub fn lang_engine(&self) -> EngineLang { 23 | unsafe { from_glib_none(self.0.lang_engine) } 24 | } 25 | 26 | pub fn font(&self) -> Font { 27 | unsafe { from_glib_none(self.0.font) } 28 | } 29 | 30 | pub fn level(&self) -> u8 { 31 | self.0.level 32 | } 33 | 34 | pub fn gravity(&self) -> Gravity { 35 | from_glib(self.0.gravity as i32) 36 | } 37 | 38 | pub fn flags(&self) -> u8 { 39 | self.0.flags 40 | } 41 | 42 | pub fn script(&self) -> Script { 43 | from_glib(self.0.script as i32) 44 | } 45 | 46 | pub fn language(&self) -> Language { 47 | unsafe { from_glib_none(self.0.language) } 48 | } 49 | 50 | /*pub fn extra_attrs(&self) -> Vec { 51 | unsafe { from_glib_none_num_as_vec(self.0.extra_attrs) } 52 | }*/ 53 | } 54 | 55 | #[doc(hidden)] 56 | impl<'a> ToGlibPtr<'a, *const pango_sys::PangoAnalysis> for Analysis { 57 | type Storage = &'a Self; 58 | 59 | #[inline] 60 | fn to_glib_none(&'a self) -> Stash<'a, *const pango_sys::PangoAnalysis, Self> { 61 | let ptr: *const pango_sys::PangoAnalysis = &self.0; 62 | Stash(ptr, self) 63 | } 64 | } 65 | 66 | #[doc(hidden)] 67 | impl<'a> ToGlibPtrMut<'a, *mut pango_sys::PangoAnalysis> for Analysis { 68 | type Storage = &'a mut Self; 69 | 70 | #[inline] 71 | fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut pango_sys::PangoAnalysis, Self> { 72 | let ptr: *mut pango_sys::PangoAnalysis = &mut self.0; 73 | StashMut(ptr, self) 74 | } 75 | } 76 | 77 | #[doc(hidden)] 78 | impl FromGlibPtrNone<*const pango_sys::PangoAnalysis> for Analysis { 79 | unsafe fn from_glib_none(ptr: *const pango_sys::PangoAnalysis) -> Self { 80 | Analysis(*ptr) 81 | } 82 | } 83 | 84 | #[doc(hidden)] 85 | impl FromGlibPtrNone<*mut pango_sys::PangoAnalysis> for Analysis { 86 | unsafe fn from_glib_none(ptr: *mut pango_sys::PangoAnalysis) -> Self { 87 | Analysis(*ptr) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/attr_class.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Gtk-rs Project Developers. 2 | // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // Licensed under the MIT license, see the LICENSE file or 4 | 5 | use glib::translate::{FromGlibPtrFull, FromGlibPtrNone, Stash, ToGlibPtr}; 6 | use pango_sys; 7 | 8 | #[doc(hidden)] 9 | impl<'a> ToGlibPtr<'a, *mut pango_sys::PangoAttrClass> for &'a AttrClass { 10 | type Storage = &'a AttrClass; 11 | 12 | fn to_glib_none(&self) -> Stash<'a, *mut pango_sys::PangoAttrClass, Self> { 13 | Stash(self.0, *self) 14 | } 15 | } 16 | 17 | #[doc(hidden)] 18 | impl FromGlibPtrNone<*mut pango_sys::PangoAttrClass> for AttrClass { 19 | unsafe fn from_glib_none(ptr: *mut pango_sys::PangoAttrClass) -> Self { 20 | assert!(!ptr.is_null()); 21 | AttrClass(ptr) 22 | } 23 | } 24 | 25 | #[doc(hidden)] 26 | impl FromGlibPtrFull<*mut pango_sys::PangoAttrClass> for AttrClass { 27 | unsafe fn from_glib_full(ptr: *mut pango_sys::PangoAttrClass) -> Self { 28 | assert!(!ptr.is_null()); 29 | AttrClass(ptr) 30 | } 31 | } 32 | 33 | #[doc(hidden)] 34 | impl FromGlibPtrNone<*const pango_sys::PangoAttrClass> for AttrClass { 35 | unsafe fn from_glib_none(ptr: *const pango_sys::PangoAttrClass) -> Self { 36 | assert!(!ptr.is_null()); 37 | AttrClass(ptr as *mut _) 38 | } 39 | } 40 | 41 | #[doc(hidden)] 42 | impl FromGlibPtrFull<*const pango_sys::PangoAttrClass> for AttrClass { 43 | unsafe fn from_glib_full(ptr: *const pango_sys::PangoAttrClass) -> Self { 44 | assert!(!ptr.is_null()); 45 | AttrClass(ptr as *mut _) 46 | } 47 | } 48 | 49 | pub struct AttrClass(*mut pango_sys::PangoAttrClass); 50 | 51 | impl PartialEq for AttrClass { 52 | fn eq(&self, other: &AttrClass) -> bool { 53 | self.0 == other.0 54 | } 55 | } 56 | 57 | impl Eq for AttrClass {} 58 | -------------------------------------------------------------------------------- /src/attr_iterator.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2018, The Gtk-rs Project Developers. 2 | // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // Licensed under the MIT license, see the LICENSE file or 4 | 5 | use glib::translate::*; 6 | use glib_sys; 7 | use pango_sys; 8 | use AttrIterator; 9 | use Attribute; 10 | use FontDescription; 11 | use Language; 12 | 13 | use std::ptr; 14 | 15 | impl AttrIterator { 16 | pub fn get_font( 17 | &mut self, 18 | desc: &mut FontDescription, 19 | language: Option<&Language>, 20 | extra_attrs: &[&Attribute], 21 | ) { 22 | unsafe { 23 | let stash_vec: Vec<_> = extra_attrs.iter().rev().map(|v| v.to_glib_none()).collect(); 24 | let mut list: *mut glib_sys::GSList = ptr::null_mut(); 25 | for stash in &stash_vec { 26 | list = glib_sys::g_slist_prepend(list, Ptr::to(stash.0)); 27 | } 28 | 29 | pango_sys::pango_attr_iterator_get_font( 30 | self.to_glib_none_mut().0, 31 | desc.to_glib_none_mut().0, 32 | &mut language.to_glib_none().0, 33 | &mut list, 34 | ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/attr_list.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Gtk-rs Project Developers. 2 | // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // Licensed under the MIT license, see the LICENSE file or 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use std::mem; 8 | use AttrList; 9 | use Attribute; 10 | 11 | impl AttrList { 12 | pub fn change(&self, attr: Attribute) { 13 | unsafe { 14 | pango_sys::pango_attr_list_change( 15 | self.to_glib_none().0, 16 | attr.to_glib_none().0 as *mut _, 17 | ); 18 | mem::forget(attr); //As attr transferred fully 19 | } 20 | } 21 | 22 | #[cfg(any(feature = "v1_46", feature = "dox"))] 23 | fn equal(&self, other_list: &AttrList) -> bool { 24 | unsafe { 25 | from_glib(pango_sys::pango_attr_list_equal( 26 | self.to_glib_none().0, 27 | other_list.to_glib_none().0, 28 | )) 29 | } 30 | } 31 | 32 | pub fn insert(&self, attr: Attribute) { 33 | unsafe { 34 | pango_sys::pango_attr_list_insert( 35 | self.to_glib_none().0, 36 | attr.to_glib_none().0 as *mut _, 37 | ); 38 | mem::forget(attr); //As attr transferred fully 39 | } 40 | } 41 | 42 | pub fn insert_before(&self, attr: Attribute) { 43 | unsafe { 44 | pango_sys::pango_attr_list_insert_before( 45 | self.to_glib_none().0, 46 | attr.to_glib_none().0 as *mut _, 47 | ); 48 | mem::forget(attr); //As attr transferred fully 49 | } 50 | } 51 | } 52 | 53 | #[cfg(any(feature = "v1_46", feature = "dox"))] 54 | impl PartialEq for AttrList { 55 | #[inline] 56 | fn eq(&self, other: &Self) -> bool { 57 | self.equal(other) 58 | } 59 | } 60 | 61 | #[cfg(any(feature = "v1_46", feature = "dox"))] 62 | impl Eq for AttrList {} 63 | -------------------------------------------------------------------------------- /src/attribute.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2017, The Gtk-rs Project Developers. 2 | // See the COPYRIGHT file at the top-level directory of this distribution. 3 | // Licensed under the MIT license, see the LICENSE file or 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use AttrClass; 8 | use Attribute; 9 | use Gravity; 10 | use GravityHint; 11 | use Stretch; 12 | use Style; 13 | use Underline; 14 | use Variant; 15 | use Weight; 16 | 17 | impl Attribute { 18 | #[cfg(any(feature = "v1_38", feature = "dox"))] 19 | pub fn new_background_alpha(alpha: u16) -> Option { 20 | unsafe { from_glib_full(pango_sys::pango_attr_background_alpha_new(alpha)) } 21 | } 22 | 23 | pub fn new_background(red: u16, green: u16, blue: u16) -> Option { 24 | unsafe { from_glib_full(pango_sys::pango_attr_background_new(red, green, blue)) } 25 | } 26 | 27 | pub fn new_fallback(enable_fallback: bool) -> Option { 28 | unsafe { 29 | from_glib_full(pango_sys::pango_attr_fallback_new( 30 | enable_fallback.to_glib(), 31 | )) 32 | } 33 | } 34 | 35 | pub fn new_family(family: &str) -> Option { 36 | unsafe { from_glib_full(pango_sys::pango_attr_family_new(family.to_glib_none().0)) } 37 | } 38 | 39 | #[cfg(any(feature = "v1_38", feature = "dox"))] 40 | pub fn new_font_features(features: &str) -> Option { 41 | unsafe { 42 | from_glib_full(pango_sys::pango_attr_font_features_new( 43 | features.to_glib_none().0, 44 | )) 45 | } 46 | } 47 | 48 | #[cfg(any(feature = "v1_38", feature = "dox"))] 49 | pub fn new_foreground_alpha(alpha: u16) -> Option { 50 | unsafe { from_glib_full(pango_sys::pango_attr_foreground_alpha_new(alpha)) } 51 | } 52 | 53 | pub fn new_foreground(red: u16, green: u16, blue: u16) -> Option { 54 | unsafe { from_glib_full(pango_sys::pango_attr_foreground_new(red, green, blue)) } 55 | } 56 | 57 | pub fn new_gravity_hint(hint: GravityHint) -> Option { 58 | unsafe { from_glib_full(pango_sys::pango_attr_gravity_hint_new(hint.to_glib())) } 59 | } 60 | 61 | pub fn new_gravity(gravity: Gravity) -> Option { 62 | unsafe { from_glib_full(pango_sys::pango_attr_gravity_new(gravity.to_glib())) } 63 | } 64 | 65 | pub fn new_letter_spacing(letter_spacing: i32) -> Option { 66 | unsafe { from_glib_full(pango_sys::pango_attr_letter_spacing_new(letter_spacing)) } 67 | } 68 | 69 | pub fn new_rise(rise: i32) -> Option { 70 | unsafe { from_glib_full(pango_sys::pango_attr_rise_new(rise)) } 71 | } 72 | 73 | pub fn new_scale(scale_factor: f64) -> Option { 74 | unsafe { from_glib_full(pango_sys::pango_attr_scale_new(scale_factor)) } 75 | } 76 | 77 | pub fn new_size(size: i32) -> Option { 78 | unsafe { from_glib_full(pango_sys::pango_attr_size_new(size)) } 79 | } 80 | 81 | pub fn new_size_absolute(size: i32) -> Option { 82 | unsafe { from_glib_full(pango_sys::pango_attr_size_new_absolute(size)) } 83 | } 84 | 85 | pub fn new_stretch(stretch: Stretch) -> Option { 86 | unsafe { from_glib_full(pango_sys::pango_attr_stretch_new(stretch.to_glib())) } 87 | } 88 | 89 | pub fn new_strikethrough_color(red: u16, green: u16, blue: u16) -> Option { 90 | unsafe { 91 | from_glib_full(pango_sys::pango_attr_strikethrough_color_new( 92 | red, green, blue, 93 | )) 94 | } 95 | } 96 | 97 | pub fn new_strikethrough(strikethrough: bool) -> Option { 98 | unsafe { 99 | from_glib_full(pango_sys::pango_attr_strikethrough_new( 100 | strikethrough.to_glib(), 101 | )) 102 | } 103 | } 104 | 105 | pub fn new_style(style: Style) -> Option { 106 | unsafe { from_glib_full(pango_sys::pango_attr_style_new(style.to_glib())) } 107 | } 108 | 109 | pub fn new_underline_color(red: u16, green: u16, blue: u16) -> Option { 110 | unsafe { from_glib_full(pango_sys::pango_attr_underline_color_new(red, green, blue)) } 111 | } 112 | 113 | pub fn new_underline(underline: Underline) -> Option { 114 | unsafe { from_glib_full(pango_sys::pango_attr_underline_new(underline.to_glib())) } 115 | } 116 | 117 | pub fn new_variant(variant: Variant) -> Option { 118 | unsafe { from_glib_full(pango_sys::pango_attr_variant_new(variant.to_glib())) } 119 | } 120 | 121 | pub fn new_weight(weight: Weight) -> Option { 122 | unsafe { from_glib_full(pango_sys::pango_attr_weight_new(weight.to_glib())) } 123 | } 124 | 125 | pub fn get_attr_class(&self) -> AttrClass { 126 | unsafe { from_glib_full((*self.to_glib_none().0).klass) } 127 | } 128 | 129 | pub fn get_start_index(&self) -> u32 { 130 | unsafe { 131 | let stash = self.to_glib_none(); 132 | (*stash.0).start_index 133 | } 134 | } 135 | 136 | pub fn get_end_index(&self) -> u32 { 137 | unsafe { 138 | let stash = self.to_glib_none(); 139 | (*stash.0).end_index 140 | } 141 | } 142 | 143 | pub fn set_start_index(&mut self, index: u32) { 144 | unsafe { 145 | let stash = self.to_glib_none_mut(); 146 | (*stash.0).start_index = index; 147 | } 148 | } 149 | 150 | pub fn set_end_index(&mut self, index: u32) { 151 | unsafe { 152 | let stash = self.to_glib_none_mut(); 153 | (*stash.0).end_index = index; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/auto/alias.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[allow(unused_imports)] 6 | use auto::*; 7 | 8 | pub type Glyph = u32; 9 | pub type GlyphUnit = i32; 10 | pub type LayoutRun = GlyphItem; 11 | -------------------------------------------------------------------------------- /src/auto/attr_iterator.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use std::mem; 8 | use AttrType; 9 | use Attribute; 10 | 11 | #[cfg(any(feature = "v1_44", feature = "dox"))] 12 | glib_wrapper! { 13 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 14 | pub struct AttrIterator(Boxed); 15 | 16 | match fn { 17 | copy => |ptr| pango_sys::pango_attr_iterator_copy(mut_override(ptr)), 18 | free => |ptr| pango_sys::pango_attr_iterator_destroy(ptr), 19 | get_type => || pango_sys::pango_attr_iterator_get_type(), 20 | } 21 | } 22 | 23 | #[cfg(not(any(feature = "v1_44", feature = "dox")))] 24 | glib_wrapper! { 25 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 26 | pub struct AttrIterator(Boxed); 27 | 28 | match fn { 29 | copy => |ptr| pango_sys::pango_attr_iterator_copy(mut_override(ptr)), 30 | free => |ptr| pango_sys::pango_attr_iterator_destroy(ptr), 31 | } 32 | } 33 | 34 | impl AttrIterator { 35 | pub fn get(&mut self, type_: AttrType) -> Option { 36 | unsafe { 37 | from_glib_none(pango_sys::pango_attr_iterator_get( 38 | self.to_glib_none_mut().0, 39 | type_.to_glib(), 40 | )) 41 | } 42 | } 43 | 44 | pub fn get_attrs(&mut self) -> Vec { 45 | unsafe { 46 | FromGlibPtrContainer::from_glib_full(pango_sys::pango_attr_iterator_get_attrs( 47 | self.to_glib_none_mut().0, 48 | )) 49 | } 50 | } 51 | 52 | pub fn next(&mut self) -> bool { 53 | unsafe { 54 | from_glib(pango_sys::pango_attr_iterator_next( 55 | self.to_glib_none_mut().0, 56 | )) 57 | } 58 | } 59 | 60 | pub fn range(&mut self) -> (i32, i32) { 61 | unsafe { 62 | let mut start = mem::MaybeUninit::uninit(); 63 | let mut end = mem::MaybeUninit::uninit(); 64 | pango_sys::pango_attr_iterator_range( 65 | self.to_glib_none_mut().0, 66 | start.as_mut_ptr(), 67 | end.as_mut_ptr(), 68 | ); 69 | let start = start.assume_init(); 70 | let end = end.assume_init(); 71 | (start, end) 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/auto/attr_list.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use AttrIterator; 8 | use Attribute; 9 | 10 | glib_wrapper! { 11 | #[derive(Debug)] 12 | pub struct AttrList(Shared); 13 | 14 | match fn { 15 | ref => |ptr| pango_sys::pango_attr_list_ref(ptr), 16 | unref => |ptr| pango_sys::pango_attr_list_unref(ptr), 17 | get_type => || pango_sys::pango_attr_list_get_type(), 18 | } 19 | } 20 | 21 | impl AttrList { 22 | pub fn new() -> AttrList { 23 | unsafe { from_glib_full(pango_sys::pango_attr_list_new()) } 24 | } 25 | 26 | pub fn copy(&self) -> Option { 27 | unsafe { from_glib_full(pango_sys::pango_attr_list_copy(self.to_glib_none().0)) } 28 | } 29 | 30 | pub fn filter bool>(&self, func: P) -> Option { 31 | let func_data: P = func; 32 | unsafe extern "C" fn func_func bool>( 33 | attribute: *mut pango_sys::PangoAttribute, 34 | user_data: glib_sys::gpointer, 35 | ) -> glib_sys::gboolean { 36 | let attribute = from_glib_borrow(attribute); 37 | let callback: *mut P = user_data as *const _ as usize as *mut P; 38 | let res = (*callback)(&attribute); 39 | res.to_glib() 40 | } 41 | let func = Some(func_func::

as _); 42 | let super_callback0: &P = &func_data; 43 | unsafe { 44 | from_glib_full(pango_sys::pango_attr_list_filter( 45 | self.to_glib_none().0, 46 | func, 47 | super_callback0 as *const _ as usize as *mut _, 48 | )) 49 | } 50 | } 51 | 52 | #[cfg(any(feature = "v1_44", feature = "dox"))] 53 | pub fn get_attributes(&self) -> Vec { 54 | unsafe { 55 | FromGlibPtrContainer::from_glib_full(pango_sys::pango_attr_list_get_attributes( 56 | self.to_glib_none().0, 57 | )) 58 | } 59 | } 60 | 61 | pub fn get_iterator(&self) -> Option { 62 | unsafe { 63 | from_glib_full(pango_sys::pango_attr_list_get_iterator( 64 | self.to_glib_none().0, 65 | )) 66 | } 67 | } 68 | 69 | pub fn splice(&self, other: &AttrList, pos: i32, len: i32) { 70 | unsafe { 71 | pango_sys::pango_attr_list_splice( 72 | self.to_glib_none().0, 73 | other.to_glib_none().0, 74 | pos, 75 | len, 76 | ); 77 | } 78 | } 79 | 80 | #[cfg(any(feature = "v1_44", feature = "dox"))] 81 | pub fn update(&self, pos: i32, remove: i32, add: i32) { 82 | unsafe { 83 | pango_sys::pango_attr_list_update(self.to_glib_none().0, pos, remove, add); 84 | } 85 | } 86 | } 87 | 88 | impl Default for AttrList { 89 | fn default() -> Self { 90 | Self::new() 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/auto/attribute.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use AttrClass; 8 | 9 | #[cfg(any(feature = "v1_44", feature = "dox"))] 10 | glib_wrapper! { 11 | #[derive(Debug, PartialOrd, Ord, Hash)] 12 | pub struct Attribute(Boxed); 13 | 14 | match fn { 15 | copy => |ptr| pango_sys::pango_attribute_copy(mut_override(ptr)), 16 | free => |ptr| pango_sys::pango_attribute_destroy(ptr), 17 | get_type => || pango_sys::pango_attribute_get_type(), 18 | } 19 | } 20 | 21 | #[cfg(not(any(feature = "v1_44", feature = "dox")))] 22 | glib_wrapper! { 23 | #[derive(Debug, PartialOrd, Ord, Hash)] 24 | pub struct Attribute(Boxed); 25 | 26 | match fn { 27 | copy => |ptr| pango_sys::pango_attribute_copy(mut_override(ptr)), 28 | free => |ptr| pango_sys::pango_attribute_destroy(ptr), 29 | } 30 | } 31 | 32 | impl Attribute { 33 | fn equal(&self, attr2: &Attribute) -> bool { 34 | unsafe { 35 | from_glib(pango_sys::pango_attribute_equal( 36 | self.to_glib_none().0, 37 | attr2.to_glib_none().0, 38 | )) 39 | } 40 | } 41 | 42 | pub fn init(&mut self, klass: &AttrClass) { 43 | unsafe { 44 | pango_sys::pango_attribute_init(self.to_glib_none_mut().0, klass.to_glib_none().0); 45 | } 46 | } 47 | } 48 | 49 | impl PartialEq for Attribute { 50 | #[inline] 51 | fn eq(&self, other: &Self) -> bool { 52 | self.equal(other) 53 | } 54 | } 55 | 56 | impl Eq for Attribute {} 57 | -------------------------------------------------------------------------------- /src/auto/color.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use glib::GString; 7 | use pango_sys; 8 | use std::fmt; 9 | #[cfg(any(feature = "v1_46", feature = "dox"))] 10 | use std::mem; 11 | 12 | glib_wrapper! { 13 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 14 | pub struct Color(Boxed); 15 | 16 | match fn { 17 | copy => |ptr| pango_sys::pango_color_copy(mut_override(ptr)), 18 | free => |ptr| pango_sys::pango_color_free(ptr), 19 | get_type => || pango_sys::pango_color_get_type(), 20 | } 21 | } 22 | 23 | impl Color { 24 | pub fn parse(&mut self, spec: &str) -> bool { 25 | unsafe { 26 | from_glib(pango_sys::pango_color_parse( 27 | self.to_glib_none_mut().0, 28 | spec.to_glib_none().0, 29 | )) 30 | } 31 | } 32 | 33 | #[cfg(any(feature = "v1_46", feature = "dox"))] 34 | pub fn parse_with_alpha(&mut self, spec: &str) -> Option { 35 | unsafe { 36 | let mut alpha = mem::MaybeUninit::uninit(); 37 | let ret = from_glib(pango_sys::pango_color_parse_with_alpha( 38 | self.to_glib_none_mut().0, 39 | alpha.as_mut_ptr(), 40 | spec.to_glib_none().0, 41 | )); 42 | let alpha = alpha.assume_init(); 43 | if ret { 44 | Some(alpha) 45 | } else { 46 | None 47 | } 48 | } 49 | } 50 | 51 | fn to_string(&self) -> GString { 52 | unsafe { from_glib_full(pango_sys::pango_color_to_string(self.to_glib_none().0)) } 53 | } 54 | } 55 | 56 | impl fmt::Display for Color { 57 | #[inline] 58 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 59 | write!(f, "{}", self.to_string()) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/auto/constants.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use pango_sys; 6 | use std::ffi::CStr; 7 | 8 | #[cfg_attr(feature = "v1_38", deprecated)] 9 | pub static ENGINE_TYPE_LANG: once_cell::sync::Lazy<&'static str> = 10 | once_cell::sync::Lazy::new(|| unsafe { 11 | CStr::from_ptr(pango_sys::PANGO_ENGINE_TYPE_LANG) 12 | .to_str() 13 | .unwrap() 14 | }); 15 | #[cfg_attr(feature = "v1_38", deprecated)] 16 | pub static ENGINE_TYPE_SHAPE: once_cell::sync::Lazy<&'static str> = 17 | once_cell::sync::Lazy::new(|| unsafe { 18 | CStr::from_ptr(pango_sys::PANGO_ENGINE_TYPE_SHAPE) 19 | .to_str() 20 | .unwrap() 21 | }); 22 | #[cfg_attr(feature = "v1_38", deprecated)] 23 | pub static RENDER_TYPE_NONE: once_cell::sync::Lazy<&'static str> = 24 | once_cell::sync::Lazy::new(|| unsafe { 25 | CStr::from_ptr(pango_sys::PANGO_RENDER_TYPE_NONE) 26 | .to_str() 27 | .unwrap() 28 | }); 29 | -------------------------------------------------------------------------------- /src/auto/context.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use pango_sys; 8 | use std::fmt; 9 | use std::mem; 10 | use std::ptr; 11 | use Direction; 12 | use Font; 13 | use FontDescription; 14 | use FontFamily; 15 | use FontMap; 16 | use FontMetrics; 17 | use Fontset; 18 | use Gravity; 19 | use GravityHint; 20 | use Language; 21 | use Matrix; 22 | 23 | glib_wrapper! { 24 | pub struct Context(Object); 25 | 26 | match fn { 27 | get_type => || pango_sys::pango_context_get_type(), 28 | } 29 | } 30 | 31 | impl Context { 32 | pub fn new() -> Context { 33 | unsafe { from_glib_full(pango_sys::pango_context_new()) } 34 | } 35 | 36 | pub fn changed(&self) { 37 | unsafe { 38 | pango_sys::pango_context_changed(self.to_glib_none().0); 39 | } 40 | } 41 | 42 | pub fn get_base_dir(&self) -> Direction { 43 | unsafe { from_glib(pango_sys::pango_context_get_base_dir(self.to_glib_none().0)) } 44 | } 45 | 46 | pub fn get_base_gravity(&self) -> Gravity { 47 | unsafe { 48 | from_glib(pango_sys::pango_context_get_base_gravity( 49 | self.to_glib_none().0, 50 | )) 51 | } 52 | } 53 | 54 | pub fn get_font_description(&self) -> Option { 55 | unsafe { 56 | from_glib_none(pango_sys::pango_context_get_font_description( 57 | self.to_glib_none().0, 58 | )) 59 | } 60 | } 61 | 62 | pub fn get_font_map(&self) -> Option { 63 | unsafe { from_glib_none(pango_sys::pango_context_get_font_map(self.to_glib_none().0)) } 64 | } 65 | 66 | pub fn get_gravity(&self) -> Gravity { 67 | unsafe { from_glib(pango_sys::pango_context_get_gravity(self.to_glib_none().0)) } 68 | } 69 | 70 | pub fn get_gravity_hint(&self) -> GravityHint { 71 | unsafe { 72 | from_glib(pango_sys::pango_context_get_gravity_hint( 73 | self.to_glib_none().0, 74 | )) 75 | } 76 | } 77 | 78 | pub fn get_language(&self) -> Option { 79 | unsafe { from_glib_full(pango_sys::pango_context_get_language(self.to_glib_none().0)) } 80 | } 81 | 82 | pub fn get_matrix(&self) -> Option { 83 | unsafe { from_glib_none(pango_sys::pango_context_get_matrix(self.to_glib_none().0)) } 84 | } 85 | 86 | pub fn get_metrics( 87 | &self, 88 | desc: Option<&FontDescription>, 89 | language: Option<&Language>, 90 | ) -> Option { 91 | unsafe { 92 | from_glib_full(pango_sys::pango_context_get_metrics( 93 | self.to_glib_none().0, 94 | desc.to_glib_none().0, 95 | mut_override(language.to_glib_none().0), 96 | )) 97 | } 98 | } 99 | 100 | #[cfg(any(feature = "v1_44", feature = "dox"))] 101 | pub fn get_round_glyph_positions(&self) -> bool { 102 | unsafe { 103 | from_glib(pango_sys::pango_context_get_round_glyph_positions( 104 | self.to_glib_none().0, 105 | )) 106 | } 107 | } 108 | 109 | pub fn get_serial(&self) -> u32 { 110 | unsafe { pango_sys::pango_context_get_serial(self.to_glib_none().0) } 111 | } 112 | 113 | pub fn list_families(&self) -> Vec { 114 | unsafe { 115 | let mut families = ptr::null_mut(); 116 | let mut n_families = mem::MaybeUninit::uninit(); 117 | pango_sys::pango_context_list_families( 118 | self.to_glib_none().0, 119 | &mut families, 120 | n_families.as_mut_ptr(), 121 | ); 122 | FromGlibContainer::from_glib_container_num(families, n_families.assume_init() as usize) 123 | } 124 | } 125 | 126 | pub fn load_font(&self, desc: &FontDescription) -> Option { 127 | unsafe { 128 | from_glib_full(pango_sys::pango_context_load_font( 129 | self.to_glib_none().0, 130 | desc.to_glib_none().0, 131 | )) 132 | } 133 | } 134 | 135 | pub fn load_fontset(&self, desc: &FontDescription, language: &Language) -> Option { 136 | unsafe { 137 | from_glib_full(pango_sys::pango_context_load_fontset( 138 | self.to_glib_none().0, 139 | desc.to_glib_none().0, 140 | mut_override(language.to_glib_none().0), 141 | )) 142 | } 143 | } 144 | 145 | pub fn set_base_dir(&self, direction: Direction) { 146 | unsafe { 147 | pango_sys::pango_context_set_base_dir(self.to_glib_none().0, direction.to_glib()); 148 | } 149 | } 150 | 151 | pub fn set_base_gravity(&self, gravity: Gravity) { 152 | unsafe { 153 | pango_sys::pango_context_set_base_gravity(self.to_glib_none().0, gravity.to_glib()); 154 | } 155 | } 156 | 157 | pub fn set_font_description(&self, desc: &FontDescription) { 158 | unsafe { 159 | pango_sys::pango_context_set_font_description( 160 | self.to_glib_none().0, 161 | desc.to_glib_none().0, 162 | ); 163 | } 164 | } 165 | 166 | pub fn set_font_map>(&self, font_map: &P) { 167 | unsafe { 168 | pango_sys::pango_context_set_font_map( 169 | self.to_glib_none().0, 170 | font_map.as_ref().to_glib_none().0, 171 | ); 172 | } 173 | } 174 | 175 | pub fn set_gravity_hint(&self, hint: GravityHint) { 176 | unsafe { 177 | pango_sys::pango_context_set_gravity_hint(self.to_glib_none().0, hint.to_glib()); 178 | } 179 | } 180 | 181 | pub fn set_language(&self, language: &Language) { 182 | unsafe { 183 | pango_sys::pango_context_set_language( 184 | self.to_glib_none().0, 185 | mut_override(language.to_glib_none().0), 186 | ); 187 | } 188 | } 189 | 190 | pub fn set_matrix(&self, matrix: Option<&Matrix>) { 191 | unsafe { 192 | pango_sys::pango_context_set_matrix(self.to_glib_none().0, matrix.to_glib_none().0); 193 | } 194 | } 195 | 196 | #[cfg(any(feature = "v1_44", feature = "dox"))] 197 | pub fn set_round_glyph_positions(&self, round_positions: bool) { 198 | unsafe { 199 | pango_sys::pango_context_set_round_glyph_positions( 200 | self.to_glib_none().0, 201 | round_positions.to_glib(), 202 | ); 203 | } 204 | } 205 | } 206 | 207 | impl Default for Context { 208 | fn default() -> Self { 209 | Self::new() 210 | } 211 | } 212 | 213 | impl fmt::Display for Context { 214 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 215 | write!(f, "Context") 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /src/auto/engine_lang.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use std::fmt; 8 | 9 | glib_wrapper! { 10 | pub struct EngineLang(Object); 11 | 12 | match fn { 13 | get_type => || pango_sys::pango_engine_lang_get_type(), 14 | } 15 | } 16 | 17 | impl EngineLang {} 18 | 19 | pub const NONE_ENGINE_LANG: Option<&EngineLang> = None; 20 | 21 | impl fmt::Display for EngineLang { 22 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 23 | write!(f, "EngineLang") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/auto/engine_shape.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | use std::fmt; 8 | 9 | glib_wrapper! { 10 | pub struct EngineShape(Object); 11 | 12 | match fn { 13 | get_type => || pango_sys::pango_engine_shape_get_type(), 14 | } 15 | } 16 | 17 | impl EngineShape {} 18 | 19 | pub const NONE_ENGINE_SHAPE: Option<&EngineShape> = None; 20 | 21 | impl fmt::Display for EngineShape { 22 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 23 | write!(f, "EngineShape") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/auto/flags.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use glib::value::FromValue; 7 | use glib::value::FromValueOptional; 8 | use glib::value::SetValue; 9 | use glib::value::Value; 10 | use glib::StaticType; 11 | use glib::Type; 12 | use gobject_sys; 13 | use pango_sys; 14 | 15 | bitflags! { 16 | pub struct FontMask: u32 { 17 | const FAMILY = 1; 18 | const STYLE = 2; 19 | const VARIANT = 4; 20 | const WEIGHT = 8; 21 | const STRETCH = 16; 22 | const SIZE = 32; 23 | const GRAVITY = 64; 24 | const VARIATIONS = 128; 25 | } 26 | } 27 | 28 | #[doc(hidden)] 29 | impl ToGlib for FontMask { 30 | type GlibType = pango_sys::PangoFontMask; 31 | 32 | fn to_glib(&self) -> pango_sys::PangoFontMask { 33 | self.bits() 34 | } 35 | } 36 | 37 | #[doc(hidden)] 38 | impl FromGlib for FontMask { 39 | fn from_glib(value: pango_sys::PangoFontMask) -> FontMask { 40 | FontMask::from_bits_truncate(value) 41 | } 42 | } 43 | 44 | impl StaticType for FontMask { 45 | fn static_type() -> Type { 46 | unsafe { from_glib(pango_sys::pango_font_mask_get_type()) } 47 | } 48 | } 49 | 50 | impl<'a> FromValueOptional<'a> for FontMask { 51 | unsafe fn from_value_optional(value: &Value) -> Option { 52 | Some(FromValue::from_value(value)) 53 | } 54 | } 55 | 56 | impl<'a> FromValue<'a> for FontMask { 57 | unsafe fn from_value(value: &Value) -> Self { 58 | from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) 59 | } 60 | } 61 | 62 | impl SetValue for FontMask { 63 | unsafe fn set_value(value: &mut Value, this: &Self) { 64 | gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) 65 | } 66 | } 67 | 68 | #[cfg(any(feature = "v1_44", feature = "dox"))] 69 | bitflags! { 70 | pub struct ShapeFlags: u32 { 71 | const NONE = 0; 72 | const ROUND_POSITIONS = 1; 73 | } 74 | } 75 | 76 | #[cfg(any(feature = "v1_44", feature = "dox"))] 77 | #[doc(hidden)] 78 | impl ToGlib for ShapeFlags { 79 | type GlibType = pango_sys::PangoShapeFlags; 80 | 81 | fn to_glib(&self) -> pango_sys::PangoShapeFlags { 82 | self.bits() 83 | } 84 | } 85 | 86 | #[cfg(any(feature = "v1_44", feature = "dox"))] 87 | #[doc(hidden)] 88 | impl FromGlib for ShapeFlags { 89 | fn from_glib(value: pango_sys::PangoShapeFlags) -> ShapeFlags { 90 | ShapeFlags::from_bits_truncate(value) 91 | } 92 | } 93 | 94 | #[cfg(any(feature = "v1_44", feature = "dox"))] 95 | impl StaticType for ShapeFlags { 96 | fn static_type() -> Type { 97 | unsafe { from_glib(pango_sys::pango_shape_flags_get_type()) } 98 | } 99 | } 100 | 101 | #[cfg(any(feature = "v1_44", feature = "dox"))] 102 | impl<'a> FromValueOptional<'a> for ShapeFlags { 103 | unsafe fn from_value_optional(value: &Value) -> Option { 104 | Some(FromValue::from_value(value)) 105 | } 106 | } 107 | 108 | #[cfg(any(feature = "v1_44", feature = "dox"))] 109 | impl<'a> FromValue<'a> for ShapeFlags { 110 | unsafe fn from_value(value: &Value) -> Self { 111 | from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) 112 | } 113 | } 114 | 115 | #[cfg(any(feature = "v1_44", feature = "dox"))] 116 | impl SetValue for ShapeFlags { 117 | unsafe fn set_value(value: &mut Value, this: &Self) { 118 | gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) 119 | } 120 | } 121 | 122 | #[cfg(any(feature = "v1_44", feature = "dox"))] 123 | bitflags! { 124 | pub struct ShowFlags: u32 { 125 | const NONE = 0; 126 | const SPACES = 1; 127 | const LINE_BREAKS = 2; 128 | const IGNORABLES = 4; 129 | } 130 | } 131 | 132 | #[cfg(any(feature = "v1_44", feature = "dox"))] 133 | #[doc(hidden)] 134 | impl ToGlib for ShowFlags { 135 | type GlibType = pango_sys::PangoShowFlags; 136 | 137 | fn to_glib(&self) -> pango_sys::PangoShowFlags { 138 | self.bits() 139 | } 140 | } 141 | 142 | #[cfg(any(feature = "v1_44", feature = "dox"))] 143 | #[doc(hidden)] 144 | impl FromGlib for ShowFlags { 145 | fn from_glib(value: pango_sys::PangoShowFlags) -> ShowFlags { 146 | ShowFlags::from_bits_truncate(value) 147 | } 148 | } 149 | 150 | #[cfg(any(feature = "v1_44", feature = "dox"))] 151 | impl StaticType for ShowFlags { 152 | fn static_type() -> Type { 153 | unsafe { from_glib(pango_sys::pango_show_flags_get_type()) } 154 | } 155 | } 156 | 157 | #[cfg(any(feature = "v1_44", feature = "dox"))] 158 | impl<'a> FromValueOptional<'a> for ShowFlags { 159 | unsafe fn from_value_optional(value: &Value) -> Option { 160 | Some(FromValue::from_value(value)) 161 | } 162 | } 163 | 164 | #[cfg(any(feature = "v1_44", feature = "dox"))] 165 | impl<'a> FromValue<'a> for ShowFlags { 166 | unsafe fn from_value(value: &Value) -> Self { 167 | from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) 168 | } 169 | } 170 | 171 | #[cfg(any(feature = "v1_44", feature = "dox"))] 172 | impl SetValue for ShowFlags { 173 | unsafe fn set_value(value: &mut Value, this: &Self) { 174 | gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/auto/font.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use pango_sys; 8 | use std::fmt; 9 | use Coverage; 10 | use EngineShape; 11 | use FontDescription; 12 | #[cfg(any(feature = "v1_46", feature = "dox"))] 13 | use FontFace; 14 | use FontMap; 15 | use FontMetrics; 16 | use Glyph; 17 | use Language; 18 | use Rectangle; 19 | 20 | glib_wrapper! { 21 | pub struct Font(Object); 22 | 23 | match fn { 24 | get_type => || pango_sys::pango_font_get_type(), 25 | } 26 | } 27 | 28 | pub const NONE_FONT: Option<&Font> = None; 29 | 30 | pub trait FontExt: 'static { 31 | fn describe(&self) -> Option; 32 | 33 | fn describe_with_absolute_size(&self) -> Option; 34 | 35 | fn find_shaper(&self, language: &Language, ch: u32) -> Option; 36 | 37 | fn get_coverage(&self, language: &Language) -> Option; 38 | 39 | #[cfg(any(feature = "v1_46", feature = "dox"))] 40 | fn get_face(&self) -> Option; 41 | 42 | //#[cfg(any(feature = "v1_44", feature = "dox"))] 43 | //fn get_features(&self, features: /*Unimplemented*/&mut Fundamental: Pointer, num_features: &mut u32) -> u32; 44 | 45 | fn get_font_map(&self) -> Option; 46 | 47 | fn get_glyph_extents(&self, glyph: Glyph) -> (Rectangle, Rectangle); 48 | 49 | //#[cfg(any(feature = "v1_44", feature = "dox"))] 50 | //fn get_hb_font(&self) -> /*Ignored*/Option; 51 | 52 | fn get_metrics(&self, language: Option<&Language>) -> Option; 53 | 54 | #[cfg(any(feature = "v1_44", feature = "dox"))] 55 | fn has_char(&self, wc: char) -> bool; 56 | } 57 | 58 | impl> FontExt for O { 59 | fn describe(&self) -> Option { 60 | unsafe { 61 | from_glib_full(pango_sys::pango_font_describe( 62 | self.as_ref().to_glib_none().0, 63 | )) 64 | } 65 | } 66 | 67 | fn describe_with_absolute_size(&self) -> Option { 68 | unsafe { 69 | from_glib_full(pango_sys::pango_font_describe_with_absolute_size( 70 | self.as_ref().to_glib_none().0, 71 | )) 72 | } 73 | } 74 | 75 | fn find_shaper(&self, language: &Language, ch: u32) -> Option { 76 | unsafe { 77 | from_glib_none(pango_sys::pango_font_find_shaper( 78 | self.as_ref().to_glib_none().0, 79 | mut_override(language.to_glib_none().0), 80 | ch, 81 | )) 82 | } 83 | } 84 | 85 | fn get_coverage(&self, language: &Language) -> Option { 86 | unsafe { 87 | from_glib_full(pango_sys::pango_font_get_coverage( 88 | self.as_ref().to_glib_none().0, 89 | mut_override(language.to_glib_none().0), 90 | )) 91 | } 92 | } 93 | 94 | #[cfg(any(feature = "v1_46", feature = "dox"))] 95 | fn get_face(&self) -> Option { 96 | unsafe { 97 | from_glib_none(pango_sys::pango_font_get_face( 98 | self.as_ref().to_glib_none().0, 99 | )) 100 | } 101 | } 102 | 103 | //#[cfg(any(feature = "v1_44", feature = "dox"))] 104 | //fn get_features(&self, features: /*Unimplemented*/&mut Fundamental: Pointer, num_features: &mut u32) -> u32 { 105 | // unsafe { TODO: call pango_sys:pango_font_get_features() } 106 | //} 107 | 108 | fn get_font_map(&self) -> Option { 109 | unsafe { 110 | from_glib_none(pango_sys::pango_font_get_font_map( 111 | self.as_ref().to_glib_none().0, 112 | )) 113 | } 114 | } 115 | 116 | fn get_glyph_extents(&self, glyph: Glyph) -> (Rectangle, Rectangle) { 117 | unsafe { 118 | let mut ink_rect = Rectangle::uninitialized(); 119 | let mut logical_rect = Rectangle::uninitialized(); 120 | pango_sys::pango_font_get_glyph_extents( 121 | self.as_ref().to_glib_none().0, 122 | glyph, 123 | ink_rect.to_glib_none_mut().0, 124 | logical_rect.to_glib_none_mut().0, 125 | ); 126 | (ink_rect, logical_rect) 127 | } 128 | } 129 | 130 | //#[cfg(any(feature = "v1_44", feature = "dox"))] 131 | //fn get_hb_font(&self) -> /*Ignored*/Option { 132 | // unsafe { TODO: call pango_sys:pango_font_get_hb_font() } 133 | //} 134 | 135 | fn get_metrics(&self, language: Option<&Language>) -> Option { 136 | unsafe { 137 | from_glib_full(pango_sys::pango_font_get_metrics( 138 | self.as_ref().to_glib_none().0, 139 | mut_override(language.to_glib_none().0), 140 | )) 141 | } 142 | } 143 | 144 | #[cfg(any(feature = "v1_44", feature = "dox"))] 145 | fn has_char(&self, wc: char) -> bool { 146 | unsafe { 147 | from_glib(pango_sys::pango_font_has_char( 148 | self.as_ref().to_glib_none().0, 149 | wc.to_glib(), 150 | )) 151 | } 152 | } 153 | } 154 | 155 | impl fmt::Display for Font { 156 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 157 | write!(f, "Font") 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/auto/font_description.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use glib::GString; 7 | use pango_sys; 8 | use std::fmt; 9 | use std::hash; 10 | use FontMask; 11 | use Gravity; 12 | use Stretch; 13 | use Style; 14 | use Variant; 15 | use Weight; 16 | 17 | glib_wrapper! { 18 | #[derive(Debug, PartialOrd, Ord)] 19 | pub struct FontDescription(Boxed); 20 | 21 | match fn { 22 | copy => |ptr| pango_sys::pango_font_description_copy(mut_override(ptr)), 23 | free => |ptr| pango_sys::pango_font_description_free(ptr), 24 | get_type => || pango_sys::pango_font_description_get_type(), 25 | } 26 | } 27 | 28 | impl FontDescription { 29 | pub fn new() -> FontDescription { 30 | unsafe { from_glib_full(pango_sys::pango_font_description_new()) } 31 | } 32 | 33 | pub fn better_match( 34 | &self, 35 | old_match: Option<&FontDescription>, 36 | new_match: &FontDescription, 37 | ) -> bool { 38 | unsafe { 39 | from_glib(pango_sys::pango_font_description_better_match( 40 | self.to_glib_none().0, 41 | old_match.to_glib_none().0, 42 | new_match.to_glib_none().0, 43 | )) 44 | } 45 | } 46 | 47 | fn equal(&self, desc2: &FontDescription) -> bool { 48 | unsafe { 49 | from_glib(pango_sys::pango_font_description_equal( 50 | self.to_glib_none().0, 51 | desc2.to_glib_none().0, 52 | )) 53 | } 54 | } 55 | 56 | pub fn get_family(&self) -> Option { 57 | unsafe { 58 | from_glib_none(pango_sys::pango_font_description_get_family( 59 | self.to_glib_none().0, 60 | )) 61 | } 62 | } 63 | 64 | pub fn get_gravity(&self) -> Gravity { 65 | unsafe { 66 | from_glib(pango_sys::pango_font_description_get_gravity( 67 | self.to_glib_none().0, 68 | )) 69 | } 70 | } 71 | 72 | pub fn get_set_fields(&self) -> FontMask { 73 | unsafe { 74 | from_glib(pango_sys::pango_font_description_get_set_fields( 75 | self.to_glib_none().0, 76 | )) 77 | } 78 | } 79 | 80 | pub fn get_size(&self) -> i32 { 81 | unsafe { pango_sys::pango_font_description_get_size(self.to_glib_none().0) } 82 | } 83 | 84 | pub fn get_size_is_absolute(&self) -> bool { 85 | unsafe { 86 | from_glib(pango_sys::pango_font_description_get_size_is_absolute( 87 | self.to_glib_none().0, 88 | )) 89 | } 90 | } 91 | 92 | pub fn get_stretch(&self) -> Stretch { 93 | unsafe { 94 | from_glib(pango_sys::pango_font_description_get_stretch( 95 | self.to_glib_none().0, 96 | )) 97 | } 98 | } 99 | 100 | pub fn get_style(&self) -> Style { 101 | unsafe { 102 | from_glib(pango_sys::pango_font_description_get_style( 103 | self.to_glib_none().0, 104 | )) 105 | } 106 | } 107 | 108 | pub fn get_variant(&self) -> Variant { 109 | unsafe { 110 | from_glib(pango_sys::pango_font_description_get_variant( 111 | self.to_glib_none().0, 112 | )) 113 | } 114 | } 115 | 116 | #[cfg(any(feature = "v1_42", feature = "dox"))] 117 | pub fn get_variations(&self) -> Option { 118 | unsafe { 119 | from_glib_none(pango_sys::pango_font_description_get_variations( 120 | self.to_glib_none().0, 121 | )) 122 | } 123 | } 124 | 125 | pub fn get_weight(&self) -> Weight { 126 | unsafe { 127 | from_glib(pango_sys::pango_font_description_get_weight( 128 | self.to_glib_none().0, 129 | )) 130 | } 131 | } 132 | 133 | fn hash(&self) -> u32 { 134 | unsafe { pango_sys::pango_font_description_hash(self.to_glib_none().0) } 135 | } 136 | 137 | pub fn merge(&mut self, desc_to_merge: Option<&FontDescription>, replace_existing: bool) { 138 | unsafe { 139 | pango_sys::pango_font_description_merge( 140 | self.to_glib_none_mut().0, 141 | desc_to_merge.to_glib_none().0, 142 | replace_existing.to_glib(), 143 | ); 144 | } 145 | } 146 | 147 | pub fn set_absolute_size(&mut self, size: f64) { 148 | unsafe { 149 | pango_sys::pango_font_description_set_absolute_size(self.to_glib_none_mut().0, size); 150 | } 151 | } 152 | 153 | pub fn set_family(&mut self, family: &str) { 154 | unsafe { 155 | pango_sys::pango_font_description_set_family( 156 | self.to_glib_none_mut().0, 157 | family.to_glib_none().0, 158 | ); 159 | } 160 | } 161 | 162 | pub fn set_gravity(&mut self, gravity: Gravity) { 163 | unsafe { 164 | pango_sys::pango_font_description_set_gravity( 165 | self.to_glib_none_mut().0, 166 | gravity.to_glib(), 167 | ); 168 | } 169 | } 170 | 171 | pub fn set_size(&mut self, size: i32) { 172 | unsafe { 173 | pango_sys::pango_font_description_set_size(self.to_glib_none_mut().0, size); 174 | } 175 | } 176 | 177 | pub fn set_stretch(&mut self, stretch: Stretch) { 178 | unsafe { 179 | pango_sys::pango_font_description_set_stretch( 180 | self.to_glib_none_mut().0, 181 | stretch.to_glib(), 182 | ); 183 | } 184 | } 185 | 186 | pub fn set_style(&mut self, style: Style) { 187 | unsafe { 188 | pango_sys::pango_font_description_set_style(self.to_glib_none_mut().0, style.to_glib()); 189 | } 190 | } 191 | 192 | pub fn set_variant(&mut self, variant: Variant) { 193 | unsafe { 194 | pango_sys::pango_font_description_set_variant( 195 | self.to_glib_none_mut().0, 196 | variant.to_glib(), 197 | ); 198 | } 199 | } 200 | 201 | #[cfg(any(feature = "v1_42", feature = "dox"))] 202 | pub fn set_variations(&mut self, variations: &str) { 203 | unsafe { 204 | pango_sys::pango_font_description_set_variations( 205 | self.to_glib_none_mut().0, 206 | variations.to_glib_none().0, 207 | ); 208 | } 209 | } 210 | 211 | #[cfg(any(feature = "v1_42", feature = "dox"))] 212 | pub fn set_variations_static(&mut self, variations: &str) { 213 | unsafe { 214 | pango_sys::pango_font_description_set_variations_static( 215 | self.to_glib_none_mut().0, 216 | variations.to_glib_none().0, 217 | ); 218 | } 219 | } 220 | 221 | pub fn set_weight(&mut self, weight: Weight) { 222 | unsafe { 223 | pango_sys::pango_font_description_set_weight( 224 | self.to_glib_none_mut().0, 225 | weight.to_glib(), 226 | ); 227 | } 228 | } 229 | 230 | pub fn to_filename(&self) -> Option { 231 | unsafe { 232 | from_glib_full(pango_sys::pango_font_description_to_filename( 233 | self.to_glib_none().0, 234 | )) 235 | } 236 | } 237 | 238 | fn to_string(&self) -> GString { 239 | unsafe { 240 | from_glib_full(pango_sys::pango_font_description_to_string( 241 | self.to_glib_none().0, 242 | )) 243 | } 244 | } 245 | 246 | pub fn unset_fields(&mut self, to_unset: FontMask) { 247 | unsafe { 248 | pango_sys::pango_font_description_unset_fields( 249 | self.to_glib_none_mut().0, 250 | to_unset.to_glib(), 251 | ); 252 | } 253 | } 254 | 255 | pub fn from_string(str: &str) -> FontDescription { 256 | unsafe { 257 | from_glib_full(pango_sys::pango_font_description_from_string( 258 | str.to_glib_none().0, 259 | )) 260 | } 261 | } 262 | } 263 | 264 | impl Default for FontDescription { 265 | fn default() -> Self { 266 | Self::new() 267 | } 268 | } 269 | 270 | impl PartialEq for FontDescription { 271 | #[inline] 272 | fn eq(&self, other: &Self) -> bool { 273 | self.equal(other) 274 | } 275 | } 276 | 277 | impl Eq for FontDescription {} 278 | 279 | impl fmt::Display for FontDescription { 280 | #[inline] 281 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 282 | write!(f, "{}", self.to_string()) 283 | } 284 | } 285 | 286 | impl hash::Hash for FontDescription { 287 | #[inline] 288 | fn hash(&self, state: &mut H) 289 | where 290 | H: hash::Hasher, 291 | { 292 | hash::Hash::hash(&self.hash(), state) 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /src/auto/font_face.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use glib::GString; 8 | use pango_sys; 9 | use std::fmt; 10 | use std::mem; 11 | use std::ptr; 12 | use FontDescription; 13 | #[cfg(any(feature = "v1_46", feature = "dox"))] 14 | use FontFamily; 15 | 16 | glib_wrapper! { 17 | pub struct FontFace(Object); 18 | 19 | match fn { 20 | get_type => || pango_sys::pango_font_face_get_type(), 21 | } 22 | } 23 | 24 | pub const NONE_FONT_FACE: Option<&FontFace> = None; 25 | 26 | pub trait FontFaceExt: 'static { 27 | fn describe(&self) -> Option; 28 | 29 | fn get_face_name(&self) -> Option; 30 | 31 | #[cfg(any(feature = "v1_46", feature = "dox"))] 32 | fn get_family(&self) -> Option; 33 | 34 | fn is_synthesized(&self) -> bool; 35 | 36 | fn list_sizes(&self) -> Vec; 37 | } 38 | 39 | impl> FontFaceExt for O { 40 | fn describe(&self) -> Option { 41 | unsafe { 42 | from_glib_full(pango_sys::pango_font_face_describe( 43 | self.as_ref().to_glib_none().0, 44 | )) 45 | } 46 | } 47 | 48 | fn get_face_name(&self) -> Option { 49 | unsafe { 50 | from_glib_none(pango_sys::pango_font_face_get_face_name( 51 | self.as_ref().to_glib_none().0, 52 | )) 53 | } 54 | } 55 | 56 | #[cfg(any(feature = "v1_46", feature = "dox"))] 57 | fn get_family(&self) -> Option { 58 | unsafe { 59 | from_glib_none(pango_sys::pango_font_face_get_family( 60 | self.as_ref().to_glib_none().0, 61 | )) 62 | } 63 | } 64 | 65 | fn is_synthesized(&self) -> bool { 66 | unsafe { 67 | from_glib(pango_sys::pango_font_face_is_synthesized( 68 | self.as_ref().to_glib_none().0, 69 | )) 70 | } 71 | } 72 | 73 | fn list_sizes(&self) -> Vec { 74 | unsafe { 75 | let mut sizes = ptr::null_mut(); 76 | let mut n_sizes = mem::MaybeUninit::uninit(); 77 | pango_sys::pango_font_face_list_sizes( 78 | self.as_ref().to_glib_none().0, 79 | &mut sizes, 80 | n_sizes.as_mut_ptr(), 81 | ); 82 | FromGlibContainer::from_glib_full_num(sizes, n_sizes.assume_init() as usize) 83 | } 84 | } 85 | } 86 | 87 | impl fmt::Display for FontFace { 88 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 89 | write!(f, "FontFace") 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/auto/font_family.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use glib::GString; 8 | use pango_sys; 9 | use std::fmt; 10 | use std::mem; 11 | use std::ptr; 12 | use FontFace; 13 | 14 | glib_wrapper! { 15 | pub struct FontFamily(Object); 16 | 17 | match fn { 18 | get_type => || pango_sys::pango_font_family_get_type(), 19 | } 20 | } 21 | 22 | pub const NONE_FONT_FAMILY: Option<&FontFamily> = None; 23 | 24 | pub trait FontFamilyExt: 'static { 25 | #[cfg(any(feature = "v1_46", feature = "dox"))] 26 | fn get_face(&self, name: Option<&str>) -> Option; 27 | 28 | fn get_name(&self) -> Option; 29 | 30 | fn is_monospace(&self) -> bool; 31 | 32 | #[cfg(any(feature = "v1_44", feature = "dox"))] 33 | fn is_variable(&self) -> bool; 34 | 35 | fn list_faces(&self) -> Vec; 36 | } 37 | 38 | impl> FontFamilyExt for O { 39 | #[cfg(any(feature = "v1_46", feature = "dox"))] 40 | fn get_face(&self, name: Option<&str>) -> Option { 41 | unsafe { 42 | from_glib_none(pango_sys::pango_font_family_get_face( 43 | self.as_ref().to_glib_none().0, 44 | name.to_glib_none().0, 45 | )) 46 | } 47 | } 48 | 49 | fn get_name(&self) -> Option { 50 | unsafe { 51 | from_glib_none(pango_sys::pango_font_family_get_name( 52 | self.as_ref().to_glib_none().0, 53 | )) 54 | } 55 | } 56 | 57 | fn is_monospace(&self) -> bool { 58 | unsafe { 59 | from_glib(pango_sys::pango_font_family_is_monospace( 60 | self.as_ref().to_glib_none().0, 61 | )) 62 | } 63 | } 64 | 65 | #[cfg(any(feature = "v1_44", feature = "dox"))] 66 | fn is_variable(&self) -> bool { 67 | unsafe { 68 | from_glib(pango_sys::pango_font_family_is_variable( 69 | self.as_ref().to_glib_none().0, 70 | )) 71 | } 72 | } 73 | 74 | fn list_faces(&self) -> Vec { 75 | unsafe { 76 | let mut faces = ptr::null_mut(); 77 | let mut n_faces = mem::MaybeUninit::uninit(); 78 | pango_sys::pango_font_family_list_faces( 79 | self.as_ref().to_glib_none().0, 80 | &mut faces, 81 | n_faces.as_mut_ptr(), 82 | ); 83 | FromGlibContainer::from_glib_container_num(faces, n_faces.assume_init() as usize) 84 | } 85 | } 86 | } 87 | 88 | impl fmt::Display for FontFamily { 89 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 90 | write!(f, "FontFamily") 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/auto/font_map.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use pango_sys; 8 | use std::fmt; 9 | use std::mem; 10 | use std::ptr; 11 | use Context; 12 | use Font; 13 | use FontDescription; 14 | use FontFamily; 15 | use Fontset; 16 | use Language; 17 | 18 | glib_wrapper! { 19 | pub struct FontMap(Object); 20 | 21 | match fn { 22 | get_type => || pango_sys::pango_font_map_get_type(), 23 | } 24 | } 25 | 26 | pub const NONE_FONT_MAP: Option<&FontMap> = None; 27 | 28 | pub trait FontMapExt: 'static { 29 | fn changed(&self); 30 | 31 | fn create_context(&self) -> Option; 32 | 33 | #[cfg(any(feature = "v1_46", feature = "dox"))] 34 | fn get_family(&self, name: &str) -> Option; 35 | 36 | fn get_serial(&self) -> u32; 37 | 38 | fn list_families(&self) -> Vec; 39 | 40 | fn load_font(&self, context: &Context, desc: &FontDescription) -> Option; 41 | 42 | fn load_fontset( 43 | &self, 44 | context: &Context, 45 | desc: &FontDescription, 46 | language: &Language, 47 | ) -> Option; 48 | } 49 | 50 | impl> FontMapExt for O { 51 | fn changed(&self) { 52 | unsafe { 53 | pango_sys::pango_font_map_changed(self.as_ref().to_glib_none().0); 54 | } 55 | } 56 | 57 | fn create_context(&self) -> Option { 58 | unsafe { 59 | from_glib_full(pango_sys::pango_font_map_create_context( 60 | self.as_ref().to_glib_none().0, 61 | )) 62 | } 63 | } 64 | 65 | #[cfg(any(feature = "v1_46", feature = "dox"))] 66 | fn get_family(&self, name: &str) -> Option { 67 | unsafe { 68 | from_glib_none(pango_sys::pango_font_map_get_family( 69 | self.as_ref().to_glib_none().0, 70 | name.to_glib_none().0, 71 | )) 72 | } 73 | } 74 | 75 | fn get_serial(&self) -> u32 { 76 | unsafe { pango_sys::pango_font_map_get_serial(self.as_ref().to_glib_none().0) } 77 | } 78 | 79 | fn list_families(&self) -> Vec { 80 | unsafe { 81 | let mut families = ptr::null_mut(); 82 | let mut n_families = mem::MaybeUninit::uninit(); 83 | pango_sys::pango_font_map_list_families( 84 | self.as_ref().to_glib_none().0, 85 | &mut families, 86 | n_families.as_mut_ptr(), 87 | ); 88 | FromGlibContainer::from_glib_container_num(families, n_families.assume_init() as usize) 89 | } 90 | } 91 | 92 | fn load_font(&self, context: &Context, desc: &FontDescription) -> Option { 93 | unsafe { 94 | from_glib_full(pango_sys::pango_font_map_load_font( 95 | self.as_ref().to_glib_none().0, 96 | context.to_glib_none().0, 97 | desc.to_glib_none().0, 98 | )) 99 | } 100 | } 101 | 102 | fn load_fontset( 103 | &self, 104 | context: &Context, 105 | desc: &FontDescription, 106 | language: &Language, 107 | ) -> Option { 108 | unsafe { 109 | from_glib_full(pango_sys::pango_font_map_load_fontset( 110 | self.as_ref().to_glib_none().0, 111 | context.to_glib_none().0, 112 | desc.to_glib_none().0, 113 | mut_override(language.to_glib_none().0), 114 | )) 115 | } 116 | } 117 | } 118 | 119 | impl fmt::Display for FontMap { 120 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 121 | write!(f, "FontMap") 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/auto/font_metrics.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::translate::*; 6 | use pango_sys; 7 | 8 | glib_wrapper! { 9 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 10 | pub struct FontMetrics(Shared); 11 | 12 | match fn { 13 | ref => |ptr| pango_sys::pango_font_metrics_ref(ptr), 14 | unref => |ptr| pango_sys::pango_font_metrics_unref(ptr), 15 | get_type => || pango_sys::pango_font_metrics_get_type(), 16 | } 17 | } 18 | 19 | impl FontMetrics { 20 | pub fn get_approximate_char_width(&self) -> i32 { 21 | unsafe { pango_sys::pango_font_metrics_get_approximate_char_width(self.to_glib_none().0) } 22 | } 23 | 24 | pub fn get_approximate_digit_width(&self) -> i32 { 25 | unsafe { pango_sys::pango_font_metrics_get_approximate_digit_width(self.to_glib_none().0) } 26 | } 27 | 28 | pub fn get_ascent(&self) -> i32 { 29 | unsafe { pango_sys::pango_font_metrics_get_ascent(self.to_glib_none().0) } 30 | } 31 | 32 | pub fn get_descent(&self) -> i32 { 33 | unsafe { pango_sys::pango_font_metrics_get_descent(self.to_glib_none().0) } 34 | } 35 | 36 | #[cfg(any(feature = "v1_44", feature = "dox"))] 37 | pub fn get_height(&self) -> i32 { 38 | unsafe { pango_sys::pango_font_metrics_get_height(self.to_glib_none().0) } 39 | } 40 | 41 | pub fn get_strikethrough_position(&self) -> i32 { 42 | unsafe { pango_sys::pango_font_metrics_get_strikethrough_position(self.to_glib_none().0) } 43 | } 44 | 45 | pub fn get_strikethrough_thickness(&self) -> i32 { 46 | unsafe { pango_sys::pango_font_metrics_get_strikethrough_thickness(self.to_glib_none().0) } 47 | } 48 | 49 | pub fn get_underline_position(&self) -> i32 { 50 | unsafe { pango_sys::pango_font_metrics_get_underline_position(self.to_glib_none().0) } 51 | } 52 | 53 | pub fn get_underline_thickness(&self) -> i32 { 54 | unsafe { pango_sys::pango_font_metrics_get_underline_thickness(self.to_glib_none().0) } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/auto/fontset.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use pango_sys; 8 | use std::fmt; 9 | use Font; 10 | use FontMetrics; 11 | 12 | glib_wrapper! { 13 | pub struct Fontset(Object); 14 | 15 | match fn { 16 | get_type => || pango_sys::pango_fontset_get_type(), 17 | } 18 | } 19 | 20 | pub const NONE_FONTSET: Option<&Fontset> = None; 21 | 22 | pub trait FontsetExt: 'static { 23 | fn foreach bool>(&self, func: P); 24 | 25 | fn get_font(&self, wc: u32) -> Option; 26 | 27 | fn get_metrics(&self) -> Option; 28 | } 29 | 30 | impl> FontsetExt for O { 31 | fn foreach bool>(&self, func: P) { 32 | let func_data: P = func; 33 | unsafe extern "C" fn func_func bool>( 34 | fontset: *mut pango_sys::PangoFontset, 35 | font: *mut pango_sys::PangoFont, 36 | user_data: glib_sys::gpointer, 37 | ) -> glib_sys::gboolean { 38 | let fontset = from_glib_borrow(fontset); 39 | let font = from_glib_borrow(font); 40 | let callback: *mut P = user_data as *const _ as usize as *mut P; 41 | let res = (*callback)(&fontset, &font); 42 | res.to_glib() 43 | } 44 | let func = Some(func_func::

as _); 45 | let super_callback0: &P = &func_data; 46 | unsafe { 47 | pango_sys::pango_fontset_foreach( 48 | self.as_ref().to_glib_none().0, 49 | func, 50 | super_callback0 as *const _ as usize as *mut _, 51 | ); 52 | } 53 | } 54 | 55 | fn get_font(&self, wc: u32) -> Option { 56 | unsafe { 57 | from_glib_full(pango_sys::pango_fontset_get_font( 58 | self.as_ref().to_glib_none().0, 59 | wc, 60 | )) 61 | } 62 | } 63 | 64 | fn get_metrics(&self) -> Option { 65 | unsafe { 66 | from_glib_full(pango_sys::pango_fontset_get_metrics( 67 | self.as_ref().to_glib_none().0, 68 | )) 69 | } 70 | } 71 | } 72 | 73 | impl fmt::Display for Fontset { 74 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 75 | write!(f, "Fontset") 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/auto/fontset_simple.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib::object::IsA; 6 | use glib::translate::*; 7 | use pango_sys; 8 | use std::fmt; 9 | use Font; 10 | use Fontset; 11 | use Language; 12 | 13 | glib_wrapper! { 14 | pub struct FontsetSimple(Object) @extends Fontset; 15 | 16 | match fn { 17 | get_type => || pango_sys::pango_fontset_simple_get_type(), 18 | } 19 | } 20 | 21 | impl FontsetSimple { 22 | pub fn new(language: &mut Language) -> FontsetSimple { 23 | unsafe { 24 | from_glib_full(pango_sys::pango_fontset_simple_new( 25 | language.to_glib_none_mut().0, 26 | )) 27 | } 28 | } 29 | 30 | pub fn append>(&self, font: &P) { 31 | unsafe { 32 | pango_sys::pango_fontset_simple_append( 33 | self.to_glib_none().0, 34 | font.as_ref().to_glib_none().0, 35 | ); 36 | } 37 | } 38 | 39 | pub fn size(&self) -> i32 { 40 | unsafe { pango_sys::pango_fontset_simple_size(self.to_glib_none().0) } 41 | } 42 | } 43 | 44 | impl fmt::Display for FontsetSimple { 45 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 46 | write!(f, "FontsetSimple") 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/auto/functions.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use glib; 6 | use glib::translate::*; 7 | use glib::GString; 8 | use pango_sys; 9 | use std::mem; 10 | use std::ptr; 11 | use Analysis; 12 | use AttrIterator; 13 | use AttrList; 14 | use Context; 15 | use Direction; 16 | use GlyphString; 17 | use Item; 18 | use Rectangle; 19 | use Stretch; 20 | use Style; 21 | use Variant; 22 | use Weight; 23 | 24 | //#[cfg_attr(feature = "v1_44", deprecated)] 25 | //pub fn break_(text: &str, analysis: &mut Analysis, attrs: /*Ignored*/&[&LogAttr]) { 26 | // unsafe { TODO: call pango_sys:pango_break() } 27 | //} 28 | 29 | //pub fn default_break(text: &str, analysis: Option<&mut Analysis>, attrs: /*Ignored*/&mut LogAttr, attrs_len: i32) { 30 | // unsafe { TODO: call pango_sys:pango_default_break() } 31 | //} 32 | 33 | pub fn extents_to_pixels(inclusive: Option<&Rectangle>, nearest: Option<&Rectangle>) { 34 | unsafe { 35 | pango_sys::pango_extents_to_pixels( 36 | mut_override(inclusive.to_glib_none().0), 37 | mut_override(nearest.to_glib_none().0), 38 | ); 39 | } 40 | } 41 | 42 | pub fn find_base_dir(text: &str) -> Direction { 43 | let length = text.len() as i32; 44 | unsafe { 45 | from_glib(pango_sys::pango_find_base_dir( 46 | text.to_glib_none().0, 47 | length, 48 | )) 49 | } 50 | } 51 | 52 | //#[cfg_attr(feature = "v1_38", deprecated)] 53 | //pub fn find_map(language: &mut Language, engine_type_id: u32, render_type_id: u32) -> /*Ignored*/Option { 54 | // unsafe { TODO: call pango_sys:pango_find_map() } 55 | //} 56 | 57 | pub fn find_paragraph_boundary(text: &str) -> (i32, i32) { 58 | let length = text.len() as i32; 59 | unsafe { 60 | let mut paragraph_delimiter_index = mem::MaybeUninit::uninit(); 61 | let mut next_paragraph_start = mem::MaybeUninit::uninit(); 62 | pango_sys::pango_find_paragraph_boundary( 63 | text.to_glib_none().0, 64 | length, 65 | paragraph_delimiter_index.as_mut_ptr(), 66 | next_paragraph_start.as_mut_ptr(), 67 | ); 68 | let paragraph_delimiter_index = paragraph_delimiter_index.assume_init(); 69 | let next_paragraph_start = next_paragraph_start.assume_init(); 70 | (paragraph_delimiter_index, next_paragraph_start) 71 | } 72 | } 73 | 74 | //pub fn get_log_attrs(text: &str, level: i32, language: &mut Language, log_attrs: /*Ignored*/&[&LogAttr]) { 75 | // unsafe { TODO: call pango_sys:pango_get_log_attrs() } 76 | //} 77 | 78 | pub fn is_zero_width(ch: char) -> bool { 79 | unsafe { from_glib(pango_sys::pango_is_zero_width(ch.to_glib())) } 80 | } 81 | 82 | pub fn itemize( 83 | context: &Context, 84 | text: &str, 85 | start_index: i32, 86 | length: i32, 87 | attrs: &AttrList, 88 | cached_iter: Option<&AttrIterator>, 89 | ) -> Vec { 90 | unsafe { 91 | FromGlibPtrContainer::from_glib_full(pango_sys::pango_itemize( 92 | context.to_glib_none().0, 93 | text.to_glib_none().0, 94 | start_index, 95 | length, 96 | attrs.to_glib_none().0, 97 | mut_override(cached_iter.to_glib_none().0), 98 | )) 99 | } 100 | } 101 | 102 | pub fn itemize_with_base_dir( 103 | context: &Context, 104 | base_dir: Direction, 105 | text: &str, 106 | start_index: i32, 107 | length: i32, 108 | attrs: &AttrList, 109 | cached_iter: Option<&AttrIterator>, 110 | ) -> Vec { 111 | unsafe { 112 | FromGlibPtrContainer::from_glib_full(pango_sys::pango_itemize_with_base_dir( 113 | context.to_glib_none().0, 114 | base_dir.to_glib(), 115 | text.to_glib_none().0, 116 | start_index, 117 | length, 118 | attrs.to_glib_none().0, 119 | mut_override(cached_iter.to_glib_none().0), 120 | )) 121 | } 122 | } 123 | 124 | //pub fn markup_parser_finish(context: /*Ignored*/&glib::MarkupParseContext) -> Result<(AttrList, GString, char), glib::Error> { 125 | // unsafe { TODO: call pango_sys:pango_markup_parser_finish() } 126 | //} 127 | 128 | //pub fn markup_parser_new(accel_marker: char) -> /*Ignored*/Option { 129 | // unsafe { TODO: call pango_sys:pango_markup_parser_new() } 130 | //} 131 | 132 | //#[cfg_attr(feature = "v1_38", deprecated)] 133 | //pub fn module_register(module: /*Ignored*/&mut IncludedModule) { 134 | // unsafe { TODO: call pango_sys:pango_module_register() } 135 | //} 136 | 137 | #[cfg_attr(feature = "v1_38", deprecated)] 138 | pub fn parse_enum( 139 | type_: glib::types::Type, 140 | str: Option<&str>, 141 | warn: bool, 142 | ) -> Option<(i32, GString)> { 143 | unsafe { 144 | let mut value = mem::MaybeUninit::uninit(); 145 | let mut possible_values = ptr::null_mut(); 146 | let ret = from_glib(pango_sys::pango_parse_enum( 147 | type_.to_glib(), 148 | str.to_glib_none().0, 149 | value.as_mut_ptr(), 150 | warn.to_glib(), 151 | &mut possible_values, 152 | )); 153 | let value = value.assume_init(); 154 | if ret { 155 | Some((value, from_glib_full(possible_values))) 156 | } else { 157 | None 158 | } 159 | } 160 | } 161 | 162 | pub fn parse_markup( 163 | markup_text: &str, 164 | accel_marker: char, 165 | ) -> Result<(AttrList, GString, char), glib::Error> { 166 | let length = markup_text.len() as i32; 167 | unsafe { 168 | let mut attr_list = ptr::null_mut(); 169 | let mut text = ptr::null_mut(); 170 | let mut accel_char = mem::MaybeUninit::uninit(); 171 | let mut error = ptr::null_mut(); 172 | let _ = pango_sys::pango_parse_markup( 173 | markup_text.to_glib_none().0, 174 | length, 175 | accel_marker.to_glib(), 176 | &mut attr_list, 177 | &mut text, 178 | accel_char.as_mut_ptr(), 179 | &mut error, 180 | ); 181 | let accel_char = accel_char.assume_init(); 182 | if error.is_null() { 183 | Ok(( 184 | from_glib_full(attr_list), 185 | from_glib_full(text), 186 | from_glib(accel_char), 187 | )) 188 | } else { 189 | Err(from_glib_full(error)) 190 | } 191 | } 192 | } 193 | 194 | pub fn parse_stretch(str: &str, warn: bool) -> Option { 195 | unsafe { 196 | let mut stretch = mem::MaybeUninit::uninit(); 197 | let ret = from_glib(pango_sys::pango_parse_stretch( 198 | str.to_glib_none().0, 199 | stretch.as_mut_ptr(), 200 | warn.to_glib(), 201 | )); 202 | let stretch = stretch.assume_init(); 203 | if ret { 204 | Some(from_glib(stretch)) 205 | } else { 206 | None 207 | } 208 | } 209 | } 210 | 211 | pub fn parse_style(str: &str, warn: bool) -> Option