Fix bugs across all crates
This commit is contained in:
@@ -198,7 +198,7 @@ fn render_text_to_image(
|
||||
opacity: f32,
|
||||
) -> image::RgbaImage {
|
||||
let scale = ab_glyph::PxScale::from(font_size);
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 1.0) as u32).saturating_add(4).min(16384);
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 0.6) as u32).saturating_add(4).min(16384);
|
||||
let text_height = ((font_size.min(1000.0) * 1.4) as u32).saturating_add(4).min(4096);
|
||||
|
||||
let alpha = (opacity * 255.0).clamp(0.0, 255.0) as u8;
|
||||
@@ -296,7 +296,7 @@ fn apply_text_watermark(
|
||||
} else {
|
||||
// No rotation - draw text directly (faster)
|
||||
let scale = ab_glyph::PxScale::from(font_size);
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 1.0) as u32).saturating_add(4).min(16384);
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 0.6) as u32).saturating_add(4).min(16384);
|
||||
let text_height = ((font_size.min(1000.0) * 1.4) as u32).saturating_add(4).min(4096);
|
||||
let text_dims = Dimensions {
|
||||
width: text_width,
|
||||
@@ -351,9 +351,9 @@ fn apply_tiled_text_watermark(
|
||||
let tw = tile.width();
|
||||
let th = tile.height();
|
||||
|
||||
let mut y: i64 = spacing as i64;
|
||||
let mut y: i64 = 0;
|
||||
while y < ih as i64 {
|
||||
let mut x: i64 = spacing as i64;
|
||||
let mut x: i64 = 0;
|
||||
while x < iw as i64 {
|
||||
image::imageops::overlay(&mut rgba, &tile, x, y);
|
||||
x += tw as i64 + spacing as i64;
|
||||
@@ -366,12 +366,12 @@ fn apply_tiled_text_watermark(
|
||||
let alpha = (opacity * 255.0).clamp(0.0, 255.0) as u8;
|
||||
let draw_color = Rgba([color[0], color[1], color[2], alpha]);
|
||||
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 1.0) as i64 + 4).min(16384);
|
||||
let text_width = ((text.chars().count().min(10_000) as f32 * font_size.min(1000.0) * 0.6) as i64 + 4).min(16384);
|
||||
let text_height = ((font_size.min(1000.0) * 1.4) as i64 + 4).min(4096);
|
||||
|
||||
let mut y = spacing as i64;
|
||||
let mut y: i64 = 0;
|
||||
while y < ih as i64 {
|
||||
let mut x = spacing as i64;
|
||||
let mut x: i64 = 0;
|
||||
while x < iw as i64 {
|
||||
draw_text_mut(&mut rgba, draw_color, x as i32, y as i32, scale, &font, text);
|
||||
x += text_width + spacing as i64;
|
||||
@@ -413,9 +413,9 @@ fn apply_tiled_image_watermark(
|
||||
let mut base = img.into_rgba8();
|
||||
let (iw, ih) = (base.width(), base.height());
|
||||
|
||||
let mut ty = spacing;
|
||||
let mut ty = 0u32;
|
||||
while ty < ih {
|
||||
let mut tx = spacing;
|
||||
let mut tx = 0u32;
|
||||
while tx < iw {
|
||||
for oy in 0..oh {
|
||||
for ox in 0..ow {
|
||||
|
||||
Reference in New Issue
Block a user