Skip to content

Commit

Permalink
Fix typos and add a CI check (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Oct 21, 2024
1 parent baf0bc0 commit 342f20b
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 22 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ jobs:
- name: cargo doc piet-web
run: cargo doc --manifest-path=piet-web/Cargo.toml --all-features --document-private-items --target wasm32-unknown-unknown

# If this fails, consider changing your text or adding something to .typos.toml
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: check typos
uses: crate-ci/[email protected]

compare-snapshots:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
20 changes: 20 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See the configuration reference at
# https://github.com/crate-ci/typos/blob/master/docs/reference.md

# Corrections take the form of a key/value pair. The key is the incorrect word
# and the value is the correct word. If the key and value are the same, the
# word is treated as always correct. If the value is an empty string, the word
# is treated as always incorrect.

# Match Identifier - Case Sensitive
[default.extend-identifiers]

# Match Inside a Word - Case Insensitive
[default.extend-words]

[files]
# Include .github, .cargo, etc.
ignore-hidden = false
# /.git isn't in .gitignore, because git never tracks it.
# Typos doesn't know that, though.
extend-exclude = ["/.git"]
2 changes: 1 addition & 1 deletion piet-cairo/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Text for CairoText {
type TextLayoutBuilder = CairoTextLayoutBuilder;

fn font_family(&mut self, family_name: &str) -> Option<FontFamily> {
//TODO: Veryify that a family exists with the requested name
//TODO: Verify that a family exists with the requested name
Some(FontFamily::new_unchecked(family_name))
}

Expand Down
4 changes: 2 additions & 2 deletions piet-common/examples/mondrian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ fn main() {
/// Generate a Piet Mondrian-style picture.
///
/// Obviously we cannot recreate the genius of an artist with a simple random
/// generation, but the following makes something plausable (heavily influenced by
/// generation, but the following makes something plausible (heavily influenced by
/// https://generativeartistry.com/tutorials/piet-mondrian/):
///
/// 1. Start with a single rectangle covering the whole picture.
/// 2. Choose a number `n`. Choose `n` coordinates in the rectange.
/// 2. Choose a number `n`. Choose `n` coordinates in the rectangle.
/// 3. For each coordinate `p`: split any rectangles who are intersected by the
/// vertical or horizontal lines that cross `p`. Skip if this would create a
/// very thin rectangle, or randomly some of the time.
Expand Down
6 changes: 3 additions & 3 deletions piet-coregraphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub struct CoreGraphicsContext<'a> {
impl<'a> CoreGraphicsContext<'a> {
/// Create a new context with the y-origin at the top-left corner.
///
/// This is not the default for CoreGraphics; but it is the defualt for piet.
/// This is not the default for CoreGraphics; but it is the default for piet.
/// To map between the two coordinate spaces you must also pass an explicit
/// height argument.
///
/// The optional `text` argument can be a reuseable `CoreGraphicsText` struct;
/// The optional `text` argument can be a reusable `CoreGraphicsText` struct;
/// a new one will be constructed if `None` is passed.
pub fn new_y_up(
ctx: &mut CGContextRef,
Expand All @@ -76,7 +76,7 @@ impl<'a> CoreGraphicsContext<'a> {
///
/// This is the default for core graphics, but not for piet.
///
/// The optional `text` argument can be a reuseable `CoreGraphicsText` struct;
/// The optional `text` argument can be a reusable `CoreGraphicsText` struct;
/// a new one will be constructed if `None` is passed.
pub fn new_y_down(
ctx: &mut CGContextRef,
Expand Down
2 changes: 1 addition & 1 deletion piet-direct2d/src/dwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl TextLayout {
}
}

pub(crate) fn set_foregound_brush(&mut self, range: Utf16Range, brush: Brush) {
pub(crate) fn set_foreground_brush(&mut self, range: Utf16Range, brush: Brush) {
unsafe {
self.0
.SetDrawingEffect(brush.as_raw() as *mut IUnknown, range.into());
Expand Down
4 changes: 2 additions & 2 deletions piet-direct2d/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl D2DTextLayoutBuilder {
layout.set_font_collection(utf16_range, loaded.collection());
} else if !self.loaded_fonts.inner.borrow().is_empty() {
// if we are using custom fonts we also need to set the collection
// back to the system collection explicity as needed
// back to the system collection explicitly as needed
layout.set_font_collection(utf16_range, &FontCollection::system());
}
let family_name = resolve_family_name(&font);
Expand Down Expand Up @@ -468,7 +468,7 @@ impl D2DTextLayout {
if self.needs_to_set_colors.replace(false) {
for (range, color) in self.colors.as_ref() {
let brush = ctx.solid_brush(*color);
self.layout.borrow_mut().set_foregound_brush(*range, brush)
self.layout.borrow_mut().set_foreground_brush(*range, brush)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion piet-svg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl piet::RenderContext for RenderContext {
//
// `dominant-baseline` gets us most of the way (to the top of the ascender), so we add a
// small fiddle factor in to cover the difference between the top of the line and the top
// of the ascender (currently 6% of the font height, calcuated by eye).
// of the ascender (currently 6% of the font height, calculated by eye).
let y = pos.y + 0.06 * layout.size().height;
let mut text = svg::node::element::Text::new()
.set("x", x)
Expand Down
2 changes: 1 addition & 1 deletion piet-svg/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl piet::TextLayout for TextLayout {
}
}

/// All the info required to indentify a font face. Basically, everythinge except the size.
/// All the info required to identify a font face. Basically, everythinge except the size.
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
pub(crate) struct FontFace {
pub family: FontFamily,
Expand Down
2 changes: 1 addition & 1 deletion piet-web/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl WebTextLayout {

fn update_width(&mut self, new_width: impl Into<Option<f64>>) {
// various functions like `text_width` are stateful, and require
// the context to be configured correcttly.
// the context to be configured correctly.
self.ctx.set_font(&self.font.get_font_string());
let new_width = new_width.into().unwrap_or(f64::INFINITY);
let mut line_metrics =
Expand Down
2 changes: 1 addition & 1 deletion piet-web/src/text/grapheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::hit_test_line_position;
// code in `piet` core doesn't really make sense as it's implementation specific.
//
/// get grapheme boundaries, intended to act on a line of text, not a full text layout that has
/// both horizontal and vertial components
/// both horizontal and vertical components
pub(crate) fn get_grapheme_boundaries(
ctx: &CanvasRenderingContext2d,
text: &str,
Expand Down
2 changes: 1 addition & 1 deletion piet/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub struct FixedRadialGradient {
///
/// This is provided as a convenience, so that we can provide API that
/// accept both [`FixedLinearGradient`] and [`FixedRadialGradient`].
/// You should not construct this type dirctly; rather construct one of those
/// You should not construct this type directly; rather construct one of those
/// types, both of which impl `Into<FixedGradient>`.
#[derive(Debug, Clone)]
pub enum FixedGradient {
Expand Down
2 changes: 1 addition & 1 deletion piet/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{Color, ImageFormat, RenderContext};

/// A trait for a backend's bitmap image type.
///
/// This is cheaply clonable.
/// This is cheaply cloneable.
pub trait Image: Clone {
/// The size of the image
fn size(&self) -> Size;
Expand Down
2 changes: 1 addition & 1 deletion piet/src/render_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where
/// The region can be omitted, in which case it will apply to the entire
/// canvas.
///
/// This operation ignores any existing clipping and transforations.
/// This operation ignores any existing clipping and transformations.
///
/// # Note:
///
Expand Down
2 changes: 1 addition & 1 deletion piet/src/samples/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct Args {
scale: f64,
}

/// A shared `main` fn for diferent backends.
/// A shared `main` fn for different backends.
///
/// The important thing here is the fn argument; this should be a method that
/// takes a number and a path, executes the corresponding sample, and saves a
Expand Down
4 changes: 2 additions & 2 deletions piet/src/samples/picture_12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const SIZE: Size = Size::new(240., 280.);
static TEXT: &str = r#"The idea of "structurelessness," however, has moved from a healthy counter to those tendencies to becoming a goddess in its own right. The idea is as little examined as the term is much used, but it has become an intrinsic and unquestioned part of women's liberation ideology. For the early development of the movement this did not much matter."#;

const SELECTION_COLOR: Color = Color::rgb8(165, 205, 255);
const HILIGHT_COLOR: Color = Color::rgba8(255, 242, 54, 96);
const HIGHLIGHT_COLOR: Color = Color::rgba8(255, 242, 54, 96);

pub fn draw<R: RenderContext>(rc: &mut R) -> Result<(), Error> {
rc.clear(None, Color::WHITE);
Expand All @@ -40,7 +40,7 @@ pub fn draw<R: RenderContext>(rc: &mut R) -> Result<(), Error> {
rc.draw_text(&layout, text_pos.to_point());

for rect in sel_two {
rc.fill(rect + text_pos, &HILIGHT_COLOR);
rc.fill(rect + text_pos, &HIGHLIGHT_COLOR);
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions piet/src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::rc::Rc;
///
/// ## Defaults
///
/// Currently, the style (and its various consituent parts) have [`Default`]
/// Currently, the style (and its various constituent parts) have [`Default`]
/// impls that conform to the defaults described in the
/// [Postscript Language Manual, 3rd Edition][PLRMv3]; that document is the
/// basis for the choice of these types, and can be consulted for detailed
Expand All @@ -25,7 +25,7 @@ use std::rc::Rc;
/// ```
/// use piet::{LineJoin, StrokeStyle};
///
/// const CONST_STLYE: StrokeStyle = StrokeStyle::new()
/// const CONST_STYLE: StrokeStyle = StrokeStyle::new()
/// .dash_pattern(&[5.0, 1.0, 2.0])
/// .line_join(LineJoin::Round);
///
Expand Down
2 changes: 1 addition & 1 deletion piet/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ pub struct HitTestPosition {
/// to the baseline of the line containing that grapheme cluster.
//FIXME: maybe we should communicate more about this position? for instance
//instead of returning an x/y point, we could return the x offset, the line's y_offset,
//and the line height (everything tou would need to draw a cursor)
//and the line height (everything you would need to draw a cursor)
pub point: Point,
/// The number of the line containing this position.
///
Expand Down

0 comments on commit 342f20b

Please sign in to comment.