Skip to content

Commit

Permalink
Move free text annotation general parameters to AnnotationsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Aug 23, 2024
1 parent b433a3d commit 487210d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Zotero/Controllers/AnnotationConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct AnnotationConverter {
paths = []
} else if let annotation = annotation as? PSPDFKit.FreeTextAnnotation {
type = .freeText
let roundedFontSize = round(annotation.fontSize * 2) / 2
let roundedFontSize = AnnotationsConfig.roundFreeTextAnnotationFontSize(annotation.fontSize)
fontSize = roundedFontSize
rotation = annotation.rotation
paths = []
Expand Down
7 changes: 7 additions & 0 deletions Zotero/Models/AnnotationsConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ struct AnnotationsConfig {
static let keyKey = "Zotero:Key"
// Line width of image annotation in PDF document.
static let imageAnnotationLineWidth: CGFloat = 2
// Free text annotation font size minimum, maximum, increment and rounding
static let freeTextAnnotationFontSizeMinimum: CGFloat = 1
static let freeTextAnnotationFontSizeMaximum: CGFloat = 200
static let freeTextAnnotationFontSizeIncrement: CGFloat = 0.5
static func roundFreeTextAnnotationFontSize(_ fontSize: CGFloat) -> CGFloat {
round(fontSize * 2) / 2
}
// Size of note annotation in PDF document.
static let noteAnnotationSize: CGSize = CGSize(width: 22, height: 22)
static let positionSizeLimit = 65000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ final class FontSizeView: UIView {
private func setup() {
let stepper = UIStepper()
stepper.isHidden = !stepperEnabled
stepper.stepValue = 0.5
stepper.minimumValue = 1
stepper.maximumValue = 200
stepper.stepValue = AnnotationsConfig.freeTextAnnotationFontSizeIncrement
stepper.minimumValue = AnnotationsConfig.freeTextAnnotationFontSizeMinimum
stepper.maximumValue = AnnotationsConfig.freeTextAnnotationFontSizeMaximum
stepper.rx.controlEvent(.valueChanged)
.observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ final class PDFReaderActionHandler: ViewModelActionHandler, BackgroundDbProcessi
}

if editFontSize {
let roundedFontSize = round(textAnnotation.fontSize * 2) / 2
let roundedFontSize = AnnotationsConfig.roundFreeTextAnnotationFontSize(textAnnotation.fontSize)
requests.append(EditAnnotationFontSizeDbRequest(key: key, libraryId: viewModel.state.library.identifier, size: roundedFontSize))
}
} else if hasChanges([.boundingBox, .rects]), let rects = AnnotationConverter.rects(from: annotation) {
Expand Down

0 comments on commit 487210d

Please sign in to comment.