mirror of
https://github.com/wez/wezterm.git
synced 2025-01-03 19:21:57 +03:00
Build our own freetype, harfbuzz
This is primarily for macos where the default freetype installation is unable to render color emoji, but should also help make things more consistent across the various platforms. It's a little bit awkward on linux because the font-loader crate pulls in the now-conflicting servo-font* crates. I've disabled font-loader on linux systems; it's just calling fontconfig under the covers anyway.
This commit is contained in:
parent
3777da13d2
commit
27cb18f8ae
8
.gitmodules
vendored
8
.gitmodules
vendored
@ -1,6 +1,12 @@
|
||||
[submodule "harfbuzz/harfbuzz"]
|
||||
path = ci/harfbuzz
|
||||
path = deps/harfbuzz/harfbuzz
|
||||
url = https://github.com/harfbuzz/harfbuzz.git
|
||||
[submodule "ci/esctest"]
|
||||
path = ci/esctest
|
||||
url = https://gitlab.freedesktop.org/terminal-wg/esctest
|
||||
[submodule "freetype/freetype2"]
|
||||
path = deps/freetype/freetype2
|
||||
url = git://git.savannah.gnu.org/freetype/freetype2.git
|
||||
[submodule "freetype/libpng"]
|
||||
path = deps/freetype/libpng
|
||||
url = https://github.com/glennrp/libpng.git
|
||||
|
@ -22,7 +22,6 @@ matrix:
|
||||
|
||||
before_script:
|
||||
- rustup component add rustfmt-preview
|
||||
- PREFIX=$TRAVIS_BUILD_DIR ./ci/build_harfbuzz.sh
|
||||
|
||||
script:
|
||||
- "if [[ \"$TRAVIS_RUST_VERSION\" == \"stable\" ]] ; then cargo fmt --all -- --check ; else true ; fi"
|
||||
@ -50,7 +49,3 @@ addons:
|
||||
- libxkbcommon-dev
|
||||
- libxkbcommon-x11-dev
|
||||
- ragel
|
||||
|
||||
env:
|
||||
global:
|
||||
- PKG_CONFIG_PATH=$TRAVIS_BUILD_DIR/lib/pkgconfig
|
||||
|
18
Cargo.toml
18
Cargo.toml
@ -17,11 +17,10 @@ serde_derive = "~1.0"
|
||||
toml = "~0.4"
|
||||
unicode-width = "~0.1"
|
||||
dirs = "~1.0"
|
||||
font-loader = "0.8"
|
||||
rusttype = "0.7"
|
||||
clipboard = "0.5"
|
||||
unicode-normalization = "~0.1"
|
||||
freetype = "~0.4"
|
||||
freetype = { path = "deps/freetype" }
|
||||
open = "1.2"
|
||||
structopt = "0.2"
|
||||
foreign-types = "0.3"
|
||||
@ -36,16 +35,25 @@ leb128 = "0.2"
|
||||
zstd = "0.4"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
harfbuzz-sys = { git = "https://github.com/wez/rust-harfbuzz", branch="coretext" }
|
||||
harfbuzz = { path = "deps/harfbuzz" }
|
||||
mio = "~0.6"
|
||||
mio-extras = "~2.0"
|
||||
|
||||
[dependencies.fontconfig]
|
||||
optional = true
|
||||
path = "deps/fontconfig"
|
||||
|
||||
[dependencies.term]
|
||||
path = "term"
|
||||
|
||||
[dependencies.termwiz]
|
||||
path = "termwiz"
|
||||
|
||||
[target.'cfg(any(windows, target_os = "macos"))'.dependencies.font-loader]
|
||||
# on linux, font-loader pulls in servo-font* crates which conflict with
|
||||
# our newer font related deps, so we avoid it on linux
|
||||
version = "0.8"
|
||||
|
||||
[target."cfg(windows)".dependencies.uds_windows]
|
||||
version = "0.1"
|
||||
|
||||
@ -61,7 +69,7 @@ features = [
|
||||
version = "~0.3"
|
||||
|
||||
[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
|
||||
servo-fontconfig = "~0.4"
|
||||
fontconfig = { path = "deps/fontconfig" }
|
||||
egli = "~0.4"
|
||||
x11 = {version ="~2.18", features = ["xlib_xcb"]}
|
||||
|
||||
@ -94,11 +102,11 @@ core-foundation = "0.6"
|
||||
debug-escape-sequences = ["term/debug-escape-sequences"]
|
||||
force-glutin = []
|
||||
force-rusttype = []
|
||||
force-fontconfig = ["fontconfig"]
|
||||
|
||||
[patch.crates-io]
|
||||
# We need https://github.com/tomaka/glutin/pull/1099
|
||||
glutin = { git = "https://github.com/yvt/glutin", branch="patch-macos-iscurrent" }
|
||||
harfbuzz-sys = { git = "https://github.com/wez/rust-harfbuzz", branch="coretext" }
|
||||
|
||||
[workspace]
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit f0b700db394ccdff30ff83961a3e2ea9ff4ea472
|
13
deps/fontconfig/Cargo.toml
vendored
Normal file
13
deps/fontconfig/Cargo.toml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
authors = ["Wez Furlong <wez@wezfurlong.org>"]
|
||||
name = "fontconfig"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
links = "fontconfig"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
libc = "~0.2"
|
||||
|
||||
[build-dependencies]
|
||||
pkg-config = "0.3"
|
23
deps/fontconfig/build.rs
vendored
Normal file
23
deps/fontconfig/build.rs
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
use pkg_config;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
|
||||
if let Ok(lib) = pkg_config::Config::new()
|
||||
.atleast_version("2.11.1")
|
||||
.find("fontconfig")
|
||||
{
|
||||
println!(
|
||||
"cargo:incdir={}",
|
||||
lib.include_paths[0]
|
||||
.clone()
|
||||
.into_os_string()
|
||||
.into_string()
|
||||
.unwrap()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
panic!("You need to install fontconfig");
|
||||
}
|
736
deps/fontconfig/src/lib.rs
vendored
Normal file
736
deps/fontconfig/src/lib.rs
vendored
Normal file
@ -0,0 +1,736 @@
|
||||
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use libc::*;
|
||||
|
||||
pub type FcChar8 = c_uchar;
|
||||
pub type FcChar16 = c_ushort;
|
||||
pub type FcChar32 = c_uint;
|
||||
pub type FcBool = c_int;
|
||||
|
||||
pub type enum__FcType = c_uint;
|
||||
pub const FcTypeVoid: u32 = 0_u32;
|
||||
pub const FcTypeInteger: u32 = 1_u32;
|
||||
pub const FcTypeDouble: u32 = 2_u32;
|
||||
pub const FcTypeString: u32 = 3_u32;
|
||||
pub const FcTypeBool: u32 = 4_u32;
|
||||
pub const FcTypeMatrix: u32 = 5_u32;
|
||||
pub const FcTypeCharSet: u32 = 6_u32;
|
||||
pub const FcTypeFTFace: u32 = 7_u32;
|
||||
pub const FcTypeLangSet: u32 = 8_u32;
|
||||
|
||||
pub type FcType = enum__FcType;
|
||||
|
||||
pub const FC_WEIGHT_THIN: c_int = 0;
|
||||
pub const FC_WEIGHT_EXTRALIGHT: c_int = 40;
|
||||
pub const FC_WEIGHT_ULTRALIGHT: c_int = FC_WEIGHT_EXTRALIGHT;
|
||||
pub const FC_WEIGHT_LIGHT: c_int = 50;
|
||||
pub const FC_WEIGHT_BOOK: c_int = 75;
|
||||
pub const FC_WEIGHT_REGULAR: c_int = 80;
|
||||
pub const FC_WEIGHT_NORMAL: c_int = FC_WEIGHT_REGULAR;
|
||||
pub const FC_WEIGHT_MEDIUM: c_int = 100;
|
||||
pub const FC_WEIGHT_DEMIBOLD: c_int = 180;
|
||||
pub const FC_WEIGHT_SEMIBOLD: c_int = FC_WEIGHT_DEMIBOLD;
|
||||
pub const FC_WEIGHT_BOLD: c_int = 200;
|
||||
pub const FC_WEIGHT_EXTRABOLD: c_int = 205;
|
||||
pub const FC_WEIGHT_ULTRABOLD: c_int = FC_WEIGHT_EXTRABOLD;
|
||||
pub const FC_WEIGHT_BLACK: c_int = 210;
|
||||
pub const FC_WEIGHT_HEAVY: c_int = FC_WEIGHT_BLACK;
|
||||
pub const FC_WEIGHT_EXTRABLACK: c_int = 215;
|
||||
pub const FC_WEIGHT_ULTRABLACK: c_int = FC_WEIGHT_EXTRABLACK;
|
||||
|
||||
pub const FC_SLANT_ROMAN: c_int = 0;
|
||||
pub const FC_SLANT_ITALIC: c_int = 100;
|
||||
pub const FC_SLANT_OBLIQUE: c_int = 110;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct struct__FcMatrix {
|
||||
pub xx: c_double,
|
||||
pub xy: c_double,
|
||||
pub yx: c_double,
|
||||
pub yy: c_double,
|
||||
}
|
||||
|
||||
pub type FcMatrix = struct__FcMatrix;
|
||||
|
||||
pub type struct__FcCharSet = c_void;
|
||||
|
||||
pub type FcCharSet = struct__FcCharSet;
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct struct__FcObjectType {
|
||||
pub object: *mut c_char,
|
||||
pub _type: FcType,
|
||||
}
|
||||
|
||||
pub type FcObjectType = struct__FcObjectType;
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct struct__FcConstant {
|
||||
pub name: *mut FcChar8,
|
||||
pub object: *mut c_char,
|
||||
pub value: c_int,
|
||||
}
|
||||
|
||||
pub type FcConstant = struct__FcConstant;
|
||||
|
||||
pub type enum__FcResult = c_uint;
|
||||
pub const FcResultMatch: u32 = 0_u32;
|
||||
pub const FcResultNoMatch: u32 = 1_u32;
|
||||
pub const FcResultTypeMismatch: u32 = 2_u32;
|
||||
pub const FcResultNoId: u32 = 3_u32;
|
||||
pub const FcResultOutOfMemory: u32 = 4_u32;
|
||||
|
||||
pub type FcResult = enum__FcResult;
|
||||
|
||||
pub type struct__FcPattern = c_void;
|
||||
|
||||
pub type FcPattern = struct__FcPattern;
|
||||
|
||||
pub type struct__FcLangSet = c_void;
|
||||
|
||||
pub type FcLangSet = struct__FcLangSet;
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct struct__FcValue {
|
||||
pub _type: FcType,
|
||||
pub u: union_unnamed1,
|
||||
}
|
||||
|
||||
pub type FcValue = struct__FcValue;
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct struct__FcFontSet {
|
||||
pub nfont: c_int,
|
||||
pub sfont: c_int,
|
||||
pub fonts: *mut *mut FcPattern,
|
||||
}
|
||||
|
||||
pub type FcFontSet = struct__FcFontSet;
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct struct__FcObjectSet {
|
||||
pub nobject: c_int,
|
||||
pub sobject: c_int,
|
||||
pub objects: *mut *mut c_char,
|
||||
}
|
||||
|
||||
pub type FcObjectSet = struct__FcObjectSet;
|
||||
|
||||
pub type enum__FcMatchKind = c_uint;
|
||||
pub const FcMatchPattern: u32 = 0_u32;
|
||||
pub const FcMatchFont: u32 = 1_u32;
|
||||
pub const FcMatchScan: u32 = 2_u32;
|
||||
|
||||
pub type FcMatchKind = enum__FcMatchKind;
|
||||
|
||||
pub type enum__FcLangResult = c_uint;
|
||||
pub const FcLangEqual: u32 = 0_u32;
|
||||
pub const FcLangDifferentCountry: u32 = 1_u32;
|
||||
pub const FcLangDifferentTerritory: u32 = 1_u32;
|
||||
pub const FcLangDifferentLang: u32 = 2_u32;
|
||||
|
||||
pub type FcLangResult = enum__FcLangResult;
|
||||
|
||||
pub type enum__FcSetName = c_uint;
|
||||
pub const FcSetSystem: u32 = 0_u32;
|
||||
pub const FcSetApplication: u32 = 1_u32;
|
||||
|
||||
pub type FcSetName = enum__FcSetName;
|
||||
|
||||
pub type struct__FcAtomic = c_void;
|
||||
|
||||
pub type FcAtomic = struct__FcAtomic;
|
||||
|
||||
pub type FcEndian = c_uint;
|
||||
pub const FcEndianBig: u32 = 0_u32;
|
||||
pub const FcEndianLittle: u32 = 1_u32;
|
||||
|
||||
pub type struct__FcConfig = c_void;
|
||||
|
||||
pub type FcConfig = struct__FcConfig;
|
||||
|
||||
pub type struct__FcGlobalCache = c_void;
|
||||
|
||||
pub type FcFileCache = struct__FcGlobalCache;
|
||||
|
||||
pub type struct__FcBlanks = c_void;
|
||||
|
||||
pub type FcBlanks = struct__FcBlanks;
|
||||
|
||||
pub type struct__FcStrList = c_void;
|
||||
|
||||
pub type FcStrList = struct__FcStrList;
|
||||
|
||||
pub type struct__FcStrSet = c_void;
|
||||
|
||||
pub type FcStrSet = struct__FcStrSet;
|
||||
|
||||
pub type struct__FcCache = c_void;
|
||||
|
||||
pub type FcCache = struct__FcCache;
|
||||
|
||||
pub type union_unnamed1 = c_void;
|
||||
|
||||
extern "C" {
|
||||
|
||||
pub fn FcBlanksCreate() -> *mut FcBlanks;
|
||||
|
||||
pub fn FcBlanksDestroy(b: *mut FcBlanks);
|
||||
|
||||
pub fn FcBlanksAdd(b: *mut FcBlanks, ucs4: FcChar32) -> FcBool;
|
||||
|
||||
pub fn FcBlanksIsMember(b: *mut FcBlanks, ucs4: FcChar32) -> FcBool;
|
||||
|
||||
pub fn FcCacheDir(c: *mut FcCache) -> *const FcChar8;
|
||||
|
||||
pub fn FcCacheCopySet(c: *const FcCache) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcCacheSubdir(c: *const FcCache, i: c_int) -> *const FcChar8;
|
||||
|
||||
pub fn FcCacheNumSubdir(c: *const FcCache) -> c_int;
|
||||
|
||||
pub fn FcCacheNumFont(c: *const FcCache) -> c_int;
|
||||
|
||||
pub fn FcDirCacheUnlink(dir: *const FcChar8, config: *mut FcConfig) -> FcBool;
|
||||
|
||||
pub fn FcDirCacheValid(cache_file: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcConfigHome() -> *mut FcChar8;
|
||||
|
||||
pub fn FcConfigEnableHome(enable: FcBool) -> FcBool;
|
||||
|
||||
pub fn FcConfigFilename(url: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcConfigCreate() -> *mut FcConfig;
|
||||
|
||||
pub fn FcConfigReference(config: *mut FcConfig) -> *mut FcConfig;
|
||||
|
||||
pub fn FcConfigDestroy(config: *mut FcConfig);
|
||||
|
||||
pub fn FcConfigSetCurrent(config: *mut FcConfig) -> FcBool;
|
||||
|
||||
pub fn FcConfigGetCurrent() -> *mut FcConfig;
|
||||
|
||||
pub fn FcConfigUptoDate(config: *mut FcConfig) -> FcBool;
|
||||
|
||||
pub fn FcConfigBuildFonts(config: *mut FcConfig) -> FcBool;
|
||||
|
||||
pub fn FcConfigGetFontDirs(config: *mut FcConfig) -> *mut FcStrList;
|
||||
|
||||
pub fn FcConfigGetConfigDirs(config: *mut FcConfig) -> *mut FcStrList;
|
||||
|
||||
pub fn FcConfigGetConfigFiles(config: *mut FcConfig) -> *mut FcStrList;
|
||||
|
||||
pub fn FcConfigGetCache(config: *mut FcConfig) -> *mut FcChar8;
|
||||
|
||||
pub fn FcConfigGetBlanks(config: *mut FcConfig) -> *mut FcBlanks;
|
||||
|
||||
pub fn FcConfigGetCacheDirs(config: *const FcConfig) -> *mut FcStrList;
|
||||
|
||||
pub fn FcConfigGetRescanInterval(config: *mut FcConfig) -> c_int;
|
||||
|
||||
pub fn FcConfigSetRescanInterval(config: *mut FcConfig, rescanInterval: c_int) -> FcBool;
|
||||
|
||||
pub fn FcConfigGetFonts(config: *mut FcConfig, set: FcSetName) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcConfigAppFontAddFile(config: *mut FcConfig, file: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcConfigAppFontAddDir(config: *mut FcConfig, dir: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcConfigAppFontClear(config: *mut FcConfig);
|
||||
|
||||
pub fn FcConfigSubstituteWithPat(
|
||||
config: *mut FcConfig,
|
||||
p: *mut FcPattern,
|
||||
p_pat: *mut FcPattern,
|
||||
kind: FcMatchKind,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcConfigSubstitute(
|
||||
config: *mut FcConfig,
|
||||
p: *mut FcPattern,
|
||||
kind: FcMatchKind,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcCharSetCreate() -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetNew() -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetDestroy(fcs: *mut FcCharSet);
|
||||
|
||||
pub fn FcCharSetAddChar(fcs: *mut FcCharSet, ucs4: FcChar32) -> FcBool;
|
||||
|
||||
pub fn FcCharSetCopy(src: *mut FcCharSet) -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetEqual(a: *const FcCharSet, b: *const FcCharSet) -> FcBool;
|
||||
|
||||
pub fn FcCharSetIntersect(a: *const FcCharSet, b: *const FcCharSet) -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetUnion(a: *const FcCharSet, b: *const FcCharSet) -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetSubtract(a: *const FcCharSet, b: *const FcCharSet) -> *mut FcCharSet;
|
||||
|
||||
pub fn FcCharSetMerge(a: *mut FcCharSet, b: *const FcCharSet, changed: *mut FcBool) -> FcBool;
|
||||
|
||||
pub fn FcCharSetHasChar(fcs: *const FcCharSet, ucs4: FcChar32) -> FcBool;
|
||||
|
||||
pub fn FcCharSetCount(a: *const FcCharSet) -> FcChar32;
|
||||
|
||||
pub fn FcCharSetIntersectCount(a: *const FcCharSet, b: *const FcCharSet) -> FcChar32;
|
||||
|
||||
pub fn FcCharSetSubtractCount(a: *const FcCharSet, b: *const FcCharSet) -> FcChar32;
|
||||
|
||||
pub fn FcCharSetIsSubset(a: *const FcCharSet, bi: *const FcCharSet) -> FcBool;
|
||||
|
||||
pub fn FcCharSetFirstPage(
|
||||
a: *const FcCharSet,
|
||||
map: *mut FcChar32,
|
||||
next: *mut FcChar32,
|
||||
) -> FcChar32;
|
||||
|
||||
pub fn FcCharSetNextPage(
|
||||
a: *const FcCharSet,
|
||||
map: *mut FcChar32,
|
||||
next: *mut FcChar32,
|
||||
) -> FcChar32;
|
||||
|
||||
pub fn FcCharSetCoverage(
|
||||
a: *const FcCharSet,
|
||||
page: FcChar32,
|
||||
result: *mut FcChar32,
|
||||
) -> FcChar32;
|
||||
|
||||
pub fn FcValuePrint(v: FcValue);
|
||||
|
||||
pub fn FcPatternPrint(p: *const FcPattern);
|
||||
|
||||
pub fn FcFontSetPrint(s: *mut FcFontSet);
|
||||
|
||||
pub fn FcDefaultSubstitute(pattern: *mut FcPattern);
|
||||
|
||||
pub fn FcFileIsDir(file: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcFileScan(
|
||||
set: *mut FcFontSet,
|
||||
dirs: *mut FcStrSet,
|
||||
cache: *mut FcFileCache,
|
||||
blanks: *mut FcBlanks,
|
||||
file: *const FcChar8,
|
||||
force: FcBool,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcDirScan(
|
||||
set: *mut FcFontSet,
|
||||
dirs: *mut FcStrSet,
|
||||
cache: *mut FcFileCache,
|
||||
blanks: *mut FcBlanks,
|
||||
dir: *const FcChar8,
|
||||
force: FcBool,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcDirSave(set: *mut FcFontSet, dirs: *const FcStrSet, dir: *mut FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcDirCacheLoad(
|
||||
dir: *const FcChar8,
|
||||
config: *mut FcConfig,
|
||||
cache_file: *mut *mut FcChar8,
|
||||
) -> *mut FcCache;
|
||||
|
||||
pub fn FcDirCacheRead(
|
||||
dir: *const FcChar8,
|
||||
force: FcBool,
|
||||
config: *mut FcConfig,
|
||||
) -> *mut FcCache;
|
||||
|
||||
//pub fn FcDirCacheLoadFile(cache_file: *mut FcChar8, file_stat: *mut struct_stat) -> *mut FcCache;
|
||||
|
||||
pub fn FcDirCacheUnload(cache: *mut FcCache);
|
||||
|
||||
pub fn FcFreeTypeQuery(
|
||||
file: *const FcChar8,
|
||||
id: c_int,
|
||||
blanks: *mut FcBlanks,
|
||||
count: *mut c_int,
|
||||
) -> *mut FcPattern;
|
||||
|
||||
pub fn FcFontSetCreate() -> *mut FcFontSet;
|
||||
|
||||
pub fn FcFontSetDestroy(s: *mut FcFontSet);
|
||||
|
||||
pub fn FcFontSetAdd(s: *mut FcFontSet, font: *mut FcPattern) -> FcBool;
|
||||
|
||||
pub fn FcInitLoadConfig() -> *mut FcConfig;
|
||||
|
||||
pub fn FcInitLoadConfigAndFonts() -> *mut FcConfig;
|
||||
|
||||
pub fn FcInit() -> FcBool;
|
||||
|
||||
pub fn FcFini();
|
||||
|
||||
pub fn FcGetVersion() -> c_int;
|
||||
|
||||
pub fn FcInitReinitialize() -> FcBool;
|
||||
|
||||
pub fn FcInitBringUptoDate() -> FcBool;
|
||||
|
||||
pub fn FcGetLangs() -> *mut FcStrSet;
|
||||
|
||||
pub fn FcLangGetCharSet(lang: *const FcChar8) -> *mut FcCharSet;
|
||||
|
||||
pub fn FcLangSetCreate() -> *mut FcLangSet;
|
||||
|
||||
pub fn FcLangSetDestroy(ls: *mut FcLangSet);
|
||||
|
||||
pub fn FcLangSetCopy(ls: *const FcLangSet) -> *mut FcLangSet;
|
||||
|
||||
pub fn FcLangSetAdd(ls: *mut FcLangSet, lang: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcLangSetHasLang(ls: *const FcLangSet, lang: *const FcChar8) -> FcLangResult;
|
||||
|
||||
pub fn FcLangSetCompare(lsa: *const FcLangSet, lsb: *const FcLangSet) -> FcLangResult;
|
||||
|
||||
pub fn FcLangSetContains(lsa: *const FcLangSet, lsb: *const FcLangSet) -> FcBool;
|
||||
|
||||
pub fn FcLangSetEqual(lsa: *const FcLangSet, lsb: *const FcLangSet) -> FcBool;
|
||||
|
||||
pub fn FcLangSetHash(ls: *const FcLangSet) -> FcChar32;
|
||||
|
||||
pub fn FcLangSetGetLangs(ls: *const FcLangSet) -> *mut FcStrSet;
|
||||
|
||||
pub fn FcObjectSetCreate() -> *mut FcObjectSet;
|
||||
|
||||
pub fn FcObjectSetAdd(os: *mut FcObjectSet, object: *const c_char) -> FcBool;
|
||||
|
||||
pub fn FcObjectSetDestroy(os: *mut FcObjectSet);
|
||||
|
||||
//pub fn FcObjectSetVaBuild(first: *mut c_char, va: *mut __va_list_tag) -> *mut FcObjectSet;
|
||||
|
||||
pub fn FcObjectSetBuild(first: *mut c_char, ...) -> *mut FcObjectSet;
|
||||
|
||||
pub fn FcFontSetList(
|
||||
config: *mut FcConfig,
|
||||
sets: *mut *mut FcFontSet,
|
||||
nsets: c_int,
|
||||
p: *mut FcPattern,
|
||||
os: *mut FcObjectSet,
|
||||
) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcFontList(
|
||||
config: *mut FcConfig,
|
||||
p: *mut FcPattern,
|
||||
os: *mut FcObjectSet,
|
||||
) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcAtomicCreate(file: *const FcChar8) -> *mut FcAtomic;
|
||||
|
||||
pub fn FcAtomicLock(atomic: *mut FcAtomic) -> FcBool;
|
||||
|
||||
pub fn FcAtomicNewFile(atomic: *mut FcAtomic) -> *mut FcChar8;
|
||||
|
||||
pub fn FcAtomicOrigFile(atomic: *mut FcAtomic) -> *mut FcChar8;
|
||||
|
||||
pub fn FcAtomicReplaceOrig(atomic: *mut FcAtomic) -> FcBool;
|
||||
|
||||
pub fn FcAtomicDeleteNew(atomic: *mut FcAtomic);
|
||||
|
||||
pub fn FcAtomicUnlock(atomic: *mut FcAtomic);
|
||||
|
||||
pub fn FcAtomicDestroy(atomic: *mut FcAtomic);
|
||||
|
||||
pub fn FcFontSetMatch(
|
||||
config: *mut FcConfig,
|
||||
sets: *mut *mut FcFontSet,
|
||||
nsets: c_int,
|
||||
p: *mut FcPattern,
|
||||
result: *mut FcResult,
|
||||
) -> *mut FcPattern;
|
||||
|
||||
pub fn FcFontMatch(
|
||||
config: *mut FcConfig,
|
||||
p: *mut FcPattern,
|
||||
result: *mut FcResult,
|
||||
) -> *mut FcPattern;
|
||||
|
||||
pub fn FcFontRenderPrepare(
|
||||
config: *mut FcConfig,
|
||||
pat: *mut FcPattern,
|
||||
font: *mut FcPattern,
|
||||
) -> *mut FcPattern;
|
||||
|
||||
pub fn FcFontSetSort(
|
||||
config: *mut FcConfig,
|
||||
sets: *mut *mut FcFontSet,
|
||||
nsets: c_int,
|
||||
p: *mut FcPattern,
|
||||
trim: FcBool,
|
||||
csp: *mut *mut FcCharSet,
|
||||
result: *mut FcResult,
|
||||
) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcFontSort(
|
||||
config: *mut FcConfig,
|
||||
p: *mut FcPattern,
|
||||
trim: FcBool,
|
||||
csp: *mut *mut FcCharSet,
|
||||
result: *mut FcResult,
|
||||
) -> *mut FcFontSet;
|
||||
|
||||
pub fn FcFontSetSortDestroy(fs: *mut FcFontSet);
|
||||
|
||||
pub fn FcMatrixCopy(mat: *const FcMatrix) -> *mut FcMatrix;
|
||||
|
||||
pub fn FcMatrixEqual(mat1: *const FcMatrix, mat2: *const FcMatrix) -> FcBool;
|
||||
|
||||
pub fn FcMatrixMultiply(result: *mut FcMatrix, a: *const FcMatrix, b: *const FcMatrix);
|
||||
|
||||
pub fn FcMatrixRotate(m: *mut FcMatrix, c: c_double, s: c_double);
|
||||
|
||||
pub fn FcMatrixScale(m: *mut FcMatrix, sx: c_double, sy: c_double);
|
||||
|
||||
pub fn FcMatrixShear(m: *mut FcMatrix, sh: c_double, sv: c_double);
|
||||
|
||||
pub fn FcNameRegisterObjectTypes(types: *const FcObjectType, ntype: c_int) -> FcBool;
|
||||
|
||||
pub fn FcNameUnregisterObjectTypes(types: *const FcObjectType, ntype: c_int) -> FcBool;
|
||||
|
||||
pub fn FcNameGetObjectType(object: *const c_char) -> *const FcObjectType;
|
||||
|
||||
pub fn FcNameRegisterConstants(consts: *const FcConstant, nconsts: c_int) -> FcBool;
|
||||
|
||||
pub fn FcNameUnregisterConstants(consts: *const FcConstant, nconsts: c_int) -> FcBool;
|
||||
|
||||
pub fn FcNameGetConstant(string: *mut FcChar8) -> *const FcConstant;
|
||||
|
||||
pub fn FcNameConstant(string: *mut FcChar8, result: *mut c_int) -> FcBool;
|
||||
|
||||
pub fn FcNameParse(name: *const FcChar8) -> *mut FcPattern;
|
||||
|
||||
pub fn FcNameUnparse(pat: *mut FcPattern) -> *mut FcChar8;
|
||||
|
||||
pub fn FcPatternCreate() -> *mut FcPattern;
|
||||
|
||||
pub fn FcPatternDuplicate(p: *const FcPattern) -> *mut FcPattern;
|
||||
|
||||
pub fn FcPatternReference(p: *mut FcPattern);
|
||||
|
||||
pub fn FcPatternFilter(p: *mut FcPattern, os: *const FcObjectSet) -> *mut FcPattern;
|
||||
|
||||
pub fn FcValueDestroy(v: FcValue);
|
||||
|
||||
pub fn FcValueEqual(va: FcValue, vb: FcValue) -> FcBool;
|
||||
|
||||
pub fn FcValueSave(v: FcValue) -> FcValue;
|
||||
|
||||
pub fn FcPatternDestroy(p: *mut FcPattern);
|
||||
|
||||
pub fn FcPatternEqual(pa: *const FcPattern, pb: *const FcPattern) -> FcBool;
|
||||
|
||||
pub fn FcPatternEqualSubset(
|
||||
pa: *const FcPattern,
|
||||
pb: *const FcPattern,
|
||||
os: *const FcObjectSet,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternHash(p: *const FcPattern) -> FcChar32;
|
||||
|
||||
pub fn FcPatternAdd(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
value: FcValue,
|
||||
append: FcBool,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddWeak(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
value: FcValue,
|
||||
append: FcBool,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternGet(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
id: c_int,
|
||||
v: *mut FcValue,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternDel(p: *mut FcPattern, object: *const c_char) -> FcBool;
|
||||
|
||||
pub fn FcPatternRemove(p: *mut FcPattern, object: *const c_char, id: c_int) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddInteger(p: *mut FcPattern, object: *const c_char, i: c_int) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddDouble(p: *mut FcPattern, object: *const c_char, d: c_double) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddString(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
s: *const FcChar8,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddMatrix(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
s: *const FcMatrix,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddCharSet(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
c: *const FcCharSet,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddBool(p: *mut FcPattern, object: *const c_char, b: FcBool) -> FcBool;
|
||||
|
||||
pub fn FcPatternAddLangSet(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
ls: *const FcLangSet,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcPatternGetInteger(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
i: *mut c_int,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetDouble(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
d: *mut c_double,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetString(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
s: *mut *mut FcChar8,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetMatrix(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
s: *mut *mut FcMatrix,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetCharSet(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
c: *mut *mut FcCharSet,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetBool(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
b: *mut FcBool,
|
||||
) -> FcResult;
|
||||
|
||||
pub fn FcPatternGetLangSet(
|
||||
p: *mut FcPattern,
|
||||
object: *const c_char,
|
||||
n: c_int,
|
||||
ls: *mut *mut FcLangSet,
|
||||
) -> FcResult;
|
||||
|
||||
//pub fn FcPatternVaBuild(p: *mut FcPattern, va: *mut __va_list_tag) -> *mut FcPattern;
|
||||
|
||||
pub fn FcPatternBuild(p: *mut FcPattern, ...) -> *mut FcPattern;
|
||||
|
||||
pub fn FcPatternFormat(pat: *mut FcPattern, format: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrCopy(s: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrCopyFilename(s: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrPlus(s1: *const FcChar8, s2: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrFree(s: *mut FcChar8);
|
||||
|
||||
pub fn FcStrDowncase(s: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrCmpIgnoreCase(s1: *const FcChar8, s2: *const FcChar8) -> c_int;
|
||||
|
||||
pub fn FcStrCmp(s1: *const FcChar8, s2: *const FcChar8) -> c_int;
|
||||
|
||||
pub fn FcStrStrIgnoreCase(s1: *const FcChar8, s2: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrStr(s1: *const FcChar8, s2: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcUtf8ToUcs4(src_orig: *mut FcChar8, dst: *mut FcChar32, len: c_int) -> c_int;
|
||||
|
||||
pub fn FcUtf8Len(
|
||||
string: *mut FcChar8,
|
||||
len: c_int,
|
||||
nchar: *mut c_int,
|
||||
wchar: *mut c_int,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcUcs4ToUtf8(ucs4: FcChar32, dest: *mut FcChar8) -> c_int;
|
||||
|
||||
pub fn FcUtf16ToUcs4(
|
||||
src_orig: *mut FcChar8,
|
||||
endian: FcEndian,
|
||||
dst: *mut FcChar32,
|
||||
len: c_int,
|
||||
) -> c_int;
|
||||
|
||||
pub fn FcUtf16Len(
|
||||
string: *mut FcChar8,
|
||||
endian: FcEndian,
|
||||
len: c_int,
|
||||
nchar: *mut c_int,
|
||||
wchar: *mut c_int,
|
||||
) -> FcBool;
|
||||
|
||||
pub fn FcStrDirname(file: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrBasename(file: *const FcChar8) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrSetCreate() -> *mut FcStrSet;
|
||||
|
||||
pub fn FcStrSetMember(set: *mut FcStrSet, s: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcStrSetEqual(sa: *mut FcStrSet, sb: *mut FcStrSet) -> FcBool;
|
||||
|
||||
pub fn FcStrSetAdd(set: *mut FcStrSet, s: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcStrSetAddFilename(set: *mut FcStrSet, s: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcStrSetDel(set: *mut FcStrSet, s: *const FcChar8) -> FcBool;
|
||||
|
||||
pub fn FcStrSetDestroy(set: *mut FcStrSet);
|
||||
|
||||
pub fn FcStrListCreate(set: *mut FcStrSet) -> *mut FcStrList;
|
||||
|
||||
pub fn FcStrListNext(list: *mut FcStrList) -> *mut FcChar8;
|
||||
|
||||
pub fn FcStrListDone(list: *mut FcStrList);
|
||||
|
||||
pub fn FcConfigParseAndLoad(
|
||||
config: *mut FcConfig,
|
||||
file: *const FcChar8,
|
||||
complain: FcBool,
|
||||
) -> FcBool;
|
||||
|
||||
}
|
12
deps/freetype/Cargo.toml
vendored
Normal file
12
deps/freetype/Cargo.toml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
authors = ["Wez Furlong <wez@wezfurlong.org>"]
|
||||
name = "freetype"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
links = "freetype"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1"
|
6
deps/freetype/bindings.h
vendored
Normal file
6
deps/freetype/bindings.h
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftlcdfil.h>
|
||||
#include <freetype/tttables.h>
|
||||
#include <freetype/ftmodapi.h>
|
||||
#include <freetype/ftoutln.h>
|
31
deps/freetype/build.rs
vendored
Normal file
31
deps/freetype/build.rs
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
use cmake::Config;
|
||||
use std::env;
|
||||
|
||||
fn libpng() {
|
||||
let mut config = Config::new("libpng");
|
||||
let dst = config.profile("Release").build();
|
||||
println!("cargo:rustc-link-search=native={}/lib", dst.display());
|
||||
println!("cargo:rustc-link-lib=static=png");
|
||||
}
|
||||
|
||||
fn freetype() {
|
||||
let mut config = Config::new("freetype2");
|
||||
let dst = config
|
||||
.define("FT_WITH_PNG", "ON")
|
||||
.profile("Release")
|
||||
.build();
|
||||
println!("cargo:rustc-link-search=native={}/lib", dst.display());
|
||||
println!("cargo:rustc-link-lib=static=freetype");
|
||||
println!("cargo:rustc-link-search=native=/usr/lib");
|
||||
println!("cargo:rustc-link-lib=bz2");
|
||||
println!("cargo:rustc-link-lib=z");
|
||||
println!("cargo:include={}/include/freetype2", dst.display());
|
||||
println!("cargo:lib={}/lib/libfreetype.a", dst.display());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
libpng();
|
||||
freetype();
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
println!("cargo:outdir={}", out_dir);
|
||||
}
|
1
deps/freetype/freetype2
vendored
Submodule
1
deps/freetype/freetype2
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fdb10e8b50cfff7be2ec2b77cb4a695f3d77643c
|
1
deps/freetype/libpng
vendored
Submodule
1
deps/freetype/libpng
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 8439534daa1d3a5705ba92e653eda9251246dd61
|
20
deps/freetype/regenerate.sh
vendored
Executable file
20
deps/freetype/regenerate.sh
vendored
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
bindgen bindings.h -o src/lib.rs \
|
||||
--no-doc-comments \
|
||||
--blacklist-type "FT_(Int16|UInt16|Int32|UInt32|Int16|Int64|UInt64)" \
|
||||
--raw-line "#![allow(non_snake_case)]" \
|
||||
--raw-line "#![allow(non_camel_case_types)]" \
|
||||
--raw-line "#![allow(non_upper_case_globals)]" \
|
||||
--raw-line "pub type FT_Int16 = i16;" \
|
||||
--raw-line "pub type FT_UInt16 = u16;" \
|
||||
--raw-line "pub type FT_Int32 = i32;" \
|
||||
--raw-line "pub type FT_UInt32 = u32;" \
|
||||
--raw-line "pub type FT_Int64= i64;" \
|
||||
--raw-line "pub type FT_UInt64= u64;" \
|
||||
--default-enum-style rust \
|
||||
--generate=functions,types,vars \
|
||||
--whitelist-function="FT_.*" \
|
||||
--whitelist-type="FT_.*" \
|
||||
--whitelist-var="FT_.*" \
|
||||
-- -Ifreetype2/include
|
3710
deps/freetype/src/lib.rs
vendored
Normal file
3710
deps/freetype/src/lib.rs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
deps/harfbuzz/Cargo.toml
vendored
Normal file
13
deps/harfbuzz/Cargo.toml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
authors = ["Wez Furlong <wez@wezfurlong.org>"]
|
||||
name = "harfbuzz"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
links = "harfbuzz"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
freetype = { path = "../freetype" }
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1"
|
2
deps/harfbuzz/bindings.h
vendored
Normal file
2
deps/harfbuzz/bindings.h
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#include <hb.h>
|
||||
#include <hb-ft.h>
|
39
deps/harfbuzz/build.rs
vendored
Normal file
39
deps/harfbuzz/build.rs
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
use cmake::Config;
|
||||
use std::env;
|
||||
|
||||
fn harfbuzz() {
|
||||
let mut config = Config::new("harfbuzz");
|
||||
for (key, value) in std::env::vars() {
|
||||
println!("{}: {}", key, value);
|
||||
}
|
||||
|
||||
let ft_outdir = std::env::var("DEP_FREETYPE_OUTDIR").unwrap();
|
||||
|
||||
let dst = config
|
||||
.env("CMAKE_PREFIX_PATH", &ft_outdir)
|
||||
.cxxflag("-DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR")
|
||||
.define("HB_HAVE_FREETYPE", "ON")
|
||||
.define("HB_BUILD_TESTS", "OFF")
|
||||
.define(
|
||||
"FREETYPE_LIBRARY",
|
||||
std::env::var("DEP_FREETYPE_LIB").unwrap(),
|
||||
)
|
||||
.define(
|
||||
"FREETYPE_INCLUDE_DIRS",
|
||||
std::env::var("DEP_FREETYPE_INCLUDE").unwrap(),
|
||||
)
|
||||
.profile("Release")
|
||||
.build();
|
||||
println!("cargo:rustc-link-search=native={}/lib", ft_outdir);
|
||||
println!("cargo:rustc-link-search=native={}/lib", dst.display());
|
||||
println!("cargo:rustc-link-lib=static=harfbuzz");
|
||||
println!("cargo:rustc-link-search=native=/usr/lib");
|
||||
println!("cargo:rustc-link-lib=bz2");
|
||||
println!("cargo:rustc-link-lib=z");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
harfbuzz();
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
println!("cargo:outdir={}", out_dir);
|
||||
}
|
1
deps/harfbuzz/harfbuzz
vendored
Submodule
1
deps/harfbuzz/harfbuzz
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit bcb4e505d6ffe33e3268a06698e75d6be0e64957
|
12
deps/harfbuzz/regenerate.sh
vendored
Executable file
12
deps/harfbuzz/regenerate.sh
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
bindgen bindings.h -o src/lib.rs \
|
||||
--no-doc-comments \
|
||||
--raw-line "#![allow(non_snake_case)]" \
|
||||
--raw-line "#![allow(non_camel_case_types)]" \
|
||||
--raw-line "#![allow(non_upper_case_globals)]" \
|
||||
--default-enum-style rust \
|
||||
--generate=functions,types,vars \
|
||||
--whitelist-function="hb_.*" \
|
||||
--whitelist-type="hb_.*" \
|
||||
-- -Iharfbuzz/src -I../freetype/freetype2/include
|
4864
deps/harfbuzz/src/lib.rs
vendored
Normal file
4864
deps/harfbuzz/src/lib.rs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
//! Slightly higher level helper for fontconfig
|
||||
|
||||
use failure::{self, Error};
|
||||
pub use fontconfig::fontconfig::*;
|
||||
pub use fontconfig::*;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
@ -53,21 +53,11 @@ impl FontSet {
|
||||
position: 0,
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn add(&mut self, pat: &Pattern) {
|
||||
unsafe {
|
||||
FcFontSetAdd(self.fonts, pat.pat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(dead_code)]
|
||||
pub enum MatchKind {
|
||||
Pattern = FcMatchPattern as isize,
|
||||
Font = FcMatchFont as isize,
|
||||
Scan = FcMatchScan as isize,
|
||||
}
|
||||
|
||||
pub struct FcResultWrap(FcResult);
|
||||
@ -105,7 +95,6 @@ pub struct Pattern {
|
||||
}
|
||||
|
||||
impl Pattern {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> Result<Pattern, Error> {
|
||||
unsafe {
|
||||
let p = FcPatternCreate();
|
||||
@ -114,7 +103,6 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn add_string(&mut self, key: &str, value: &str) -> Result<(), Error> {
|
||||
let key = CString::new(key)?;
|
||||
let value = CString::new(value)?;
|
||||
@ -129,7 +117,6 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn add_double(&mut self, key: &str, value: f64) -> Result<(), Error> {
|
||||
let key = CString::new(key)?;
|
||||
unsafe {
|
||||
@ -143,7 +130,6 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn add_integer(&mut self, key: &str, value: i32) -> Result<(), Error> {
|
||||
let key = CString::new(key)?;
|
||||
unsafe {
|
||||
@ -157,24 +143,14 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn family(&mut self, family: &str) -> Result<(), Error> {
|
||||
self.add_string("family", family)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn monospace(&mut self) -> Result<(), Error> {
|
||||
self.add_integer("spacing", FC_MONO)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn print(&self) {
|
||||
unsafe {
|
||||
FcPatternPrint(self.pat);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn format(&self, fmt: &str) -> Result<String, Error> {
|
||||
let fmt = CString::new(fmt)?;
|
||||
unsafe {
|
||||
@ -213,15 +189,6 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn find_match(&self) -> Result<Pattern, Error> {
|
||||
unsafe {
|
||||
let mut res = FcResultWrap(0);
|
||||
let pat = FcFontMatch(ptr::null_mut(), self.pat, &mut res.0 as *mut _);
|
||||
res.result(Pattern { pat })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sort(&self, trim: bool) -> Result<FontSet, Error> {
|
||||
unsafe {
|
||||
let mut res = FcResultWrap(0);
|
||||
@ -241,7 +208,6 @@ impl Pattern {
|
||||
self.get_string("file")
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_double(&self, key: &str) -> Result<f64, Error> {
|
||||
unsafe {
|
||||
let key = CString::new(key)?;
|
||||
@ -260,25 +226,6 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_integer(&self, key: &str) -> Result<i32, Error> {
|
||||
unsafe {
|
||||
let key = CString::new(key)?;
|
||||
let mut ival: i32 = 0;
|
||||
let res = FcResultWrap(FcPatternGetInteger(
|
||||
self.pat,
|
||||
key.as_ptr(),
|
||||
0,
|
||||
&mut ival as *mut _,
|
||||
));
|
||||
if !res.succeeded() {
|
||||
Err(res.as_err())
|
||||
} else {
|
||||
Ok(ival)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_string(&self, key: &str) -> Result<String, Error> {
|
||||
unsafe {
|
||||
let key = CString::new(key)?;
|
||||
|
@ -2,7 +2,9 @@
|
||||
use crate::config::{Config, TextStyle};
|
||||
use crate::font::fontloader;
|
||||
use crate::font::ftfont::FreeTypeFontImpl;
|
||||
use crate::font::{ftwrap, FallbackIdx, Font, FontSystem, GlyphInfo, NamedFont};
|
||||
use crate::font::{
|
||||
ftwrap, shape_with_harfbuzz, FallbackIdx, Font, FontSystem, GlyphInfo, NamedFont,
|
||||
};
|
||||
use failure::Error;
|
||||
|
||||
struct NamedFontImpl {
|
||||
@ -63,29 +65,7 @@ impl FontSystem for FontLoaderAndFreeType {
|
||||
}))
|
||||
}
|
||||
}
|
||||
impl NamedFontImpl {
|
||||
fn shape_codepoint(&mut self, c: char, cluster: usize) -> Result<GlyphInfo, Error> {
|
||||
for (font_idx, font) in self.fonts.iter().enumerate() {
|
||||
let mut info = match font.single_glyph_info(c) {
|
||||
Err(_) => continue,
|
||||
Ok(info) => info,
|
||||
};
|
||||
if info.glyph_pos == 0 {
|
||||
continue;
|
||||
}
|
||||
info.cluster = cluster as u32;
|
||||
info.font_idx = font_idx;
|
||||
return Ok(info);
|
||||
}
|
||||
if c == '?' {
|
||||
bail!("no glyph for ?");
|
||||
}
|
||||
match self.shape_codepoint('?', cluster) {
|
||||
Ok(info) => Ok(info),
|
||||
Err(_) => bail!("no glyph for {}, and no glyph for fallback ?", c),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NamedFont for NamedFontImpl {
|
||||
fn get_fallback(&mut self, idx: FallbackIdx) -> Result<&Font, Error> {
|
||||
self.fonts
|
||||
@ -98,14 +78,6 @@ impl NamedFont for NamedFontImpl {
|
||||
}
|
||||
|
||||
fn shape(&mut self, s: &str) -> Result<Vec<GlyphInfo>, Error> {
|
||||
let mut shaped = Vec::with_capacity(s.len());
|
||||
|
||||
let mut cluster = 0;
|
||||
for c in s.chars() {
|
||||
let info = self.shape_codepoint(c, cluster)?;
|
||||
cluster += c.len_utf8();
|
||||
shaped.push(info);
|
||||
}
|
||||
Ok(shaped)
|
||||
shape_with_harfbuzz(self, 0, s)
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,18 @@
|
||||
use crate::font::system::GlyphInfo;
|
||||
use super::hbwrap as harfbuzz;
|
||||
use crate::font::{ftwrap, Font, FontMetrics, RasterizedGlyph};
|
||||
use failure::Error;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::mem;
|
||||
use std::slice;
|
||||
|
||||
#[cfg(unix)]
|
||||
use super::hbwrap as harfbuzz;
|
||||
|
||||
/// Holds a loaded font alternative
|
||||
pub struct FreeTypeFontImpl {
|
||||
face: RefCell<ftwrap::Face>,
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
font: RefCell<harfbuzz::Font>,
|
||||
/// nominal monospace cell height
|
||||
cell_height: f64,
|
||||
/// nominal monospace cell width
|
||||
cell_width: f64,
|
||||
glyph_cache: RefCell<HashMap<char, GlyphInfo>>,
|
||||
}
|
||||
|
||||
impl FreeTypeFontImpl {
|
||||
@ -67,58 +61,23 @@ impl FreeTypeFontImpl {
|
||||
};
|
||||
|
||||
debug!("metrics: width={} height={}", cell_width, cell_height);
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
let font = harfbuzz::Font::new(face.face);
|
||||
|
||||
Ok(FreeTypeFontImpl {
|
||||
face: RefCell::new(face),
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
font: RefCell::new(font),
|
||||
cell_height,
|
||||
cell_width,
|
||||
glyph_cache: RefCell::new(HashMap::new()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn single_glyph_info(&self, codepoint: char) -> Result<GlyphInfo, Error> {
|
||||
// Memoize this, as we are called frequently during shaping
|
||||
{
|
||||
let cache = self.glyph_cache.borrow_mut();
|
||||
if let Some(info) = cache.get(&codepoint) {
|
||||
return Ok(info.clone());
|
||||
}
|
||||
}
|
||||
let (glyph_pos, metrics) = self.face.borrow_mut().load_codepoint(codepoint)?;
|
||||
let info = GlyphInfo {
|
||||
#[cfg(debug_assertions)]
|
||||
text: codepoint.to_string(),
|
||||
cluster: 0,
|
||||
num_cells: unicode_width::UnicodeWidthChar::width(codepoint).unwrap_or(1) as u8,
|
||||
font_idx: 0,
|
||||
glyph_pos,
|
||||
x_advance: (metrics.horiAdvance as f64 / 64.0),
|
||||
x_offset: 0.0, //(metrics.horiBearingX as f64 / 64.0).into(),
|
||||
y_advance: 0.0,
|
||||
y_offset: 0.0,
|
||||
};
|
||||
|
||||
self.glyph_cache
|
||||
.borrow_mut()
|
||||
.insert(codepoint, info.clone());
|
||||
|
||||
Ok(info)
|
||||
}
|
||||
}
|
||||
|
||||
impl Font for FreeTypeFontImpl {
|
||||
#[cfg(unix)]
|
||||
#[allow(unused_variables)]
|
||||
fn harfbuzz_shape(
|
||||
&self,
|
||||
buf: &mut harfbuzz::Buffer,
|
||||
features: Option<&[harfbuzz::hb_feature_t]>,
|
||||
) {
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
self.font.borrow_mut().shape(buf, features)
|
||||
}
|
||||
fn has_color(&self) -> bool {
|
||||
@ -152,7 +111,6 @@ impl Font for FreeTypeFontImpl {
|
||||
// assembles these bits.
|
||||
(render_mode as i32) << 16;
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
self.font.borrow_mut().set_load_flags(load_flags);
|
||||
|
||||
// This clone is conceptually unsafe, but ok in practice as we are
|
||||
|
@ -1,11 +1,15 @@
|
||||
//! Higher level freetype bindings
|
||||
|
||||
use failure::Error;
|
||||
pub use freetype::freetype::*;
|
||||
use freetype::succeeded;
|
||||
pub use freetype::*;
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
#[inline]
|
||||
pub fn succeeded(error: FT_Error) -> bool {
|
||||
error == freetype::FT_Err_Ok as FT_Error
|
||||
}
|
||||
|
||||
/// Translate an error and value into a result
|
||||
fn ft_result<T>(err: FT_Error, t: T) -> Result<T, Error> {
|
||||
if succeeded(err) {
|
||||
@ -61,26 +65,6 @@ impl Face {
|
||||
ft_result(unsafe { FT_Select_Size(self.face, idx as i32) }, ())
|
||||
}
|
||||
|
||||
pub fn load_codepoint(
|
||||
&mut self,
|
||||
codepoint: char,
|
||||
) -> Result<(FT_UInt, FT_Glyph_Metrics_), Error> {
|
||||
unsafe {
|
||||
let glyph_pos = FT_Get_Char_Index(self.face, FT_ULong::from(u32::from(codepoint)));
|
||||
let res = FT_Load_Glyph(self.face, glyph_pos, FT_LOAD_COLOR as i32);
|
||||
ensure!(
|
||||
succeeded(res),
|
||||
"load_codepoint {}: FreeType error {:?} 0x{:x}",
|
||||
codepoint,
|
||||
res,
|
||||
res
|
||||
);
|
||||
|
||||
let glyph = &(*(*self.face).glyph);
|
||||
Ok((glyph_pos, glyph.metrics))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_and_render_glyph(
|
||||
&mut self,
|
||||
glyph_index: FT_UInt,
|
||||
|
@ -2,18 +2,15 @@
|
||||
#![allow(dead_code)]
|
||||
#[cfg(target_os = "macos")]
|
||||
use core_text::font::{CTFont, CTFontRef};
|
||||
#[cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))]
|
||||
use freetype;
|
||||
|
||||
pub use self::harfbuzz::*;
|
||||
use harfbuzz_sys as harfbuzz;
|
||||
pub use harfbuzz::*;
|
||||
|
||||
use failure::Error;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
#[cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))]
|
||||
extern "C" {
|
||||
fn hb_ft_font_set_load_flags(font: *mut hb_font_t, load_flags: i32);
|
||||
}
|
||||
@ -92,7 +89,7 @@ impl Blob {
|
||||
hb_blob_create(
|
||||
data.as_ptr() as *const i8,
|
||||
data.len() as u32,
|
||||
HB_MEMORY_MODE_READONLY,
|
||||
hb_memory_mode_t::HB_MEMORY_MODE_READONLY,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
)
|
||||
@ -127,15 +124,14 @@ impl Face {
|
||||
}
|
||||
|
||||
impl Font {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
/// Create a harfbuzz face from a freetype font
|
||||
pub fn new(face: freetype::freetype::FT_Face) -> Font {
|
||||
pub fn new(face: freetype::FT_Face) -> Font {
|
||||
// hb_ft_font_create_referenced always returns a
|
||||
// pointer to something, or derefs a nullptr internally
|
||||
// if everything fails, so there's nothing for us to
|
||||
// test here.
|
||||
Font {
|
||||
font: unsafe { hb_ft_font_create_referenced(face) },
|
||||
font: unsafe { hb_ft_font_create_referenced(face as _) },
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
@ -163,8 +159,7 @@ impl Font {
|
||||
Ok(Self { font })
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn set_load_flags(&mut self, load_flags: freetype::freetype::FT_Int32) {
|
||||
pub fn set_load_flags(&mut self, load_flags: freetype::FT_Int32) {
|
||||
unsafe {
|
||||
hb_ft_font_set_load_flags(self.font, load_flags);
|
||||
}
|
||||
|
@ -16,16 +16,19 @@ pub use self::system::*;
|
||||
|
||||
pub mod ftwrap;
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
#[cfg(all(unix, any(feature = "force-fontconfig", not(target_os = "macos"))))]
|
||||
pub mod fcwrap;
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
#[cfg(all(unix, any(feature = "force-fontconfig", not(target_os = "macos"))))]
|
||||
pub mod fontconfigandfreetype;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod coretext;
|
||||
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
pub mod fontloader;
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
pub mod fontloader_and_freetype;
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
pub mod fontloader_and_rusttype;
|
||||
pub mod rtype;
|
||||
|
||||
@ -80,16 +83,25 @@ impl FontSystemSelection {
|
||||
fn new_font_system(self) -> Rc<FontSystem> {
|
||||
match self {
|
||||
FontSystemSelection::FontConfigAndFreeType => {
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
#[cfg(all(unix, any(feature = "force-fontconfig", not(target_os = "macos"))))]
|
||||
return Rc::new(fontconfigandfreetype::FontSystemImpl::new());
|
||||
#[cfg(not(all(unix, not(target_os = "macos"))))]
|
||||
#[cfg(not(all(
|
||||
unix,
|
||||
any(feature = "force-fontconfig", not(target_os = "macos"))
|
||||
)))]
|
||||
panic!("fontconfig not compiled in");
|
||||
}
|
||||
FontSystemSelection::FontLoaderAndFreeType => {
|
||||
Rc::new(fontloader_and_freetype::FontSystemImpl::new())
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
return Rc::new(fontloader_and_freetype::FontSystemImpl::new());
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
panic!("font-loader not compiled in");
|
||||
}
|
||||
FontSystemSelection::FontLoaderAndRustType => {
|
||||
Rc::new(fontloader_and_rusttype::FontSystemImpl::new())
|
||||
#[cfg(any(target_os = "macos", windows))]
|
||||
return Rc::new(fontloader_and_rusttype::FontSystemImpl::new());
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
panic!("font-loader not compiled in");
|
||||
}
|
||||
FontSystemSelection::CoreText => {
|
||||
#[cfg(target_os = "macos")]
|
||||
@ -258,8 +270,8 @@ pub fn shape_with_harfbuzz(
|
||||
];
|
||||
|
||||
let mut buf = harfbuzz::Buffer::new()?;
|
||||
buf.set_script(harfbuzz::HB_SCRIPT_LATIN);
|
||||
buf.set_direction(harfbuzz::HB_DIRECTION_LTR);
|
||||
buf.set_script(harfbuzz::hb_script_t::HB_SCRIPT_LATIN);
|
||||
buf.set_direction(harfbuzz::hb_direction_t::HB_DIRECTION_LTR);
|
||||
buf.set_language(harfbuzz::language_from_string("en")?);
|
||||
buf.add_str(s);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user