Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into check-test-binary-ci
- Loading branch information
Showing
16 changed files
with
1,030 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/next-swc/crates/next-core/src/next_font/local/font_fallback.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use anyhow::Result; | ||
use turbo_tasks::primitives::{StringVc, StringsVc, U32Vc}; | ||
|
||
use super::{options::NextFontLocalOptionsVc, request::AdjustFontFallback}; | ||
use crate::next_font::{ | ||
font_fallback::{AutomaticFontFallback, FontFallback, FontFallbacksVc}, | ||
util::{get_scoped_font_family, FontFamilyType}, | ||
}; | ||
|
||
#[turbo_tasks::function] | ||
pub(super) async fn get_font_fallbacks( | ||
options_vc: NextFontLocalOptionsVc, | ||
request_hash: U32Vc, | ||
) -> Result<FontFallbacksVc> { | ||
let options = &*options_vc.await?; | ||
let mut font_fallbacks = vec![]; | ||
let scoped_font_family = get_scoped_font_family( | ||
FontFamilyType::Fallback.cell(), | ||
options_vc.font_family(), | ||
request_hash, | ||
); | ||
|
||
match options.adjust_font_fallback { | ||
AdjustFontFallback::Arial => font_fallbacks.push( | ||
FontFallback::Automatic( | ||
AutomaticFontFallback { | ||
scoped_font_family, | ||
local_font_family: StringVc::cell("Arial".to_owned()), | ||
adjustment: None, | ||
} | ||
.cell(), | ||
) | ||
.into(), | ||
), | ||
AdjustFontFallback::TimesNewRoman => font_fallbacks.push( | ||
FontFallback::Automatic( | ||
AutomaticFontFallback { | ||
scoped_font_family, | ||
local_font_family: StringVc::cell("Times New Roman".to_owned()), | ||
adjustment: None, | ||
} | ||
.cell(), | ||
) | ||
.into(), | ||
), | ||
AdjustFontFallback::None => (), | ||
}; | ||
|
||
if let Some(fallback) = &options.fallback { | ||
font_fallbacks.push(FontFallback::Manual(StringsVc::cell(fallback.clone())).into()); | ||
} | ||
|
||
Ok(FontFallbacksVc::cell(font_fallbacks)) | ||
} |
Oops, something went wrong.