Add add_native_font function to get feature parity on Windows + publicly export necessary types
This commit is contained in:
parent
ddcde6d1ae
commit
80a872ca46
|
@ -22,6 +22,7 @@ use std::iter::Cloned;
|
|||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
use std::ptr;
|
||||
use std::collections::btree_map::Entry;
|
||||
use std::slice::{self, Iter};
|
||||
use std::sync::Arc;
|
||||
use uuid::IID_ID2D1SimplifiedGeometrySink;
|
||||
|
@ -36,7 +37,8 @@ use winapi::{IDWriteFontFileLoader, IDWriteFontFileLoaderVtbl, IDWriteFontFileSt
|
|||
use winapi::{IDWriteFontFileStreamVtbl, IDWriteGeometrySink, IUnknown, IUnknownVtbl, TRUE, UINT16};
|
||||
use winapi::{UINT32, UINT64, UINT};
|
||||
|
||||
use self::com::{PathfinderCoclass, PathfinderComObject, PathfinderComPtr};
|
||||
use self::com::{PathfinderCoclass, PathfinderComObject};
|
||||
pub use self::com::{PathfinderComPtr};
|
||||
use {FontInstance, GlyphDimensions, GlyphImage, GlyphKey};
|
||||
|
||||
mod com;
|
||||
|
@ -178,6 +180,19 @@ impl<FK> FontContext<FK> where FK: Clone + Hash + Eq + Ord {
|
|||
}
|
||||
}
|
||||
|
||||
/// Loads an OpenType font from a COM `IDWriteFontFace` handle.
|
||||
pub fn add_native_font<H>(&mut self, font_key: &FK, handle: H) -> Result<(), ()>
|
||||
where H: Into<PathfinderComPtr<IDWriteFontFace>>
|
||||
{
|
||||
match self.dwrite_font_faces.entry((*font_key).clone()) {
|
||||
Entry::Occupied(_) => Ok(()),
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(handle.into());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Unloads the font with the given font key from memory.
|
||||
///
|
||||
/// If the font isn't loaded, does nothing.
|
||||
|
|
|
@ -53,6 +53,11 @@ extern crate uuid;
|
|||
#[macro_use(DEFINE_GUID)]
|
||||
extern crate winapi;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use self::directwrite::PathfinderComPtr;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use winapi::IDWriteFontFace;
|
||||
|
||||
use app_units::Au;
|
||||
use euclid::{Point2D, Size2D};
|
||||
|
||||
|
|
Loading…
Reference in New Issue