rastertoepson drops the last band of a page when it is not full (9-pin and 24-pin)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず filter/rastertoepson.c の OutputLine()、EndPage()、OutputRows() から始め、提供された再現スクリプトをローカルフィルターに対して実行します。最終の不完全なバンドは期待される4行で出力され、Oki 9ピンの出力は、現在の実効の誤った動作に一致するのではなく、Epsonエミュレーションを選択する必要があります。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With the Epson and Oki 9-pin drivers (EPSON_9PIN, and likewise EPSON_24PIN), rastertoepson loses the last rows of a page when the page height in pixels is not a multiple of the band height. For example, US Letter at 72 dpi has an imageable height of 756 rows: 94 bands of 8 plus 4 rows, and those last 4 rows are never printed.
Cause
OutputLine() collects rows into CompBuffer (filter/rastertoepson.c, master at 4fb4b58) and copies it into LineBuffers only when a band is complete (DotBit reaching 1, from line 604). EndPage() (line 352) calls OutputRows() when DotBit < 128, but OutputRows() prints LineBuffers, which do not yet hold the partial band, so it sends only a line feed. The partial band is still in CompBuffer when the page ends.
To Reproduce
The script below fills a Letter page with black and runs it through epson9.ppd at 60x72dpi, one pass per band. It needs only CUPS (cupsfilter, cups-driverd) and Python 3:
raster rows: 756 = 94 bands of 8 + 4 rows
bit images sent: 94
dots in the last image: [255] (0xFF is all 8 pins)
rows printed: 752, rows lost: 4
The same output comes from macOS's CUPS 2.3.4 filter and from filter/rastertoepson.c at master (4fb4b58), built against the system libcups.
repro.py
"""Reproduce two rastertoepson bugs with CUPS's own sample drivers.
Usage: python3 repro.py [path/to/rastertoepson]
Prints a page filled with black through the Epson 9-pin driver at
60x72dpi on Letter, and through the Oki 9-pin driver.
"""
import os
import struct
import subprocess
import sys
from pathlib import Path
serverbin = Path(subprocess.run(["cups-config", "--serverbin"], capture_output=True,
text=True, check=True).stdout.strip())
rastertoepson = sys.argv[1] if len(sys.argv) > 1 else str(serverbin / "filter" / "rastertoepson")
# A US Letter PDF filled with black.
content = b"0 0 612 792 re f"
objects = [
b"<< /Type /Catalog /Pages 2 0 R >>",
b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R >>",
b"<< /Length %d >>\nstream\n%s\nendstream" % (len(content), content),
]
pdf = bytearray(b"%PDF-1.4\n")
offsets = []
for number, body in enumerate(objects, 1):
offsets.append(len(pdf))
pdf += b"%d 0 obj\n%s\nendobj\n" % (number, body)
xref = len(pdf)
pdf += b"xref\n0 %d\n0000000000 65535 f \n" % (len(objects) + 1)
pdf += b"".join(b"%010d 00000 n \n" % o for o in offsets)
pdf += b"trailer\n<< /Size %d /Root 1 0 R >>\nstartxref\n%d\n%%%%EOF\n" % (len(objects) + 1, xref)
Path("black.pdf").write_bytes(pdf)
def run(ppd_name, resolution):
ppd = subprocess.run([str(serverbin / "daemon" / "cups-driverd"), "cat",
f"drv:///sample.drv/{ppd_name}.ppd"],
capture_output=True, check=True).stdout
Path(f"{ppd_name}.ppd").write_bytes(ppd)
options = ["-o", "PageSize=Letter", "-o", f"Resolution={resolution}"]
raster = subprocess.run(["cupsfilter", "-p", f"{ppd_name}.ppd", "-m",
"application/vnd.cups-raster", *options, "black.pdf"],
capture_output=True, check=True).stdout
Path(f"{ppd_name}.ras").write_bytes(raster)
out = subprocess.run([rastertoepson, "1", "user", "title", "1", "", f"{ppd_name}.ras"],
capture_output=True, check=True,
env={**os.environ, "PPD": f"{ppd_name}.ppd"}).stdout
return raster, out
# Bug 1: the last band of a page is dropped when it holds fewer than 8 rows.
raster, out = run("epson9", "60x72dpi")
order = ">" if raster[:4] in (b"RaS2", b"RaS3") else "<"
height = struct.unpack_from(order + "I", raster, 4 + 376)[0]
images, i = [], 0
while (i := out.find(b"\x1b*", i)) >= 0: # ESC * m nL nH data
n = out[i + 3] | out[i + 4] << 8
images.append(out[i + 5 : i + 5 + n])
i += 5 + n
print(f"raster rows: {height} = {height // 8} bands of 8 + {height % 8} rows")
print(f"bit images sent: {len(images)}")
print(f"dots in the last image: {sorted(set(images[-1]))[:4]} (0xFF is all 8 pins)")
print(f"rows printed: {8 * len(images)}, rows lost: {height - 8 * len(images)}")
# Bug 2: the Oki driver never selects Epson emulation.
_, oki = run("okidata9", "120x72dpi")
_, epson = run("epson9", "120x72dpi")
print(f"\nokidata9 output starts: {oki[:6].hex(' ')} (ESC {{ A would be 1b 7b 41)")
print(f"okidata9 output identical to epson9: {oki == epson}")
Expected behavior
A 95th bit image with the last 4 rows (bytes 0xF0 here), as EndPage() intends.
System Information:
- OS: macOS 14.6 (CUPS 2.3.4); the code is unchanged at master
- 主要言語
- C
- スター
- 1.8k
- フォーク
- 373
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenPrinting/cups のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
OpenPrinting/cups#1844 ·
メンテナーはふだん 1 日以内に返信
-
OAuth (bearer) quota check denies every user when the allowed-user list is empty対応中かも @RonitMehta08 が 16 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
OpenPrinting/cups#1795 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
cupsdGetPrivateAttrs: @ACL never grants access, and @OWNER is looked up as an operating-system group for non-owners対応中かも @user-Param が 23 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
OpenPrinting/cups#1796 ·
メンテナーはふだん 1 日以内に返信
-
OAuth/OIDC token-validation gaps: nonce not enforced when absent, at_hash alg, inbound bearer not signature/aud/exp-validated + unverified email used for authz再び着手できるかも @michaelrsweet が 161 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンinvestigating
OpenPrinting/cups#1609 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
OpenPrinting/cups#1572 ·
メンテナーはふだん 1 日以内に返信
OpenPrinting/cups の issue をすべて見る
似ている issue
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
389ds/389-ds-base#8251 ·
メンテナーはふだん 1 日以内に返信
-
bug data-types
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/clickhouse-cpp#645 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信