Skip to content
Permalink
Browse files

WR udpate: font

  • Loading branch information...
paulrouget committed Mar 7, 2019
1 parent 47b522f commit 395d611b1caf96ca4377aa1a16a230e31e3bdef7
@@ -6,6 +6,7 @@ use servo_atoms::Atom;
use std::fmt;
use std::fs::File;
use std::io::{Error, Read};
use std::path::PathBuf;
use webrender_api::NativeFontHandle;

/// Platform specific font representation for Linux.
@@ -61,7 +62,7 @@ impl FontTemplateData {
pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(NativeFontHandle {
pathname: String::from(&*self.identifier),
path: PathBuf::from(&*self.identifier),
index: 0,
})
} else {
@@ -280,7 +280,8 @@ impl FontHandleMethods for FontHandle {

let face = font_file
.unwrap()
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE);
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE)
.map_err(|_| ())?;
let info = FontInfo::new_from_face(&face)?;
(info, face)
} else {
@@ -64,11 +64,6 @@ where
}
}

pub fn descriptor_from_atom(ident: &Atom) -> FontDescriptor {
let fonts = FONT_ATOM_MAP.lock().unwrap();
fonts.get(ident).unwrap().clone()
}

pub fn font_from_atom(ident: &Atom) -> Font {
let fonts = FONT_ATOM_MAP.lock().unwrap();
FontCollection::system()
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::platform::windows::font_list::{descriptor_from_atom, font_from_atom};
use crate::platform::windows::font_list::font_from_atom;
use servo_atoms::Atom;
use std::fmt;
use std::io;
@@ -59,10 +59,16 @@ impl FontTemplateData {
}

pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(descriptor_from_atom(&self.identifier))
} else {
None
if self.bytes.is_some() {
return None;
}
let font = font_from_atom(&self.identifier);
let face = font.create_font_face();
let files = face.get_files();
let path = files.iter().next()?.get_font_file_path()?;
Some(NativeFontHandle {
path,
index: face.get_index(),
})
}
}

0 comments on commit 395d611

Please sign in to comment.
You can’t perform that action at this time.