id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_517200 | rust_dataset.txt | 517,200 | 512 | : symbol!(b"FcConfigSubstitute\0"),
default_substitute: symbol!(b"FcDefaultSubstitute\0"),
font_match: symbol!(b"FcFontMatch\0"),
font_sort: symbol!(b"FcFontSort\0"),
object_set_create: symbol!(b"FcObjectSetCreate\0"),
object_set_add: symbol!(b"FcObjectSetAdd\... |
rust_dataset_chunk_517201 | rust_dataset.txt | 517,201 | 512 | ..*start + *length]);
data.resize(data.len() + padded(*length) - *length, 0);
offset += padded(*length);
}
let mut woff = Vec::new();
woff.extend_from_slice(b"wOFF");
woff.extend_from_slice(&sfnt[0..4]);
woff.extend_from_slice(&(offset as u32).to_be_bytes());
woff.extend_from_sli... |
rust_dataset_chunk_517202 | rust_dataset.txt | 517,202 | 512 | _that_resolves_nothing_falls_back_to_the_embedded_fonts() {
assert!(
fontconfig::Fontconfig::load_from("libfontconfig-there-is-no-such-library.so.0")
.is_none(),
"a soname that does not resolve produced a working fontconfig"
);
let mut fonts =
... |
rust_dataset_chunk_517203 | rust_dataset.txt | 517,203 | 512 | ")));
assert!(!is_sfnt(&write("short", b"OT")));
assert!(!is_sfnt(&directory.path().join("missing.otf")));
assert!(is_sfnt(
&embedded_font_dir().join("IosevkaTerm-Regular.ttf")
));
}
#[cfg(not(any(target_os = "macos", windows)))]
fn web_font_discovery(directory: ... |
rust_dataset_chunk_517204 | rust_dataset.txt | 517,204 | 512 | _choice
.as_ref()
.and_then(|path| path.extension())
.is_some_and(|extension| extension == "woff"),
"fontconfig did not rank the web font first for a character: {:?}",
first_choice
);
let (path, _) = discovery
.match_cod... |
rust_dataset_chunk_517205 | rust_dataset.txt | 517,205 | 512 | (|data| !data.is_empty()));
}
#[test]
fn a_match_always_carries_the_codepoint_it_was_asked_for() {
let Some(discovery) = Discovery::open() else {
return;
};
for character in PROBES {
let Some((path, index)) = discovery.match_codepoint(FaceStyle::Regular, char... |
rust_dataset_chunk_517206 | rust_dataset.txt | 517,206 | 512 | () {
let Some(discovery) = synthetic() else {
return;
};
let families = discovery.monospace_families();
assert_eq!(
families
.iter()
.filter(|family| family.eq_ignore_ascii_case("Iosevka Term"))
.count(),
... |
rust_dataset_chunk_517207 | rust_dataset.txt | 517,207 | 512 | platform::Platform;
use crate::text::font::FaceRequest;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Face {
pub families: Vec<String>,
pub monospaced: bool,
pub weight: u16,
pub italic: bool,
/// The OS/2 width class: 1 (ultra-condensed) to 9 (ultra-expanded).
pub width: u16,
}
/// The OS... |
rust_dataset_chunk_517208 | rust_dataset.txt | 517,208 | 512 | , wrong_side)
}
/// How far a face is from a request, closest first. Width only breaks ties:
/// a family may ship wider and narrower cuts of each style under one
/// name, and a terminal wants the normal one, but never at the cost
/// of the requested weight or slant.
fn style_distance(face: &Face, request: FaceReque... |
rust_dataset_chunk_517209 | rust_dataset.txt | 517,209 | 512 | ;
use std::sync::Mutex;
use std::collections::HashMap;
use super::{
emoji_order, fallback_order, family_choice, monospace_families, preferred_fallbacks, Face,
};
use crate::platform::Platform;
use crate::text::font::FaceRequest;
pub struct Scanner {
database: fontdb::Datab... |
rust_dataset_chunk_517210 | rust_dataset.txt | 517,210 | 512 | (), info.index))
}
fn covers(&self, index: usize, character: char) -> bool {
self.database
.with_face_data(self.ids[index], |data, face| {
swash::FontRef::from_index(data, face as usize)
.is_some_and(|font| font.charmap().map(chara... |
rust_dataset_chunk_517211 | rust_dataset.txt | 517,211 | 512 | ![family.to_owned()],
monospaced: true,
weight,
italic: false,
width: NORMAL_WIDTH,
}
}
#[test]
fn a_family_prefers_its_normal_width_to_wider_and_narrower_faces() {
let wide = Face {
width: 6,
..weighted("Mono", 400)
... |
rust_dataset_chunk_517212 | rust_dataset.txt | 517,212 | 512 | false, false),
face("DejaVu Sans", false, false, false),
face("Apple Color Emoji", false, false, false),
face("Symbola", false, false, false),
];
assert_eq!(emoji_order(&faces), vec![2, 0]);
assert!(emoji_order(&[face("Symbola", false, false, false)]).is_empt... |
rust_dataset_chunk_517213 | rust_dataset.txt | 517,213 | 512 | !(family_choice(&faces, "Mono", upright(250)), Some(2));
assert_eq!(
family_choice(&faces[..2], "Mono", upright(400)),
Some(1),
"with no exact match a regular request leans heavier"
);
assert_eq!(
family_choice(&faces[..3], "Mono", upright(250)),
... |
rust_dataset_chunk_517214 | rust_dataset.txt | 517,214 | 512 | _eq!(
fallback_order(&faces, &["Mono"], FaceStyle::Bold.into()),
vec![1, 3, 0, 2]
);
assert_eq!(
fallback_order(&faces, &["Mono"], FaceStyle::Italic.into()),
vec![2, 0, 3, 1]
);
}
#[test]
fn a_family_is_found_by_name_regardless_of_case... |
rust_dataset_chunk_517215 | rust_dataset.txt | 517,215 | 512 | ::is_joining_control;
use crate::text::font::is_private_use;
use crate::text::font::wants_color;
use crate::text::font::ClusterRaster;
use crate::text::font::FaceStyle;
use crate::text::font::Fit;
use crate::text::font::FontId;
use crate::text::font::FontStack;
use crate::text::font::GlyphBitmap;
use crate::text::font:... |
rust_dataset_chunk_517216 | rust_dataset.txt | 517,216 | 512 | as u32 - 0x1161)) * 28 + trailing_index,
)
}
impl FontStack {
pub fn cluster_font(&mut self, style: FaceStyle, text: &str) -> Option<FontId> {
if let Some(found) = self
.cluster_fonts
.get(&style)
.and_then(|fonts| fonts.get(text))
{
return *foun... |
rust_dataset_chunk_517217 | rust_dataset.txt | 517,217 | 512 | covered(style, first) {
if suits(self, discovered.font) {
return Some(discovered.font);
}
}
if text_style {
return fallbacks
.iter()
.copied()
.find(|font| self.covers(*font, text));
}
Non... |
rust_dataset_chunk_517218 | rust_dataset.txt | 517,218 | 512 | drawn;
let Some(font) = self.cluster_font(style, text) else {
return ClusterRaster::Uncovered;
};
let silhouette = text.contains(TEXT_PRESENTATION) && self.has_color(font);
let shaped_text = self.shaping_text(font, text);
if shaped_text.is_empty() {
return... |
rust_dataset_chunk_517219 | rust_dataset.txt | 517,219 | 512 | return ClusterRaster::Blank,
Ok(Some(bitmap)) => as_drawn(bitmap, silhouette),
};
}
let placed = fit.place(bitmap, advance * size / self.size);
match crop_to_cell(placed, self.metrics) {
Some(bitmap) => ClusterRaster::Sprite(bitmap),
None => C... |
rust_dataset_chunk_517220 | rust_dataset.txt | 517,220 | 512 | if right <= left || top <= bottom {
return Ok(None);
}
let width = (right - left) as usize;
let height = (top - bottom) as usize;
let channels = content.channels() as usize;
let mut coverage = vec![0u8; width * height * channels];
for (x, piece_top, bi... |
rust_dataset_chunk_517221 | rust_dataset.txt | 517,221 | 512 | _or_else(|poisoned| poisoned.into_inner());
if let Some(data) = files.get(path) {
return Some(*data);
}
let data = map_font_file(path)
.map_err(|e| report!("failed to read the font {:?}: {}", path, e))
.ok()?;
files.insert(path.to_path_buf(), data);
Some(data)
}
pub(super) f... |
rust_dataset_chunk_517222 | rust_dataset.txt | 517,222 | 512 | &FontRef<'_>, weight: u16) -> Vec<i16> {
let variations = font.variations();
let Some(axis) = variations.find_by_tag(tag_from_bytes(WEIGHT_AXIS)) else {
return Vec::new();
};
let value = (weight as f32).clamp(axis.min_value(), axis.max_value());
let coords: Vec<i16> = variations
.no... |
rust_dataset_chunk_517223 | rust_dataset.txt | 517,223 | 512 | color) in fallbacks {
if discovered.is_none() || *color {
return Some(*glyph);
}
}
discovered.map(|(glyph, _)| glyph)
}
impl FontStack {
pub fn lookup(&mut self, style: FaceStyle, character: char) -> Option<Glyph> {
if let Some(resolved) = self.resolved.get(&(style, cha... |
rust_dataset_chunk_517224 | rust_dataset.txt | 517,224 | 512 | bool {
self.color_capable.get(font.0).copied().unwrap_or(false)
}
pub(super) fn map(&self, font: FontId, character: char) -> Option<Glyph> {
let glyph = self.faces.get(font.0)?.charmap().map(character);
(glyph != 0).then_some(Glyph { font, glyph })
}
pub(super) fn discovered(&... |
rust_dataset_chunk_517225 | rust_dataset.txt | 517,225 | 512 | "no font family named {:?} resolved for {:?} text; \
using the main font's {:?} face",
family,
style,
style
),
}
}
styled
}
/// Whether `font` measures the same cell ... |
rust_dataset_chunk_517226 | rust_dataset.txt | 517,226 | 512 | );
Some(font)
}
}
--- FILE: zellij/zellij-terminal/src/text/font/raster.rs ---
use crate::text::font::CellMetrics;
use crate::text::font::FontStack;
use crate::text::font::Glyph;
use crate::text::font::GlyphBitmap;
use crate::text::font::GlyphContent;
use crate::text::font::FALLBACK_OVERHANG;
use crate::t... |
rust_dataset_chunk_517227 | rust_dataset.txt | 517,227 | 512 | -> f32 {
(self.widest(bitmap.content) as f32 / bitmap.width as f32)
.min(self.cell_height as f32 / bitmap.height as f32)
.min(1.0)
}
pub(super) fn place(&self, bitmap: GlyphBitmap, advance: f32) -> GlyphBitmap {
let widest = self.widest(bitmap.content);
let bitm... |
rust_dataset_chunk_517228 | rust_dataset.txt | 517,228 | 512 | crop_to_cell(bitmap: GlyphBitmap, metrics: CellMetrics) -> Option<GlyphBitmap> {
let highest = metrics.baseline as i32;
let lowest = highest - metrics.height as i32;
let top = bitmap.top.min(highest);
let bottom = (bitmap.top - bitmap.height as i32).max(lowest);
if top <= bottom {
return No... |
rust_dataset_chunk_517229 | rust_dataset.txt | 517,229 | 512 | / height;
let y1 = (((y + 1) * source_height + height - 1) / height).max(y0 + 1);
for x in 0..width {
let x0 = x * source_width / width;
let x1 = (((x + 1) * source_width + width - 1) / width).max(x0 + 1);
for channel in 0..channels {
let mut total = ... |
rust_dataset_chunk_517230 | rust_dataset.txt | 517,230 | 512 | }
Some(fit.place(bitmap, advance_at(size)))
}
pub(super) fn render(
&mut self,
font: FontRef<'static>,
coords: &[i16],
glyph: GlyphId,
size: f32,
sources: &[Source],
) -> Option<GlyphBitmap> {
let mut scaler = self
.context... |
rust_dataset_chunk_517231 | rust_dataset.txt | 517,231 | 512 | IGATURES: bool = true;
pub const DEFAULT_FONT_WEIGHT: u16 = 400;
const BOLD_WEIGHT_STEP: u16 = 300;
const MAX_FONT_WEIGHT: u16 = 900;
const EMBEDDED_BOLD_THRESHOLD: u16 = 500;
const WEIGHT_AXIS: &[u8; 4] = b"wght";
const LIGATURE_FEATURES: [&[u8; 4]; 3] = [b"liga", b"calt", b"dlig"];
const MIN_FONT_SIZE: f32 = 4.0;
co... |
rust_dataset_chunk_517232 | rust_dataset.txt | 517,232 | 512 | , Hash)]
pub enum FaceStyle {
Regular,
Bold,
Italic,
BoldItalic,
}
impl FaceStyle {
pub fn of(bold: bool, italic: bool) -> Self {
match (bold, italic) {
(false, false) => FaceStyle::Regular,
(true, false) => FaceStyle::Bold,
(false, true) => FaceStyle::It... |
rust_dataset_chunk_517233 | rust_dataset.txt | 517,233 | 512 | pub top: i32,
pub width: u32,
pub height: u32,
pub coverage: Vec<u8>,
pub content: GlyphContent,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FaceRequest {
pub weight: u16,
pub italic: bool,
}
impl FaceRequest {
pub fn weighted(style: FaceStyle, regular: u16) -> Self... |
rust_dataset_chunk_517234 | rust_dataset.txt | 517,234 | 512 | default() -> Self {
Self {
line_height: 1.0,
cell_width: 1.0,
baseline_offset: 0.0,
underline_offset: 0.0,
underline_thickness: 0.0,
}
}
}
impl CellAdjust {
fn scaled(&self, scale: f32) -> Self {
Self {
baseline_of... |
rust_dataset_chunk_517235 | rust_dataset.txt | 517,235 | 512 | _FONT_WEIGHT,
features: Vec::new(),
cell: CellAdjust::default(),
}
}
}
pub fn points_to_pixels(points: f32) -> f32 {
points * PIXELS_PER_INCH / POINTS_PER_INCH
}
impl FontOptions {
pub fn scaled(&self, scale: f64) -> Self {
Self {
size: self.size * scale... |
rust_dataset_chunk_517236 | rust_dataset.txt | 517,236 | 512 | {e0020}'..='\u{e007f}' => return true,
'\u{200d}' => zwj = true,
'\u{1f000}'..='\u{1faff}' => pictographic = true,
_ => {},
}
}
zwj && pictographic
}
pub struct FontStack {
faces: Vec<FontRef<'static>>,
coords: Vec<Vec<i16>>,
color_capable: Vec<bool>,
... |
rust_dataset_chunk_517237 | rust_dataset.txt | 517,237 | 512 | ?,
face(BOLD, "IosevkaTerm-Bold")?,
face(ITALIC, "IosevkaTerm-Italic")?,
face(BOLD_ITALIC, "IosevkaTerm-BoldItalic")?,
face(CJK, "NotoSansMonoCJK-Regular")?,
match emoji {
Some(emoji) => face(emoji, "NotoColorEmoji")?,
None => f... |
rust_dataset_chunk_517238 | rust_dataset.txt | 517,238 | 512 | 0].0;
let (metrics, placement) = derive_metrics(
&stack.faces[regular],
&stack.coords[regular],
size,
&options.cell,
);
stack.metrics = metrics;
stack.placement = placement;
stack.styled = stack.requested_styles(options);
Ok... |
rust_dataset_chunk_517239 | rust_dataset.txt | 517,239 | 512 | as u32;
let underline_stroke =
(stroke as i32 + adjust.underline_thickness.round() as i32).clamp(1, height as i32) as u32;
let underline_top = ((baseline as f32 - metrics.underline_offset).round()
+ adjust.underline_offset.round())
.clamp(0.0, (height - underline_stroke.min(height)) as f32... |
rust_dataset_chunk_517240 | rust_dataset.txt | 517,240 | 512 | ::new();
if !ligatures {
for tag in LIGATURE_FEATURES {
if !requested.iter().any(|feature| &feature.tag == tag) {
features.push(FontFeature {
tag: *tag,
value: 0,
});
}
}
}
features.extend_from_sl... |
rust_dataset_chunk_517241 | rust_dataset.txt | 517,241 | 512 |
.iter()
.map(|feature| (tag_from_bytes(&feature.tag), feature.value)),
)
.normalized_coords(coords.iter())
.build();
shaper.add_str(text);
let mut glyphs = Vec::new();
let mut pen = 0.0f32;
shaper.shape_with(|sh... |
rust_dataset_chunk_517242 | rust_dataset.txt | 517,242 | 512 | {
std::borrow::Cow::Owned(
text.chars()
.filter(|character| !unmapped_control(*character))
.collect(),
)
} else {
std::borrow::Cow::Borrowed(text)
}
}
pub(super) fn shape_uncached(&mut self, font: FontI... |
rust_dataset_chunk_517243 | rust_dataset.txt | 517,243 | 512 | i32,
advance: glyph.advance.round() as i32,
});
pen += glyph.advance;
}
});
glyphs
}
}
--- FILE: zellij/zellij-terminal/src/text/font/test_helpers.rs ---
use super::*;
impl FontStack {
pub fn embedded(size: f32) -> Result<Self> ... |
rust_dataset_chunk_517244 | rust_dataset.txt | 517,244 | 512 | _FONT_SIZE).unwrap()
}
fn glyph_of(fonts: &mut FontStack, style: FaceStyle, character: char) -> Glyph {
fonts
.lookup(style, character)
.unwrap_or_else(|| panic!("{:?} has no glyph anywhere in the stack", character))
}
#[test]
fn the_embedded_faces_all_parse() {
let mut fonts = fonts();
fo... |
rust_dataset_chunk_517245 | rust_dataset.txt | 517,245 | 512 | : DEFAULT_LIGATURES,
..FontOptions::default()
}
}
fn adjusted(cell: CellAdjust) -> FontStack {
FontStack::build_with(
&FontOptions {
system_fonts: false,
cell,
..FontOptions::default()
},
None,
)
.unwrap()
}
#[test]
fn line_height_gro... |
rust_dataset_chunk_517246 | rust_dataset.txt | 517,246 | 512 | at_wide.width, at_natural.width);
}
#[test]
fn shaped_glyphs_land_on_their_own_widened_cells() {
let mut wide = FontStack::build_with(
&FontOptions {
system_fonts: false,
ligatures: true,
cell: CellAdjust {
cell_width: 1.5,
..CellAdjust::d... |
rust_dataset_chunk_517247 | rust_dataset.txt | 517,247 | 512 | !(placement.underline_stroke >= 1);
assert!(
metrics.underline_top + placement.underline_stroke <= metrics.height,
"{} {}: {:?} {:?}",
offset,
thickness,
metrics,
placement
);
}
}
#[test]
fn default_adjustments_leave_the_cell_a... |
rust_dataset_chunk_517248 | rust_dataset.txt | 517,248 | 512 | ).italic);
}
#[test]
fn features_turn_shaping_on_and_keep_ligatures_off_when_asked() {
let zero = FontFeature::parse("zero").unwrap();
let stack = FontStack::build_with(
&FontOptions {
system_fonts: false,
ligatures: false,
features: vec![zero, FontFeature::parse("+c... |
rust_dataset_chunk_517249 | rust_dataset.txt | 517,249 | 512 | calt"]),
"turning calt off left the arrow joined"
);
assert!(
arrow_ligates(false, &["+calt"]),
"listing calt with ligatures off did not join the arrow"
);
assert!(
!arrow_ligates(false, &["zero"]),
"an unrelated feature with ligatures off still joined the arrow"
... |
rust_dataset_chunk_517250 | rust_dataset.txt | 517,250 | 512 | _tags_parse_with_an_optional_sign() {
assert_eq!(
FontFeature::parse("-liga"),
Some(FontFeature {
tag: *b"liga",
value: 0
})
);
assert_eq!(
FontFeature::parse("ss01"),
Some(FontFeature {
tag: *b"ss01",
value: 1
}... |
rust_dataset_chunk_517251 | rust_dataset.txt | 517,251 | 512 | _then(|((path, _, _), _)| path.file_name())
.map(|name| name.to_string_lossy().into_owned())
}
fn file_of(stack: &FontStack, style: FaceStyle) -> Option<String> {
file_of_font(stack, stack.primary_of(style))
}
fn drawn_from(stack: &mut FontStack, style: FaceStyle, character: char) -> Option<String> {
... |
rust_dataset_chunk_517252 | rust_dataset.txt | 517,252 | 512 | COND_FAMILY.to_owned()),
bold_italic_family: Some(SECOND_FAMILY.to_owned()),
..FontOptions::default()
}),
Some(discovery),
)
.unwrap();
for style in [FaceStyle::Bold, FaceStyle::Italic, FaceStyle::BoldItalic] {
assert_eq!(
drawn_from(&mut stack, st... |
rust_dataset_chunk_517253 | rust_dataset.txt | 517,253 | 512 | else {
return;
};
let mut stack = FontStack::build_with(
&FontOptions {
italic_family: Some("Iosevka Term".to_owned()),
..FontOptions::default()
},
Some(discovery),
)
.unwrap();
assert_eq!(stack.primary_of(FaceStyle::Regular), EMBEDDED_PRIMARY... |
rust_dataset_chunk_517254 | rust_dataset.txt | 517,254 | 512 | let regular = glyph_of(&mut fonts, FaceStyle::Regular, '\u{4f60}');
let bold = glyph_of(&mut fonts, FaceStyle::Bold, '\u{4f60}');
assert_eq!(regular.font, bold.font);
}
#[test]
fn an_emoji_resolves_to_a_color_glyph() {
let mut fonts = fonts();
let glyph = glyph_of(&mut fonts, FaceStyle::Regular, '\u{1... |
rust_dataset_chunk_517255 | rust_dataset.txt | 517,255 | 512 | ]
fn a_rendered_glyph_fits_inside_the_cell_box() {
let mut fonts = fonts();
let metrics = fonts.metrics();
let glyph = glyph_of(&mut fonts, FaceStyle::Regular, 'M');
let bitmap = fonts.rasterize(glyph, 1).unwrap();
assert!(bitmap.width <= metrics.width, "{}", bitmap.width);
assert!(bitmap.height... |
rust_dataset_chunk_517256 | rust_dataset.txt | 517,256 | 512 | _faces() {
assert_eq!(FaceStyle::of(false, false), FaceStyle::Regular);
assert_eq!(FaceStyle::of(true, false), FaceStyle::Bold);
assert_eq!(FaceStyle::of(false, true), FaceStyle::Italic);
assert_eq!(FaceStyle::of(true, true), FaceStyle::BoldItalic);
}
#[test]
fn the_embedded_stack_consults_no_system_fo... |
rust_dataset_chunk_517257 | rust_dataset.txt | 517,257 | 512 | 1).is_some(),
"{:?} rendered nothing",
icon
);
}
let glyph = glyph_of(&mut fonts, FaceStyle::Regular, '\u{f16a0}');
assert_eq!(glyph.font, FontId(6));
}
#[test]
fn private_use_icons_skip_system_font_discovery() {
let mut fonts = FontStack::build(&FontOptions::default())... |
rust_dataset_chunk_517258 | rust_dataset.txt | 517,258 | 512 | );
}
#[test]
fn a_system_face_is_still_preferred_where_no_color_is_at_stake() {
let mut fonts = FontStack::new(DEFAULT_FONT_SIZE, true).unwrap();
if !fonts.has_discovery() {
return;
}
let Some(glyph) = fonts.lookup(FaceStyle::Regular, '\u{2801}') else {
return;
};
assert!(!font... |
rust_dataset_chunk_517259 | rust_dataset.txt | 517,259 | 512 | ,
top,
width,
height,
coverage: vec![200; (width * height) as usize],
content: GlyphContent::Mask,
}
}
#[test]
fn an_oversized_bitmap_is_confined_by_its_tallest_axis() {
let confined = confine(mask(0, 40, 10, 100), 16, 20);
assert_eq!(confined.height, 20);
assert... |
rust_dataset_chunk_517260 | rust_dataset.txt | 517,260 | 512 | [0]),
"a dot in the top row moved between frames: {:?}",
tops
);
}
#[test]
fn a_glyph_family_is_scaled_by_its_advance_not_by_each_glyphs_ink() {
let fit = fit();
let room = fit.box_width as f32 * FALLBACK_OVERHANG;
assert_eq!(fit.advance_scale(fit.box_width as f32), 1.0);
assert_eq!... |
rust_dataset_chunk_517261 | rust_dataset.txt | 517,261 | 512 | .0,
"an emoji must stay inside its box"
);
let far_too_wide = mask(0, 10, fit.box_width * 2, 8);
assert!(fit.ink_scale(&far_too_wide) < 1.0);
}
#[test]
fn a_glyph_poking_out_of_the_cell_is_nudged_back_in() {
let fit = fit();
let metrics = fonts().metrics();
let above = fit.place(mask(0,... |
rust_dataset_chunk_517262 | rust_dataset.txt | 517,262 | 512 | {}",
bottom
);
}
const FAMILY: &str = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}";
const SKIN_TONE: &str = "\u{1f44d}\u{1f3fd}";
const FLAG: &str = "\u{1f1e9}\u{1f1ea}";
const RAINBOW_FLAG: &str = "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}";
const ENGLAND_FLAG: &str = "\u{1f3f4}\u{e0067}\u{e0062}\u{e0065}\u{e0... |
rust_dataset_chunk_517263 | rust_dataset.txt | 517,263 | 512 | ENGLAND_FLAG, KEYCAP] {
assert!(wants_color(sequence), "{:?}", sequence);
}
for text in ["e\u{301}", "\u{915}\u{94d}\u{937}", "a\u{200d}b"] {
assert!(!wants_color(text), "{:?}", text);
}
}
#[test]
fn the_font_chosen_for_a_cluster_covers_all_of_it() {
let mut fonts = fonts();
for te... |
rust_dataset_chunk_517264 | rust_dataset.txt | 517,264 | 512 | );
assert!(
fonts.covers(primary, "\u{26a0}\u{fe0f}"),
"the primary face no longer carries the warning sign, so this test proves nothing"
);
}
#[test]
fn an_emoji_with_its_presentation_selector_is_one_colour_sprite() {
let mut fonts = fonts();
for sequence in PRESENTED {
match f... |
rust_dataset_chunk_517265 | rust_dataset.txt | 517,265 | 512 | not rasterize as one sprite", sequence),
}
}
}
#[test]
fn a_joined_sequence_differs_from_its_first_piece() {
let mut fonts = fonts();
for (sequence, first) in [
(SKIN_TONE, "\u{1f44d}"),
(FLAG, "\u{1f1e9}"),
(FAMILY, "\u{1f468}"),
(RAINBOW_FLAG, "\u{1f3f3}"),
... |
rust_dataset_chunk_517266 | rust_dataset.txt | 517,266 | 512 | !(bitmap.height <= metrics.height, "{}", bitmap.height);
assert!(bitmap.top <= metrics.baseline as i32);
assert!(
bitmap.top - bitmap.height as i32
>= metrics.baseline as i32 - metrics.height as i32
);
},
ClusterRaster::Blank => pan... |
rust_dataset_chunk_517267 | rust_dataset.txt | 517,267 | 512 | the jamo did not draw");
};
let ClusterRaster::Sprite(composed) =
fonts.rasterize_cluster(FaceStyle::Regular, "\u{ac01}", 2)
else {
panic!("the composed syllable did not draw");
};
assert_eq!(
(pieces.left, pieces.top, pieces.width, pieces.height),
(composed.left, com... |
rust_dataset_chunk_517268 | rust_dataset.txt | 517,268 | 512 | {
system_fonts: true,
..FontOptions::default()
},
Some(discovery),
)
.unwrap();
let font = fonts
.cluster_font(FaceStyle::Regular, "\u{2614}\u{fe0e}")
.expect("the umbrella found no face");
assert!(
!fonts.has_color(font),
"a colou... |
rust_dataset_chunk_517269 | rust_dataset.txt | 517,269 | 512 | (FaceStyle::Regular, "x\u{301}\u{302}", 1)
else {
panic!("a with two marks did not draw");
};
assert!(stacked.height > single.height);
}
#[cfg(unix)]
#[test]
fn a_font_file_this_user_can_write_is_read_rather_than_mapped() {
let file = tempfile::NamedTempFile::new().unwrap();
assert!(!super:... |
rust_dataset_chunk_517270 | rust_dataset.txt | 517,270 | 512 | loaded, REGULAR);
}
#[test]
fn a_font_file_is_loaded_once_per_process() {
let mut file = tempfile::NamedTempFile::new().unwrap();
std::io::Write::write_all(&mut file, REGULAR).unwrap();
let first = font_file(file.path()).unwrap();
let second = font_file(file.path()).unwrap();
assert_eq!(first.as_pt... |
rust_dataset_chunk_517271 | rust_dataset.txt | 517,271 | 512 | Stack {
FontStack::without_bundled_emoji(
&FontOptions {
system_fonts: false,
..FontOptions::default()
},
None,
)
.unwrap()
}
const EMOJI_SAMPLES: [&str; 5] = [
"\u{1f600}",
"\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}",
"\u{1f1fa}\u{1f1f8}",
... |
rust_dataset_chunk_517272 | rust_dataset.txt | 517,272 | 512 | Raster::Blank | ClusterRaster::Uncovered => {},
}
}
}
#[test]
fn without_the_bundled_emoji_an_installed_emoji_font_is_used_before_the_symbols() {
let Some(discovery) = synthetic_discovery() else {
return;
};
let mut fonts =
FontStack::without_bundled_emoji(&FontOptions::default(... |
rust_dataset_chunk_517273 | rust_dataset.txt | 517,273 | 512 | (&options, Some(discovery)).unwrap();
assert!(
stack.primary[0].0 >= 7,
"system_fonts off blocked the chosen family: {:?}",
stack.primary
);
stack.lookup(FaceStyle::Regular, '\u{10fffd}');
assert_eq!(
stack.discovery_queries, 0,
"system_fonts off still consulted t... |
rust_dataset_chunk_517274 | rust_dataset.txt | 517,274 | 512 | let image = match crate::render::image_io::decode(ICON_PNG) {
Ok(image) => image,
Err(e) => {
report!("the embedded window icon is unreadable: {e}");
return None;
},
};
match Icon::from_rgba(image.pixels, image.width, image.height) {
Ok(icon) => Some(icon... |
rust_dataset_chunk_517275 | rust_dataset.txt | 517,275 | 512 | ::app::policy::route::{pane_focus, route, AttachedWindow, Route};
use crate::app::{panel_toggle, Intent, PanelToggle};
pub(crate) const POPUP_REOPEN_GUARD: Duration = Duration::from_millis(400);
pub(crate) trait Facts {
fn session_of(&self, key: u64) -> Option<String>;
fn has_session(&self, name: &str) -> boo... |
rust_dataset_chunk_517276 | rust_dataset.txt | 517,276 | 512 | },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct PendingPanel {
ticket: u64,
view: Option<PopupView>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct ShownPanel {
view: Option<PopupView>,
focused: bool,
}
pub(crate) struct Conductor {
hosted: bool,
windows: BTreeMap<u64, u64... |
rust_dataset_chunk_517277 | rust_dataset.txt | 517,277 | 512 | dyn Facts) -> Vec<Effect> {
let mut effects = vec![];
match input {
Input::Started { first } => {
if self.started {
return effects;
}
self.started = true;
if let Some(intent) = first {
sel... |
rust_dataset_chunk_517278 | rust_dataset.txt | 517,278 | 512 | stop_sessions } => self.quit(stop_sessions, facts, &mut effects),
}
effects
}
fn take_key(&mut self) -> u64 {
let key = self.next_key;
self.next_key += 1;
key
}
fn note_focus(&mut self, key: u64) {
if let Some(at) = self.windows.get_mut(&key) {
... |
rust_dataset_chunk_517279 | rust_dataset.txt | 517,279 | 512 | => self.route_to(
&session,
pane,
token,
OpenWindowRequest::default(),
facts,
effects,
),
Intent::RouteRequest { request, token } => {
let session ... |
rust_dataset_chunk_517280 | rust_dataset.txt | 517,280 | 512 | &mut Vec<Effect>,
) {
let ticket = self.take_key();
if !self.hosted {
return;
}
self.pending_windows.insert(ticket);
effects.push(Effect::OpenWindow {
ticket,
request,
token,
});
}
fn connected(&mut self, ticke... |
rust_dataset_chunk_517281 | rust_dataset.txt | 517,281 | 512 | || pending_only {
return;
}
}
if toggling && self.just_closed(now) {
self.lost_focus_at = None;
return;
}
if !self.hosted {
return;
}
let ticket = self.take_key();
self.panel_pending = Some(PendingPa... |
rust_dataset_chunk_517282 | rust_dataset.txt | 517,282 | 512 | () {
Some(session) if live => Intent::Route {
session,
pane,
token,
},
name => Intent::Open {
request: OpenWindowRequest {
session: name,
create: true,
pane_id:... |
rust_dataset_chunk_517283 | rust_dataset.txt | 517,283 | 512 | Effect> {
self.at(0, input)
}
fn intent(&mut self, millis: u64, intent: Intent) -> Vec<Effect> {
self.at(millis, Input::Intents(vec![intent]))
}
fn window_on(&mut self, session: &str) -> u64 {
let effects = self.intent(
0,
... |
rust_dataset_chunk_517284 | rust_dataset.txt | 517,284 | 512 | .conductor.panel_state(), None);
let ticket = opened_panel(&rig.intent(0, toggle(PopupView::Sessions))).unwrap();
assert_eq!(
rig.conductor.panel_state(),
Some(PanelState {
view: Some(PopupView::Sessions),
shown: false
})
);
... |
rust_dataset_chunk_517285 | rust_dataset.txt | 517,285 | 512 | rig = Rig::hosted();
let effects = rig.intent(0, toggle(PopupView::Inbox));
assert!(opened_panel(&effects).is_some());
assert!(rig.intent(5, toggle(PopupView::Inbox)).is_empty());
assert!(rig.intent(5, toggle(PopupView::Sessions)).is_empty());
}
#[test]
fn a_shortcut_right_... |
rust_dataset_chunk_517286 | rust_dataset.txt | 517,286 | 512 | Input::Connected {
ticket,
error: None,
},
);
rig.at(60, Input::PanelFocused);
assert_eq!(rig.at(70, Input::PanelFocusLost), vec![Effect::ClosePanel]);
assert!(
rig.intent(200, tray_click()).is_empty(),
"the click that ... |
rust_dataset_chunk_517287 | rust_dataset.txt | 517,287 | 512 | = Rig::hosted();
let ticket = opened_panel(&rig.intent(0, toggle(PopupView::Inbox))).unwrap();
assert_eq!(
rig.feed(Input::Connected {
ticket,
error: Some("boom".to_owned())
}),
vec![Effect::Notify {
text: "The inbox co... |
rust_dataset_chunk_517288 | rust_dataset.txt | 517,288 | 512 | (!request.create);
},
other => panic!("expected a new window, got {:?}", other),
}
}
#[test]
fn choosing_a_new_or_exited_session_opens_a_window_that_creates_it() {
let mut rig = Rig::hosted();
rig.open_panel(0, PopupView::Sessions);
let to = ConnectTo... |
rust_dataset_chunk_517289 | rust_dataset.txt | 517,289 | 512 | ed();
rig.world.live = vec!["a".to_owned()];
assert_eq!(
rig.intent(0, Intent::QuitApp),
vec![Effect::Quit {
stop: vec![APP_PANEL_SESSION.to_owned()]
}]
);
let mut rig = Rig::single();
assert_eq!(
rig.feed(Input::Qui... |
rust_dataset_chunk_517290 | rust_dataset.txt | 517,290 | 512 | _routed_click_without_a_window_on_the_session_opens_one_and_keeps_its_token() {
let mut rig = Rig::hosted();
rig.window_on("docs");
let effects = rig.intent(
0,
Intent::Route {
session: "api".to_owned(),
pane: Some(PaneId::Terminal(7)),
... |
rust_dataset_chunk_517291 | rust_dataset.txt | 517,291 | 512 | : None
}),
vec![
Effect::ShowWindow { ticket: 1 },
Effect::SetAccessory(false)
]
);
}
#[test]
fn starting_with_a_panel_shortcut_opens_only_the_panel_with_the_launch_token() {
let mut rig = Rig::hosted();
let effects... |
rust_dataset_chunk_517292 | rust_dataset.txt | 517,292 | 512 | by_user: true
})
.is_empty());
assert!(!rig.conductor.should_exit());
}
#[test]
fn a_single_window_exits_when_its_window_closes_and_never_notices_or_hides() {
let mut rig = Rig::single();
rig.conductor.adopt(1);
assert!(rig.feed(Input::Started { firs... |
rust_dataset_chunk_517293 | rust_dataset.txt | 517,293 | 512 | assert_eq!(
rig.conductor.window_showing(Some("api"), api, &rig.world),
Some(second_api)
);
assert_eq!(
rig.conductor.window_showing(Some("docs"), docs, &rig.world),
None,
"the only window on the session is the one switching"
);
... |
rust_dataset_chunk_517294 | rust_dataset.txt | 517,294 | 512 | (4)),
tab: Some(2),
history: Some(history),
token: None,
requester: Some(docs)
}]
);
assert_eq!(rig.conductor.most_recent_window(), Some(api));
assert!(rig
.feed(Input::HandedOver {
handover: ... |
rust_dataset_chunk_517295 | rust_dataset.txt | 517,295 | 512 | use winit::window::WindowId;
use zellij_utils::app_control::OpenWindowRequest;
impl ApplicationHandler<Wake> for Desktop {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let keys: Vec<u64> = self.windows.keys().copied().collect();
for key in keys {
let verdict = match self.window... |
rust_dataset_chunk_517296 | rust_dataset.txt | 517,296 | 512 | | panel.app.window_id() == Some(id))
.unwrap_or(false)
{
self.panel_event(event_loop, event);
return;
}
let Some(key) = self
.windows
.iter()
.find(|(_, app)| app.window_id() == Some(id))
.map(|(key, _)| *key)
... |
rust_dataset_chunk_517297 | rust_dataset.txt | 517,297 | 512 | (now);
}
}
let mut deadline: Option<Instant> = None;
let mut earliest = |at: Option<Instant>| {
if let Some(at) = at {
deadline = Some(deadline.map_or(at, |d: Instant| d.min(at)));
}
};
for app in self.windows.values_mut() {
... |
rust_dataset_chunk_517298 | rust_dataset.txt | 517,298 | 512 | bottom,
left || x < corner && bottom,
right || x >= width - corner && bottom,
) {
(true, _, true, _) => Some(NorthWest),
(true, _, _, true) => Some(NorthEast),
(_, true, true, _) => Some(SouthWest),
(_, true, _, true) => Some(SouthEast),
(true, _, _, _) => So... |
rust_dataset_chunk_517299 | rust_dataset.txt | 517,299 | 512 | init::window::Window::set_cursor(self, icon)
}
fn drag_window(&self) -> Result<(), String> {
winit::window::Window::drag_window(self).map_err(|e| e.to_string())
}
fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), String> {
winit::window::Window::drag_resize_window(se... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.