Skip to content

SVG画像の表示サイズとコンテンツの軽微な修正 #26012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025

Conversation

na3shkw
Copy link
Contributor

@na3shkw na3shkw commented Feb 24, 2025

Description

Motivation

Additional details

#25551 の修正

154713e で、<svg> 要素から width 属性を削除しました。画像が小さく表示される原因が <svg> 要素の width 属性に単位が % の値が指定されているためです。

rari ではローカル画像のサイズを取得して <img> 要素の width および height 属性の値として設定する処理が行われます。画像の幅は svg-metadata クレートを利用して取得されるメタデータを利用しています。このクレートでは width 属性値の単位が % の場合は viewBox 属性の値をもとに幅を計算する width メソッドが提供されています。しかし、rari はこのメソッドではなく Width 構造体width の値を直接利用しているために単位が無視され、100%100 と解釈されてしまっています。

英語版でこの問題が起こらないのは、<img> 要素への width および height の設定をあくまで同一ホストから提供される画像に限定しているためのようです(英語版の画像は mdn.github.io でホストされています)。

rari 側の問題ですが、現時点ではコントリビューションを受け付けていないため svg を変更して対応します。この修正を適用すると viewBox 属性で指定された幅と高さが利用されます

文字がはみ出さないような図形のサイズの調整

c1fef84 で、該当の <rect> の幅および横位置を変更しました。

Related issues and pull requests

Fixes #25551

@na3shkw na3shkw requested a review from a team as a code owner February 24, 2025 04:48
@na3shkw na3shkw requested review from potappo and removed request for a team February 24, 2025 04:48
@github-actions github-actions bot added the l10n-ja Issues related to Japanese content. label Feb 24, 2025
Copy link
Collaborator

@mfuji09 mfuji09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良いと思います。ありがとうございました。

@mfuji09 mfuji09 merged commit 3cc7789 into mdn:main Feb 28, 2025
4 checks passed
@na3shkw na3shkw deleted the fix-ja-svg-image-size branch February 28, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
l10n-ja Issues related to Japanese content.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

「オリジン間リソース共有 (CORS)」のページで SVG 画像が小さく表示されてしまっている
2 participants