Skip to content

Commit

Permalink
Improve icons in PDF song details
Browse files Browse the repository at this point in the history
  • Loading branch information
Desbeers committed Feb 17, 2025
1 parent d69ce23 commit a43677c
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 26 deletions.
14 changes: 11 additions & 3 deletions Chord Provider/PDFBuild/SongElements/PDFBuild+SongDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ extension PDFBuild {
if let time = song.metadata.time {
items.append(detailLabel(icon: "time", label: time))
}
if let tempo = song.metadata.tempo {
items.append(detailLabel(icon: "tempo", label: "\(tempo) bpm"))
}
/// Draw the details
let textBounds = items.boundingRect(with: rect.size, options: .usesLineFragmentOrigin)
if !calculationOnly {
Expand All @@ -59,11 +62,16 @@ extension PDFBuild {
private func detailLabel(icon: String, label: String) -> NSAttributedString {
let imageAttachment = NSTextAttachment()
imageAttachment.image = NSImage(named: icon)
let imageSize = imageAttachment.image?.size ?? .init()
imageAttachment.bounds = CGRect(
x: CGFloat(0),
y: (NSFont.systemFont(ofSize: 8, weight: .regular).capHeight - imageSize.height) / 2,
width: imageSize.width,
height: imageSize.height
)
let result = NSMutableAttributedString()
result.append(NSAttributedString(attachment: imageAttachment, attributes: .alignment(.center)))
result.append(NSAttributedString(string: " "))
result.append(NSAttributedString(string: label, attributes: .songDetailLabel))
result.append(NSAttributedString(string: " "))
result.append(NSAttributedString(string: " \(label) ", attributes: .songDetailLabel))
return result
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "paperclip-svgrepo-com.svg",
"filename" : "capo.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "acoustic-guitar-illustration-1-svgrepo-com.svg",
"filename" : "instrument.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "key-svgrepo-com.svg",
"filename" : "key.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "tempo.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "time-svgrepo-com.svg",
"filename" : "time.svg",
"idiom" : "universal"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a43677c

Please sign in to comment.