Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
This bumps all dependencies other than freetype-rs to their latest major
versions.

The freetype-rs update is ignored for now since it would introduce build
issues on some platforms.
  • Loading branch information
chrisduerr authored Nov 2, 2024
1 parent 895ccc1 commit 9cd8ed0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 52 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The sections should follow the order `Added`, `Changed`, `Fixed`, and `Removed`.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- MSRV changed to 1.77.0
- **Breaking** yeslogic-fontconfig-sys bumped to 6.0.0

## 0.8.0

### Changed
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ readme = "README.md"
categories = ["gui", "os"]
keywords = ["font"]
edition = "2021"
rust-version = "1.65.0"
rust-version = "1.77.0"

[dependencies]
libc = "0.2"
foreign-types = "0.5"
log = "0.4"

[target.'cfg(not(any(target_os = "macos", windows)))'.dependencies]
yeslogic-fontconfig-sys = "5.0.0"
yeslogic-fontconfig-sys = "6.0.0"
freetype-rs = "0.36.0"

[target.'cfg(not(any(target_os = "macos", windows)))'.build-dependencies]
pkg-config = "0.3"

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.9.3"
core-text = "20.1.0"
core-graphics = "0.23.1"
core-foundation = "0.10.0"
core-text = "21.0.0"
core-graphics = "0.24.0"
core-foundation-sys = "0.8.4"
once_cell = "1.12"
objc2 = "0.5.1"
Expand Down
8 changes: 0 additions & 8 deletions build.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/directwrite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ impl DirectWriteRasterizer {

Ok(RasterizedGlyph {
character,
width: (bounds.right - bounds.left) as i32,
height: (bounds.bottom - bounds.top) as i32,
width: bounds.right - bounds.left,
height: bounds.bottom - bounds.top,
top: -bounds.top,
left: bounds.left,
advance: (0, 0),
Expand Down
35 changes: 7 additions & 28 deletions src/ft/fc/pattern.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ffi::{CStr, CString};
use std::fmt;
use std::mem;
use std::path::PathBuf;
use std::ptr::{self, NonNull};
use std::str;
Expand Down Expand Up @@ -45,11 +44,7 @@ impl<'a> StringPropertyIter<'a> {
};

if result == FcResultMatch {
// Transmute here is to extend lifetime of the str to that of the iterator.
//
// Potential unsafety? What happens if the pattern is modified while this ptr is
// borrowed out?
unsafe { mem::transmute(CStr::from_ptr(value as *const c_char).to_str().ok()?) }
unsafe { CStr::from_ptr(value as *const c_char).to_str().ok() }
} else {
None
}
Expand All @@ -63,7 +58,7 @@ pub struct BooleanPropertyIter<'a> {
index: usize,
}

impl<'a> BooleanPropertyIter<'a> {
impl BooleanPropertyIter<'_> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> BooleanPropertyIter<'b> {
BooleanPropertyIter { pattern, object, index: 0 }
}
Expand Down Expand Up @@ -95,7 +90,7 @@ pub struct IntPropertyIter<'a> {
index: usize,
}

impl<'a> IntPropertyIter<'a> {
impl IntPropertyIter<'_> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> IntPropertyIter<'b> {
IntPropertyIter { pattern, object, index: 0 }
}
Expand Down Expand Up @@ -200,7 +195,7 @@ pub struct DoublePropertyIter<'a> {
index: usize,
}

impl<'a> DoublePropertyIter<'a> {
impl DoublePropertyIter<'_> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> DoublePropertyIter<'b> {
DoublePropertyIter { pattern, object, index: 0 }
}
Expand Down Expand Up @@ -552,26 +547,15 @@ impl PatternRef {
/// retained. That is, the CharSet can be safely dropped immediately
/// after being added to the pattern.
pub fn add_charset(&self, charset: &CharSetRef) -> bool {
unsafe {
FcPatternAddCharSet(
self.as_ptr(),
b"charset\0".as_ptr() as *mut c_char,
charset.as_ptr(),
) == 1
}
unsafe { FcPatternAddCharSet(self.as_ptr(), c"charset".as_ptr(), charset.as_ptr()) == 1 }
}

/// Get charset from the pattern.
pub fn get_charset(&self) -> Option<&CharSetRef> {
unsafe {
let mut charset = ptr::null_mut();

let result = FcPatternGetCharSet(
self.as_ptr(),
b"charset\0".as_ptr() as *mut c_char,
0,
&mut charset,
);
let result = FcPatternGetCharSet(self.as_ptr(), c"charset".as_ptr(), 0, &mut charset);

if result == FcResultMatch {
Some(&*(charset as *const CharSetRef))
Expand All @@ -585,12 +569,7 @@ impl PatternRef {
pub fn get_matrix(&self) -> Option<FcMatrix> {
unsafe {
let mut matrix = ptr::null_mut();
let result = FcPatternGetMatrix(
self.as_ptr(),
b"matrix\0".as_ptr() as *mut c_char,
0,
&mut matrix,
);
let result = FcPatternGetMatrix(self.as_ptr(), c"matrix".as_ptr(), 0, &mut matrix);

if result == FcResultMatch {
Some(*matrix)
Expand Down
13 changes: 4 additions & 9 deletions src/ft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,22 +663,17 @@ impl FreeTypeLoader {
fn new() -> Result<FreeTypeLoader, Error> {
let library = Library::init()?;

#[cfg(ft_set_default_properties_available)]
unsafe {
// Initialize default properties, like user preferred interpreter.
freetype_sys::FT_Set_Default_Properties(library.raw());
};
// Initialize default properties, like user preferred interpreter.
unsafe { freetype_sys::FT_Set_Default_Properties(library.raw()) };

Ok(FreeTypeLoader { library, faces: HashMap::new(), ft_faces: HashMap::new() })
}

fn load_ft_face(&mut self, ft_face_location: FtFaceLocation) -> Result<Rc<FtFace>, Error> {
let mut ft_face = self.library.new_face(&ft_face_location.path, ft_face_location.index)?;
if ft_face.has_color() && !ft_face.is_scalable() {
unsafe {
// Select the colored bitmap size to use from the array of available sizes.
freetype_sys::FT_Select_Size(ft_face.raw_mut(), 0);
}
// Select the colored bitmap size to use from the array of available sizes.
unsafe { freetype_sys::FT_Select_Size(ft_face.raw_mut(), 0) };
}

let ft_face = Rc::new(ft_face);
Expand Down

0 comments on commit 9cd8ed0

Please sign in to comment.