mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
gfx: Fix Cocoa rendering by removing commented-out font loading code.
This commit is contained in:
parent
37488ce044
commit
36da30cc85
3 changed files with 30 additions and 42 deletions
|
@ -355,13 +355,11 @@ pub impl Font {
|
|||
range: &const Range,
|
||||
baseline_origin: Point2D<Au>,
|
||||
color: Color) {
|
||||
use libc::types::common::c99::{uint16_t, uint32_t};
|
||||
use azure::{AzDrawOptions,
|
||||
AzGlyph,
|
||||
AzGlyphBuffer};
|
||||
use azure::azure::bindgen::{AzCreateColorPattern,
|
||||
AzDrawTargetFillGlyphs,
|
||||
AzReleaseColorPattern};
|
||||
use core::libc::types::common::c99::{uint16_t, uint32_t};
|
||||
use azure::{AzDrawOptions, AzGlyph, AzGlyphBuffer};
|
||||
use azure::azure::bindgen::{AzCreateColorPattern};
|
||||
use azure::azure::bindgen::{AzDrawTargetFillGlyphs};
|
||||
use azure::azure::bindgen::{AzReleaseColorPattern};
|
||||
|
||||
let target = rctx.get_draw_target();
|
||||
let azfontref = self.get_azure_font();
|
||||
|
|
|
@ -1,52 +1,38 @@
|
|||
/// Implementation of Quartz (CoreGraphics) fonts.
|
||||
|
||||
extern mod core_foundation;
|
||||
extern mod core_graphics;
|
||||
extern mod core_text;
|
||||
|
||||
use quartz;
|
||||
use geometry::Au;
|
||||
use gfx_font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTable, FontTableMethods};
|
||||
use gfx_font::{FontTableTag, FontWeight100, FontWeight200, FontWeight300, FontWeight400};
|
||||
use gfx_font::{FontWeight500, FontWeight600, FontWeight700, FontWeight800, FontWeight900};
|
||||
use gfx_font::{FractionalPixel, SpecifiedFontStyle};
|
||||
use quartz::font::core_foundation::base::{CFIndex, CFTypeRef, CFWrapper};
|
||||
use quartz::font::core_foundation::data::{CFData, CFDataRef};
|
||||
use quartz::font::core_foundation::string::UniChar;
|
||||
|
||||
use quartz::font::core_graphics::base::{CGFloat, CGAffineTransform};
|
||||
use quartz::font::core_graphics::data_provider::{CGDataProviderRef, CGDataProvider};
|
||||
use quartz::font::core_graphics::font::{CGFont, CGFontRef, CGGlyph};
|
||||
use quartz::font::core_graphics::geometry::CGRect;
|
||||
|
||||
use quartz::font::core_text::font::CTFont;
|
||||
use quartz::font::core_text::font_descriptor::{kCTFontDefaultOrientation, CTFontSymbolicTraits};
|
||||
use quartz::font::core_text::font_descriptor::{SymbolicTraitAccessors};
|
||||
|
||||
use quartz::font::core_text::font_descriptor::{kCTFontDefaultOrientation, CTFontSymbolicTraits};
|
||||
use quartz::font_context::QuartzFontContextHandle;
|
||||
use geometry::Au;
|
||||
use gfx_font::{
|
||||
CSSFontWeight,
|
||||
FontHandleMethods,
|
||||
FontMetrics,
|
||||
FontTable,
|
||||
FontTableMethods,
|
||||
FontTableTag,
|
||||
FontWeight100,
|
||||
FontWeight200,
|
||||
FontWeight300,
|
||||
FontWeight400,
|
||||
FontWeight500,
|
||||
FontWeight600,
|
||||
FontWeight700,
|
||||
FontWeight800,
|
||||
FontWeight900,
|
||||
FractionalPixel,
|
||||
SpecifiedFontStyle,
|
||||
};
|
||||
use quartz;
|
||||
use text::glyph::GlyphIndex;
|
||||
|
||||
use core::libc::size_t;
|
||||
|
||||
struct QuartzFontTable {
|
||||
data: CFData,
|
||||
|
||||
drop { }
|
||||
}
|
||||
|
||||
|
||||
// Noncopyable.
|
||||
impl Drop for QuartzFontTable { fn finalize(&self) {} }
|
||||
|
||||
pub impl QuartzFontTable {
|
||||
static fn wrap(data: CFData) -> QuartzFontTable {
|
||||
QuartzFontTable { data: data }
|
||||
|
@ -105,7 +91,7 @@ pub impl QuartzFontHandle {
|
|||
}
|
||||
}
|
||||
|
||||
pub impl FontHandleMethods for QuartzFontHandle {
|
||||
impl FontHandleMethods for QuartzFontHandle {
|
||||
pure fn family_name() -> ~str {
|
||||
self.ctfont.family_name()
|
||||
}
|
||||
|
@ -131,10 +117,12 @@ pub impl FontHandleMethods for QuartzFontHandle {
|
|||
if normalized < 6.0 { return FontWeight600; }
|
||||
if normalized < 7.0 { return FontWeight700; }
|
||||
if normalized < 8.0 { return FontWeight800; }
|
||||
else { return FontWeight900; }
|
||||
return FontWeight900;
|
||||
}
|
||||
|
||||
fn clone_with_style(fctx: &QuartzFontContextHandle, style: &SpecifiedFontStyle) -> Result<QuartzFontHandle,()> {
|
||||
fn clone_with_style(fctx: &QuartzFontContextHandle,
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<QuartzFontHandle,()> {
|
||||
let new_font = self.ctfont.clone_with_font_size(style.pt_size);
|
||||
return QuartzFontHandle::new_from_CTFont(fctx, new_font);
|
||||
}
|
||||
|
@ -161,7 +149,7 @@ pub impl FontHandleMethods for QuartzFontHandle {
|
|||
let glyphs = [glyph as CGGlyph];
|
||||
unsafe {
|
||||
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
|
||||
ptr::to_unsafe_ptr(&glyphs[0]),
|
||||
&glyphs[0],
|
||||
ptr::null(),
|
||||
1);
|
||||
return Some(advance as FractionalPixel);
|
||||
|
@ -175,7 +163,9 @@ pub impl FontHandleMethods for QuartzFontHandle {
|
|||
|
||||
let metrics = FontMetrics {
|
||||
underline_size: Au::from_pt(self.ctfont.underline_thickness() as float),
|
||||
// TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table directly.
|
||||
// TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table
|
||||
// directly.
|
||||
//
|
||||
// see also: https://bugs.webkit.org/show_bug.cgi?id=16768
|
||||
// see also: https://bugreports.qt-project.org/browse/QTBUG-13364
|
||||
underline_offset: Au::from_pt(self.ctfont.underline_position() as float),
|
||||
|
|
|
@ -34,12 +34,12 @@ pub impl QuartzFontListHandle {
|
|||
let family_names: CFArray<CFStringRef> =
|
||||
quartz::font_list::core_text::font_collection::get_family_names();
|
||||
let mut family_map : FontFamilyMap = LinearMap::new();
|
||||
for family_names.each |strref: &CFStringRef| {
|
||||
/*let family_name = CFWrapper::wrap_shared(strref).to_str();
|
||||
for family_names.each |&strref: &CFStringRef| {
|
||||
let family_name = CFString::wrap_extern(strref).to_str();
|
||||
debug!("Creating new FontFamily for family: %s", family_name);
|
||||
|
||||
let new_family = @FontFamily::new(family_name);
|
||||
family_map.insert(family_name, new_family);*/
|
||||
family_map.insert(family_name, new_family);
|
||||
}
|
||||
return family_map;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue