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

Port the Pathfinder branch to Linux (FreeType). #2636

Merged
merged 1 commit into from Apr 10, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Port the Pathfinder branch to Linux (FreeType).

Closes #2617.
  • Loading branch information
pcwalton committed Apr 9, 2018
commit 7a73f61d858e6b95d8dbfd15edcaa5cb958e3e00

Some generated files are not rendered by default. Learn more.

@@ -8,6 +8,8 @@ use api::{ColorF, ColorU};
use api::{FontInstanceFlags, FontInstancePlatformOptions};
use api::{FontKey, FontRenderMode, FontTemplate, FontVariation};
use api::{GlyphDimensions, GlyphKey, LayerToWorldTransform, SubpixelDirection};
#[cfg(feature = "pathfinder")]
use api::NativeFontHandle;
#[cfg(any(test, feature = "pathfinder"))]
use api::DeviceIntSize;
#[cfg(not(feature = "pathfinder"))]
@@ -128,12 +130,12 @@ impl FontTransform {
)
}

#[cfg(not(feature = "pathfinder"))]
#[allow(dead_code)]
pub fn determinant(&self) -> f64 {
self.scale_x as f64 * self.scale_y as f64 - self.skew_y as f64 * self.skew_x as f64
}

#[cfg(not(feature = "pathfinder"))]
#[allow(dead_code)]
pub fn compute_scale(&self) -> Option<(f64, f64)> {
let det = self.determinant();
if det != 0.0 {
@@ -145,7 +147,7 @@ impl FontTransform {
}
}

#[cfg(not(feature = "pathfinder"))]
#[allow(dead_code)]
pub fn pre_scale(&self, scale_x: f32, scale_y: f32) -> Self {
FontTransform::new(
self.scale_x * scale_x,
@@ -155,7 +157,7 @@ impl FontTransform {
)
}

#[cfg(not(feature = "pathfinder"))]
#[allow(dead_code)]
pub fn invert_scale(&self, x_scale: f64, y_scale: f64) -> Self {
self.pre_scale(x_scale.recip() as f32, y_scale.recip() as f32)
}
@@ -453,6 +455,7 @@ impl GlyphRasterizer {
#[cfg(feature = "pathfinder")]
fn add_font_to_pathfinder(&mut self, font_key: &FontKey, template: &FontTemplate) {
let font_contexts = Arc::clone(&self.font_contexts);
eprintln!("add_font_to_pathfinder({:?})", font_key);
font_contexts.lock_pathfinder_context().add_font(&font_key, &template);
}

@@ -861,10 +864,10 @@ impl AddFont for PathfinderFontContext {
fn add_font(&mut self, font_key: &FontKey, template: &FontTemplate) {
match *template {
FontTemplate::Raw(ref bytes, index) => {
drop(self.add_font_from_memory(font_key, bytes.clone(), index));
drop(self.add_font_from_memory(&font_key, bytes.clone(), index))
}
FontTemplate::Native(ref native_font_handle) => {
drop(self.add_native_font(font_key, (*native_font_handle).clone().0));
drop(self.add_native_font(&font_key, NativeFontHandleWrapper(native_font_handle)))
}
}
}
@@ -1067,3 +1070,6 @@ fn request_render_task_from_pathfinder(glyph_key: &GlyphKey,

Ok((root_task_id, false))
}

#[cfg(feature = "pathfinder")]
pub struct NativeFontHandleWrapper<'a>(pub &'a NativeFontHandle);
@@ -28,6 +28,8 @@ use core_text::font::{CTFont, CTFontRef};
use core_text::font_descriptor::{kCTFontDefaultOrientation, kCTFontColorGlyphsTrait};
use gamma_lut::{ColorLut, GammaLut};
use glyph_rasterizer::{FontInstance, FontTransform};
#[cfg(feature = "pathfinder")]
use glyph_rasterizer::NativeFontHandleWrapper;
#[cfg(not(feature = "pathfinder"))]
use glyph_rasterizer::{GlyphFormat, GlyphRasterResult, RasterizedGlyph};
use internal_types::{FastHashMap, ResourceCacheError};
@@ -729,3 +731,10 @@ impl FontContext {
})
}
}

#[cfg(feature = "pathfinder")]
impl<'a> Into<CGFont> for NativeFontHandleWrapper<'a> {
fn into(self) -> CGFont {
(self.0).0.clone()
}
}
@@ -19,7 +19,11 @@ use freetype::freetype::{FT_LOAD_NO_BITMAP, FT_LOAD_NO_HINTING, FT_LOAD_VERTICAL
use freetype::freetype::{FT_FACE_FLAG_SCALABLE, FT_FACE_FLAG_FIXED_SIZES};
use freetype::succeeded;
use glyph_rasterizer::{FontInstance, GlyphFormat, GlyphRasterResult, RasterizedGlyph};
#[cfg(feature = "pathfinder")]
use glyph_rasterizer::NativeFontHandleWrapper;
use internal_types::{FastHashMap, ResourceCacheError};
#[cfg(feature = "pathfinder")]
use pathfinder_font_renderer::freetype as pf_freetype;
use std::{cmp, mem, ptr, slice};
use std::cmp::max;
use std::ffi::CString;
@@ -788,3 +792,11 @@ impl Drop for FontContext {
}
}
}

#[cfg(feature = "pathfinder")]
impl<'a> Into<pf_freetype::FontDescriptor> for NativeFontHandleWrapper<'a> {
fn into(self) -> pf_freetype::FontDescriptor {
let NativeFontHandleWrapper(font_handle) = self;
pf_freetype::FontDescriptor::new(font_handle.pathname.clone().into(), font_handle.index)
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.