Skip to content

Commit 05ccd4c

Browse files
authored
SF-2639 Use project-specified font wherever vernacular text is shown (#3525)
1 parent 84d060e commit 05ccd4c

17 files changed

+81
-12
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-answers.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h3 id="totalAnswersMessage">
9393
}
9494
@if (answer.scriptureText) {
9595
<div class="answer-scripture" dir="auto">
96-
<span class="answer-scripture-text">{{
96+
<span class="answer-scripture-text" [style.--project-font]="projectFont">{{
9797
(answer.selectionStartClipped ? "…" : "") +
9898
(answer.scriptureText || "") +
9999
(answer.selectionEndClipped ? "…" : "")

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-answers.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
}
146146

147147
.answer-scripture-text {
148+
font-family: var(--project-font);
148149
padding-block: 6px;
149150
}
150151

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-answers.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { toVerseRef, VerseRefData } from 'realtime-server/lib/esm/scriptureforge
2020
import { firstValueFrom, Subscription } from 'rxjs';
2121
import { DialogService } from 'xforge-common/dialog.service';
2222
import { FileService } from 'xforge-common/file.service';
23+
import { FontService } from 'xforge-common/font.service';
2324
import { I18nService } from 'xforge-common/i18n.service';
2425
import { FileType } from 'xforge-common/models/file-offline-data';
2526
import { NoticeService } from 'xforge-common/notice.service';
@@ -110,6 +111,7 @@ export class CheckingAnswersComponent implements OnInit {
110111
verseRef?: VerseRef;
111112
answersHighlightStatus: Map<string, boolean> = new Map<string, boolean>();
112113
submittingAnswer: boolean = false;
114+
projectFont?: string;
113115

114116
/** IDs of answers to show to user (so, excluding unshown incoming answers). */
115117
private _answersToShow: string[] = [];
@@ -130,6 +132,7 @@ export class CheckingAnswersComponent implements OnInit {
130132
private readonly questionDialogService: QuestionDialogService,
131133
private readonly i18n: I18nService,
132134
private readonly fileService: FileService,
135+
private readonly fontService: FontService,
133136
private readonly onlineStatusService: OnlineStatusService,
134137
private readonly projectService: SFProjectService,
135138
private destroyRef: DestroyRef
@@ -154,6 +157,7 @@ export class CheckingAnswersComponent implements OnInit {
154157
this.setProjectAdmin();
155158
});
156159
this.setProjectAdmin();
160+
this.projectFont = this.fontService.getFontFamilyFromProject(projectProfileDoc);
157161
}
158162

159163
@Input() set questionDoc(questionDoc: QuestionDoc | undefined) {

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-answers/checking-input-form/checking-input-form.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Comment } from 'realtime-server/lib/esm/scriptureforge/models/comment';
55
import { SFProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project';
66
import { VerseRefData } from 'realtime-server/lib/esm/scriptureforge/models/verse-ref-data';
77
import { DialogService } from 'xforge-common/dialog.service';
8+
import { FontService } from 'xforge-common/font.service';
89
import { I18nService } from 'xforge-common/i18n.service';
910
import { Breakpoint, MediaBreakpointService } from 'xforge-common/media-breakpoints/media-breakpoint.service';
1011
import { NoticeService } from 'xforge-common/notice.service';
@@ -60,6 +61,7 @@ export class CheckingInputFormComponent {
6061
constructor(
6162
readonly noticeService: NoticeService,
6263
private readonly dialogService: DialogService,
64+
private readonly fontService: FontService,
6365
private readonly i18n: I18nService,
6466
private readonly breakpointObserver: BreakpointObserver,
6567
private readonly mediaBreakpointService: MediaBreakpointService,
@@ -98,6 +100,7 @@ export class CheckingInputFormComponent {
98100
chapterNum: (this.verseRef && this.verseRef.chapterNum) || verseRef.chapterNum,
99101
textsByBookId: this.textsByBookId,
100102
projectId: this._questionDoc.data.projectRef,
103+
projectFont: this.fontService.getFontFamilyFromProject(this.project),
101104
isRightToLeft: this.project?.isRightToLeft,
102105
selectedText: this.selectedText || '',
103106
selectedVerses: this.verseRef

src/SIL.XForge.Scripture/ClientApp/src/app/text-chooser-dialog/text-chooser-dialog.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ <h2>{{ bookName }} {{ chapterNum }}</h2>
1212
[id]="textDocId"
1313
[multiSegmentSelection]="true"
1414
[isRightToLeft]="isTextRightToLeft"
15+
[style.--project-font]="projectFont"
1516
></app-text>
16-
<div class="selection-preview">
17+
<div class="selection-preview" [style.--project-font]="projectFont">
1718
<p dir="auto">
1819
{{ (startClipped ? "…" : "") + (selectedText || "") + (endClipped ? "…" : "") }}
1920
<span class="selection-reference">{{ referenceForDisplay }}</span>

src/SIL.XForge.Scripture/ClientApp/src/app/text-chooser-dialog/text-chooser-dialog.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ app-text {
3333
}
3434

3535
.selection-preview {
36+
font-family: var(--project-font);
3637
height: 16em;
3738
overflow-y: scroll;
3839
margin-top: 1em;

src/SIL.XForge.Scripture/ClientApp/src/app/text-chooser-dialog/text-chooser-dialog.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TextComponent } from '../shared/text/text.component';
1818
export interface TextChooserDialogData {
1919
bookNum: number;
2020
chapterNum: number;
21+
projectFont?: string;
2122
projectId: string;
2223
textsByBookId: TextsByBookId;
2324
isRightToLeft?: boolean;
@@ -81,6 +82,10 @@ export class TextChooserDialogComponent {
8182
return this.i18n.localizeBook(this.bookNum);
8283
}
8384

85+
get projectFont(): string {
86+
return this.data.projectFont ?? '';
87+
}
88+
8489
get isTextRightToLeft(): boolean {
8590
return this.data.isRightToLeft == null ? false : this.data.isRightToLeft;
8691
}

src/SIL.XForge.Scripture/ClientApp/src/app/translate/biblical-terms/biblical-terms.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
overflow: hidden;
5151
}
5252

53+
/* Show the term renderings in the project font */
54+
.mat-column-renderings {
55+
font-family: var(--project-font);
56+
}
57+
5358
/* Disable hover effects for disabled buttons */
5459
.mat-mdc-icon-button:disabled {
5560
pointer-events: none;

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-history/editor-history.component.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
22
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
33
import Quill from 'quill';
4+
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
45
import { TextData } from 'realtime-server/lib/esm/scriptureforge/models/text-data';
56
import { Subject } from 'rxjs';
67
import { anything, mock, when } from 'ts-mockito';
@@ -10,6 +11,7 @@ import { OnlineStatusService } from 'xforge-common/online-status.service';
1011
import { TestOnlineStatusModule } from 'xforge-common/test-online-status.module';
1112
import { TestOnlineStatusService } from 'xforge-common/test-online-status.service';
1213
import { configureTestingModule } from 'xforge-common/test-utils';
14+
import { SFProjectProfileDoc } from '../../../core/models/sf-project-profile-doc';
1315
import { TextDoc, TextDocId } from '../../../core/models/text-doc';
1416
import { Revision } from '../../../core/paratext.service';
1517
import { SFProjectService } from '../../../core/sf-project.service';
@@ -67,6 +69,19 @@ describe('EditorHistoryComponent', () => {
6769
expect(component.revisionSelect.emit).not.toHaveBeenCalled();
6870
});
6971

72+
it('should load the project document when the project id is set', fakeAsync(() => {
73+
const testProjectId = 'test_project_id';
74+
const projectDoc = { data: createTestProjectProfile(), id: testProjectId } as SFProjectProfileDoc;
75+
when(mockSFProjectService.getProfile(testProjectId)).thenReturn(Promise.resolve(projectDoc));
76+
expect(component.projectDoc).toBeUndefined();
77+
78+
component.projectId = testProjectId;
79+
tick();
80+
81+
expect(component.projectId).toBe(testProjectId);
82+
expect(component.projectDoc).toBe(projectDoc);
83+
}));
84+
7085
it('should load history after view init', fakeAsync(() => {
7186
const revision: Revision = { timestamp: 'date_here' };
7287
const textDoc: TextDoc = { data: { ops: [] } } as unknown as TextDoc;

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-history/editor-history.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,22 @@ import { HistoryChooserComponent, RevisionSelectEvent } from './history-chooser/
2929
standalone: false
3030
})
3131
export class EditorHistoryComponent implements OnChanges, OnInit, AfterViewInit {
32-
@Input() projectId?: string;
32+
private _projectId?: string | undefined;
33+
34+
@Input()
35+
public get projectId(): string | undefined {
36+
return this._projectId;
37+
}
38+
public set projectId(value: string | undefined) {
39+
this._projectId = value;
40+
if (value != null) {
41+
this.projectService.getProfile(value).then(
42+
p => (this.projectDoc = p),
43+
() => (this.projectDoc = undefined)
44+
);
45+
}
46+
}
47+
3348
@Input() bookNum?: number;
3449
@Input() chapter?: number;
3550
@Input() isRightToLeft!: boolean;

0 commit comments

Comments
 (0)