Native MSVC windows build, convert to cmake

This commit is contained in:
Vladimir Vukicevic 2016-08-01 02:32:27 -04:00
parent fc7053e030
commit 5bbec7469d
17 changed files with 394 additions and 73 deletions

View file

@ -57,7 +57,7 @@ core-foundation = "0.2"
core-graphics = "0.4"
core-text = "2.0"
[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))'.dependencies]
freetype = {git = "https://github.com/servo/rust-freetype"}
servo-fontconfig = "0.2.1"

View file

@ -37,9 +37,9 @@ extern crate euclid;
extern crate fnv;
// Platforms that use Freetype/Fontconfig library dependencies
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
extern crate fontconfig;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
extern crate freetype;
extern crate gfx_traits;

View file

@ -0,0 +1,80 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
use font::{FontHandleMethods, FontMetrics, FontTableMethods};
use font::{FontTableTag, FractionalPixel};
use platform::font_context::FontContextHandle;
use platform::font_template::FontTemplateData;
use std::sync::Arc;
use style::computed_values::{font_stretch, font_weight};
use text::glyph::GlyphId;
#[derive(Debug)]
pub struct FontTable {
buffer: Vec<u8>,
}
impl FontTableMethods for FontTable {
fn buffer(&self) -> &[u8] {
&self.buffer
}
}
#[derive(Debug)]
pub struct FontHandle {
handle: FontContextHandle,
}
impl Drop for FontHandle {
fn drop(&mut self) {
}
}
impl FontHandleMethods for FontHandle {
fn new_from_template(fctx: &FontContextHandle,
template: Arc<FontTemplateData>,
pt_size: Option<Au>)
-> Result<FontHandle, ()> {
Err(())
}
fn template(&self) -> Arc<FontTemplateData> {
unimplemented!()
}
fn family_name(&self) -> String {
String::from("Unknown")
}
fn face_name(&self) -> String {
String::from("Unknown")
}
fn is_italic(&self) -> bool {
false
}
fn boldness(&self) -> font_weight::T {
font_weight::T::Weight400
}
fn stretchiness(&self) -> font_stretch::T {
font_stretch::T::normal
}
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
None
}
fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId)
-> FractionalPixel {
0.0
}
fn can_do_fast_shaping(&self) -> bool {
false
}
fn glyph_h_advance(&self, glyph: GlyphId) -> Option<FractionalPixel> {
None
}
fn metrics(&self) -> FontMetrics {
unimplemented!()
}
fn table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
None
}
}

View file

@ -0,0 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[derive(Clone, HeapSizeOf, Debug)]
pub struct FontContextHandle;
impl FontContextHandle {
pub fn new() -> FontContextHandle {
FontContextHandle
}
}

View file

@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pub fn for_each_available_family<F>(mut callback: F) where F: FnMut(String)
{
}
pub fn for_each_variation<F>(family_name: &str, mut callback: F)
where F: FnMut(String)
{
}
pub fn system_default_family(generic_name: &str) -> Option<String> {
None
}
pub fn last_resort_font_families() -> Vec<String> {
vec!(
"Unknown".to_owned()
)
}
pub static SANS_SERIF_FONT_FAMILY: &'static str = "Unknown";

View file

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use string_cache::Atom;
use webrender_traits::NativeFontHandle;
#[derive(Deserialize, Serialize, Debug)]
pub struct FontTemplateData {
pub bytes: Vec<u8>,
pub identifier: Atom,
}
impl FontTemplateData {
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
let bytes = match font_data {
Some(bytes) => {
bytes
},
None => {
unimplemented!()
}
};
FontTemplateData {
bytes: bytes,
identifier: identifier,
}
}
pub fn bytes(&self) -> Vec<u8> {
self.bytes.clone()
}
pub fn bytes_if_in_memory(&self) -> Option<Vec<u8>> {
Some(self.bytes())
}
pub fn native_font(&self) -> Option<NativeFontHandle> {
None
}
}

View file

@ -2,13 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
pub use platform::freetype::{font, font_context, font_list, font_template};
#[cfg(target_os = "macos")]
pub use platform::macos::{font, font_context, font_list, font_template};
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
#[cfg(all(target_os = "windows", target_env = "msvc"))]
pub use platform::dummy::{font, font_context, font_list, font_template};
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
mod freetype {
use libc::c_char;
use std::ffi::CStr;
@ -33,3 +36,11 @@ mod macos {
pub mod font_list;
pub mod font_template;
}
#[cfg(all(target_os = "windows", target_env = "msvc"))]
mod dummy {
pub mod font;
pub mod font_context;
pub mod font_list;
pub mod font_template;
}