Skip to content

Commit

Permalink
Fixed point and segment marker font defaults
Browse files Browse the repository at this point in the history
The fontFamily, fontSize, and fontStyle options weren't
being used

See #551
  • Loading branch information
chrisn committed Oct 19, 2024
1 parent 1358068 commit 98959c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
11 changes: 4 additions & 7 deletions src/points-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import PointMarker from './point-marker';
import { clamp, objectHasProperty } from './utils';
import Konva from 'konva/lib/Core';

const defaultFontFamily = 'sans-serif';
const defaultFontSize = 10;
const defaultFontShape = 'normal';

/**
* Creates a Konva.Layer that displays point markers against the audio
* waveform.
Expand Down Expand Up @@ -144,14 +140,15 @@ PointsLayer.prototype._onPointsRemoveAll = function() {

PointsLayer.prototype._createPointMarker = function(point) {
const editable = this._enableEditing && point.editable;
const viewOptions = this._view.getViewOptions();

const marker = this._peaks.options.createPointMarker({
point: point,
editable: editable,
color: point.color,
fontFamily: this._peaks.options.fontFamily || defaultFontFamily,
fontSize: this._peaks.options.fontSize || defaultFontSize,
fontStyle: this._peaks.options.fontStyle || defaultFontShape,
fontFamily: viewOptions.fontFamily,
fontSize: viewOptions.fontSize,
fontStyle: viewOptions.fontStyle,
layer: this,
view: this._view.getName()
});
Expand Down
28 changes: 13 additions & 15 deletions src/segment-shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import SegmentMarker from './segment-marker';
import WaveformShape from './waveform-shape';
import { clamp } from './utils';

const defaultFontFamily = 'sans-serif';
const defaultFontSize = 10;
const defaultFontShape = 'normal';

/**
* Options that control segments' visual appearance
*
Expand Down Expand Up @@ -67,7 +63,8 @@ function SegmentShape(segment, peaks, layer, view) {
this._draggable = this._segment.editable && this._view.isSegmentDraggingEnabled();
this._dragging = false;

const segmentOptions = view.getViewOptions().segmentOptions;
const viewOptions = view.getViewOptions();
const segmentOptions = viewOptions.segmentOptions;

this._overlayOffset = segmentOptions.overlayOffset;

Expand Down Expand Up @@ -100,9 +97,9 @@ function SegmentShape(segment, peaks, layer, view) {
segment: segment,
view: this._view.getName(),
layer: this._layer,
fontFamily: this._peaks.options.fontFamily,
fontSize: this._peaks.options.fontSize,
fontStyle: this._peaks.options.fontStyle
fontFamily: viewOptions.fontFamily,
fontSize: viewOptions.fontSize,
fontStyle: viewOptions.fontStyle
});

if (this._label) {
Expand Down Expand Up @@ -200,7 +197,8 @@ function createOverlayMarker(options) {

SegmentShape.prototype._createMarkers = function() {
const editable = this._layer.isEditingEnabled() && this._segment.editable;
const segmentOptions = this._view.getViewOptions().segmentOptions;
const viewOptions = this._view.getViewOptions();
const segmentOptions = viewOptions.segmentOptions;

let createSegmentMarker, startMarker, endMarker;

Expand All @@ -217,9 +215,9 @@ SegmentShape.prototype._createMarkers = function() {
editable: editable,
startMarker: true,
color: segmentOptions.startMarkerColor,
fontFamily: this._peaks.options.fontFamily || defaultFontFamily,
fontSize: this._peaks.options.fontSize || defaultFontSize,
fontStyle: this._peaks.options.fontStyle || defaultFontShape,
fontFamily: viewOptions.fontFamily,
fontSize: viewOptions.fontSize,
fontStyle: viewOptions.fontStyle,
layer: this._layer,
view: this._view.getName(),
segmentOptions: this._view.getViewOptions().segmentOptions
Expand Down Expand Up @@ -247,9 +245,9 @@ SegmentShape.prototype._createMarkers = function() {
editable: editable,
startMarker: false,
color: segmentOptions.endMarkerColor,
fontFamily: this._peaks.options.fontFamily || defaultFontFamily,
fontSize: this._peaks.options.fontSize || defaultFontSize,
fontStyle: this._peaks.options.fontStyle || defaultFontShape,
fontFamily: viewOptions.fontFamily,
fontSize: viewOptions.fontSize,
fontStyle: viewOptions.fontStyle,
layer: this._layer,
view: this._view.getName(),
segmentOptions: this._view.getViewOptions().segmentOptions
Expand Down

0 comments on commit 98959c5

Please sign in to comment.