Skip to content
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

Improve text rendering #1222

Merged
merged 8 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/templates/iframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod tests {
use super::*;

#[test]
fn preview() {
fn thumbnail() {
assert_regex_match!(
Iframe::thumbnail(inscription_id(1))
.0.to_string(),
Expand Down
20 changes: 20 additions & 0 deletions static/preview-text.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
html {
background-color: #131516;
color: white;
font-size: 16px;
height: 100%;
line-height: 1;
}

body {
display: grid;
grid-template: 1fr / 1fr;
height: 100%;
margin: 0;
place-items: center;
}

pre {
margin: 0;
}

body > * {
grid-column: 1 / 1;
grid-row: 1 / 1;
}

body > pre {
opacity: 0;
}
6 changes: 6 additions & 0 deletions static/preview-text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let pre = document.querySelector('body > pre');
let { width, height } = pre.getBoundingClientRect();
let columns = width / 16;
let rows = height / 16;
pre.style.fontSize = `min(${95/columns}vw, ${95/rows}vh)`;
pre.style.opacity = 1;
4 changes: 4 additions & 0 deletions templates/preview-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
<meta charset=utf-8>
<meta name=format-detection content='telephone=no'>
<link href=/static/preview-text.css rel=stylesheet>
<script src=/static/preview-text.js defer></script>
</head>
<body>
<pre>{{self.text}}</pre>
<noscript>
<pre>{{self.text}}</pre>
</noscript>
</body>
</html>