Add set_hinting method to Buffer

This commit is contained in:
Héctor Ramón Jiménez 2025-11-27 23:18:30 +01:00 committed by Jeremy Soller
parent d779057d9c
commit a07a619054
14 changed files with 54 additions and 48 deletions

View file

@ -2,7 +2,7 @@
use cosmic_text::{
Action, BidiParagraphs, BorrowedWithFontSystem, Buffer, Color, Edit, Editor, FontSystem,
Hinting, Metrics, Motion, SwashCache,
Metrics, Motion, SwashCache,
};
use orbclient::{EventOption, Renderer, Window, WindowFlag};
use std::{env, fs, process, time::Instant};
@ -71,11 +71,7 @@ fn main() {
];
let font_size_default = 1; // Body
let mut buffer = Buffer::new(
&mut font_system,
font_sizes[font_size_default],
Hinting::Disabled,
);
let mut buffer = Buffer::new(&mut font_system, font_sizes[font_size_default]);
buffer
.borrow_with(&mut font_system)
.set_size(Some(window.width() as f32), Some(window.height() as f32));

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use cosmic_text::{
Action, Attrs, Buffer, Edit, Family, FontSystem, Hinting, Metrics, Motion, SwashCache,
SyntaxEditor, SyntaxSystem,
Action, Attrs, Buffer, Edit, Family, FontSystem, Metrics, Motion, SwashCache, SyntaxEditor,
SyntaxSystem,
};
use std::{env, fs, num::NonZeroU32, rc::Rc, slice};
use tiny_skia::{Paint, PixmapMut, Rect, Transform};
@ -45,7 +45,6 @@ fn main() {
Buffer::new(
&mut font_system,
font_sizes[font_size_i].scale(display_scale),
Hinting::Disabled,
),
&syntax_system,
"base16-eighties.dark",

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use cosmic_text::{
Action, Attrs, Buffer, Edit, Family, FontSystem, Hinting, Metrics, Scroll, Shaping, SwashCache,
Action, Attrs, Buffer, Edit, Family, FontSystem, Metrics, Scroll, Shaping, SwashCache,
};
use std::{collections::HashMap, env, fs, num::NonZeroU32, rc::Rc, slice};
use tiny_skia::{Color, Paint, PixmapMut, Rect, Transform};
@ -25,7 +25,7 @@ fn main() {
let mut swash_cache = SwashCache::new();
let mut buffer = Buffer::new_empty(Metrics::new(14.0, 20.0), Hinting::Disabled);
let mut buffer = Buffer::new_empty(Metrics::new(14.0, 20.0));
let mut buffer = buffer.borrow_with(&mut font_system);

View file

@ -7,7 +7,7 @@ use cosmic_text::Editor;
use cosmic_text::Shaping;
use cosmic_text::Style;
use cosmic_text::{
Action, Attrs, Buffer, Edit, Family, FontSystem, Hinting, Metrics, Motion, SwashCache, Weight,
Action, Attrs, Buffer, Edit, Family, FontSystem, Metrics, Motion, SwashCache, Weight,
};
use std::{num::NonZeroU32, rc::Rc, slice};
use tiny_skia::{Paint, PixmapMut, Rect, Transform};
@ -172,10 +172,7 @@ fn main() {
let mut display_scale = window.scale_factor() as f32;
let metrics = Metrics::new(32.0, 44.0);
let mut editor = Editor::new(Buffer::new_empty(
metrics.scale(display_scale),
Hinting::Disabled,
));
let mut editor = Editor::new(Buffer::new_empty(metrics.scale(display_scale)));
let mut editor = editor.borrow_with(&mut font_system);
editor.with_buffer_mut(|buffer| {
buffer.set_size(

View file

@ -4,7 +4,7 @@
//! or `cargo run --package terminal -- "my own text"`
use colored::Colorize;
use cosmic_text::{Attrs, Buffer, Color, FontSystem, Hinting, Metrics, Shaping, SwashCache};
use cosmic_text::{Attrs, Buffer, Color, FontSystem, Metrics, Shaping, SwashCache};
use std::fmt::Write;
fn main() {
@ -20,7 +20,7 @@ fn main() {
let metrics = Metrics::new(FONT_SIZE, LINE_HEIGHT);
// A Buffer provides shaping and layout for a UTF-8 string, create one per text widget
let mut buffer = Buffer::new(&mut font_system, metrics, Hinting::Disabled);
let mut buffer = Buffer::new(&mut font_system, metrics);
let mut buffer = buffer.borrow_with(&mut font_system);