Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yeslogic-fontconfig-sys instead of servo #65

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

- **Breaking** fontconfig system library provider changed to yeslogic-fontcontconfig-sys
- **Breaking** freetype-rs bumped to 0.36.0
chrisduerr marked this conversation as resolved.
Show resolved Hide resolved

## 0.7.0

### Changed
Expand Down
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ foreign-types = "0.5"
log = "0.4"

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

[target.'cfg(not(any(target_os = "macos", windows)))'.build-dependencies]
pkg-config = "0.3"
Expand All @@ -36,6 +36,3 @@ once_cell = "1.12"
[target.'cfg(windows)'.dependencies]
dwrote = { version = "0.11" }
winapi = { version = "0.3", features = ["impl-default"] }

[features]
force_system_fontconfig = ["servo-fontconfig/force_system_lib"]
10 changes: 5 additions & 5 deletions src/ft/fc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use std::ptr;

use foreign_types::{ForeignType, ForeignTypeRef};

use fontconfig::fontconfig as ffi;
use fontconfig_sys as ffi;

use ffi::constants::{FC_SLANT_ITALIC, FC_SLANT_OBLIQUE, FC_SLANT_ROMAN};
use ffi::constants::{FC_WEIGHT_BLACK, FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABLACK, FC_WEIGHT_EXTRABOLD};
use ffi::constants::{FC_WEIGHT_BOOK, FC_WEIGHT_MEDIUM, FC_WEIGHT_REGULAR, FC_WEIGHT_SEMIBOLD};
use ffi::constants::{FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT, FC_WEIGHT_THIN};
use ffi::FcInitBringUptoDate;
use ffi::FcResultNoMatch;
use ffi::{FcFontList, FcFontMatch, FcFontSort};
use ffi::{FcMatchFont, FcMatchPattern, FcMatchScan};
use ffi::{FcSetApplication, FcSetSystem};
use ffi::{FC_SLANT_ITALIC, FC_SLANT_OBLIQUE, FC_SLANT_ROMAN};
use ffi::{FC_WEIGHT_BLACK, FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABLACK, FC_WEIGHT_EXTRABOLD};
use ffi::{FC_WEIGHT_BOOK, FC_WEIGHT_MEDIUM, FC_WEIGHT_REGULAR, FC_WEIGHT_SEMIBOLD};
use ffi::{FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT, FC_WEIGHT_THIN};

pub mod config;
pub use config::{Config, ConfigRef};
Expand Down
15 changes: 6 additions & 9 deletions src/ft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl fmt::Debug for FaceLoadingProperties {
freetype::RenderMode::Lcd => "Lcd",
freetype::RenderMode::LcdV => "LcdV",
freetype::RenderMode::Max => "Max",
freetype::RenderMode::Sdf => "Sdf",
})
.field("lcd_filter", &self.lcd_filter)
.finish()
Expand Down Expand Up @@ -201,7 +202,7 @@ impl Rasterize for FreeTypeRasterizer {
fn get_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> {
let font_key = self.face_for_glyph(glyph_key);
let face = &self.loader.faces[&font_key];
let index = face.ft_face.get_char_index(glyph_key.character as usize);
let index = face.ft_face.get_char_index(glyph_key.character as usize).unwrap_or_default();
let pixelsize = face.non_scalable.unwrap_or_else(|| glyph_key.size.as_px());

if !face.colored_bitmap {
Expand Down Expand Up @@ -292,8 +293,8 @@ impl Rasterize for FreeTypeRasterizer {
return (0., 0.);
}

let left = ft_face.get_char_index(left.character as usize);
let right = ft_face.get_char_index(right.character as usize);
let left = ft_face.get_char_index(left.character as usize).unwrap_or_default();
let right = ft_face.get_char_index(right.character as usize).unwrap_or_default();

let mut kerning = freetype_sys::FT_Vector::default();
let mode = freetype_sys::FT_KERNING_DEFAULT;
Expand Down Expand Up @@ -423,9 +424,7 @@ impl FreeTypeRasterizer {

fn face_for_glyph(&mut self, glyph_key: GlyphKey) -> FontKey {
if let Some(face) = self.loader.faces.get(&glyph_key.font_key) {
let index = face.ft_face.get_char_index(glyph_key.character as usize);

if index != 0 {
if face.ft_face.get_char_index(glyph_key.character as usize).is_some() {
return glyph_key.font_key;
}
}
Expand All @@ -446,10 +445,8 @@ impl FreeTypeRasterizer {
let font_pattern = &fallback_font.pattern;
match self.loader.faces.get(&font_key) {
Some(face) => {
let index = face.ft_face.get_char_index(glyph.character as usize);

// We found something in a current face, so let's use it.
if index != 0 {
if face.ft_face.get_char_index(glyph.character as usize).is_some() {
return Ok(font_key);
}
},
Expand Down
Loading