mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make font-variant shorthand.
This commit is contained in:
parent
24919b3cf8
commit
6ae5af17ce
4 changed files with 16 additions and 14 deletions
|
@ -18,7 +18,7 @@ use std::rc::Rc;
|
|||
use std::str;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
||||
use style::computed_values::{font_stretch, font_variant, font_weight};
|
||||
use style::computed_values::{font_stretch, font_variant_caps, font_weight};
|
||||
use text::Shaper;
|
||||
use text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
||||
use text::shaping::ShaperMethods;
|
||||
|
@ -105,7 +105,7 @@ pub struct FontMetrics {
|
|||
pub struct Font {
|
||||
pub handle: FontHandle,
|
||||
pub metrics: FontMetrics,
|
||||
pub variant: font_variant::T,
|
||||
pub variant: font_variant_caps::T,
|
||||
pub descriptor: FontTemplateDescriptor,
|
||||
pub requested_pt_size: Au,
|
||||
pub actual_pt_size: Au,
|
||||
|
@ -117,7 +117,7 @@ pub struct Font {
|
|||
|
||||
impl Font {
|
||||
pub fn new(handle: FontHandle,
|
||||
variant: font_variant::T,
|
||||
variant: font_variant_caps::T,
|
||||
descriptor: FontTemplateDescriptor,
|
||||
requested_pt_size: Au,
|
||||
actual_pt_size: Au,
|
||||
|
@ -262,8 +262,8 @@ impl Font {
|
|||
#[inline]
|
||||
pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
let codepoint = match self.variant {
|
||||
font_variant::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938
|
||||
font_variant::T::normal => codepoint,
|
||||
font_variant_caps::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938
|
||||
font_variant_caps::T::normal => codepoint,
|
||||
};
|
||||
self.handle.glyph_index(codepoint)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
|
|||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||
use style::computed_values::{font_style, font_variant};
|
||||
use style::computed_values::{font_style, font_variant_caps};
|
||||
use style::properties::style_structs;
|
||||
use webrender_traits;
|
||||
|
||||
|
@ -77,14 +77,14 @@ impl FontContext {
|
|||
template: Arc<FontTemplateData>,
|
||||
descriptor: FontTemplateDescriptor,
|
||||
pt_size: Au,
|
||||
variant: font_variant::T,
|
||||
variant: font_variant_caps::T,
|
||||
font_key: webrender_traits::FontKey) -> Result<Font, ()> {
|
||||
// TODO: (Bug #3463): Currently we only support fake small-caps
|
||||
// painting. We should also support true small-caps (where the
|
||||
// font supports it) in the future.
|
||||
let actual_pt_size = match variant {
|
||||
font_variant::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR),
|
||||
font_variant::T::normal => pt_size,
|
||||
font_variant_caps::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR),
|
||||
font_variant_caps::T::normal => pt_size,
|
||||
};
|
||||
|
||||
let handle = try!(FontHandle::new_from_template(&self.platform_handle,
|
||||
|
@ -146,7 +146,7 @@ impl FontContext {
|
|||
let cached_font = (*cached_font_ref).borrow();
|
||||
if cached_font.descriptor == desc &&
|
||||
cached_font.requested_pt_size == style.font_size &&
|
||||
cached_font.variant == style.font_variant {
|
||||
cached_font.variant == style.font_variant_caps {
|
||||
fonts.push((*cached_font_ref).clone());
|
||||
cache_hit = true;
|
||||
break;
|
||||
|
@ -164,7 +164,7 @@ impl FontContext {
|
|||
let layout_font = self.create_layout_font(template_info.font_template,
|
||||
desc.clone(),
|
||||
style.font_size,
|
||||
style.font_variant,
|
||||
style.font_variant_caps,
|
||||
template_info.font_key
|
||||
.expect("No font key present!"));
|
||||
let font = match layout_font {
|
||||
|
@ -198,7 +198,7 @@ impl FontContext {
|
|||
let cached_font = cached_font_entry.font.borrow();
|
||||
if cached_font.descriptor == desc &&
|
||||
cached_font.requested_pt_size == style.font_size &&
|
||||
cached_font.variant == style.font_variant {
|
||||
cached_font.variant == style.font_variant_caps {
|
||||
fonts.push(cached_font_entry.font.clone());
|
||||
cache_hit = true;
|
||||
break;
|
||||
|
@ -210,7 +210,7 @@ impl FontContext {
|
|||
let layout_font = self.create_layout_font(template_info.font_template,
|
||||
desc.clone(),
|
||||
style.font_size,
|
||||
style.font_variant,
|
||||
style.font_variant_caps,
|
||||
template_info.font_key.expect("No font key present!"));
|
||||
match layout_font {
|
||||
Ok(layout_font) => {
|
||||
|
|
|
@ -281,6 +281,8 @@ partial interface CSSStyleDeclaration {
|
|||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-style;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontVariant;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-variant;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontVariantCaps;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-variant-caps;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontWeight;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-weight;
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
|
|||
get_inheritedtext.text_transform, get_inheritedtext.word_spacing,
|
||||
get_inheritedtext.overflow_wrap, get_inheritedtext.text_justify,
|
||||
get_inheritedtext.white_space, get_inheritedtext.word_break, get_text.text_overflow,
|
||||
get_font.font_family, get_font.font_style, get_font.font_variant, get_font.font_weight,
|
||||
get_font.font_family, get_font.font_style, get_font.font_variant_caps, get_font.font_weight,
|
||||
get_font.font_size, get_font.font_stretch,
|
||||
get_inheritedbox.direction, get_inheritedbox.writing_mode,
|
||||
get_text.text_decoration_line, get_text.unicode_bidi,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue