UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

32 lines (31 loc) 1.73 kB
import { CharacterPropertyDescriptor } from '../../model/character/character-property-descriptor'; import { isNumber } from '@devexpress/utils/lib/utils/common'; import { ChangeCharacterPropertiesCommandBase } from './change-character-properties-command-base'; import { FontInfoCache } from '../../../common/model/caches/hashed-caches/font-info-cache'; export class ChangeFontNameCommand extends ChangeCharacterPropertiesCommandBase { getDescriptor() { return CharacterPropertyDescriptor.fontInfo; } DEPRECATEDConvertOptionsParameter(parameter) { if (isNumber(parameter)) return this.control.modelManager.model.cache.fontInfoCache.getItemByJsonKey(parameter); else if (typeof parameter == "string") { let fontInfo = this.control.modelManager.model.cache.fontInfoCache.getItemByName(parameter); if (fontInfo) return fontInfo; else { const mergedCharacterProperties = this.inputPosition.getMergedCharacterPropertiesFull(); if (mergedCharacterProperties.fontInfo) { fontInfo = mergedCharacterProperties.fontInfo.clone(); fontInfo.name = parameter; fontInfo.cssString = parameter.match(/^\w+\s/gi) ? "'" + parameter + "'" : parameter; if (this.modelManipulator.font.loadFontInfo(fontInfo, this.selection.activeSubDocument, this.selection.intervals, this.control.measurer)) return fontInfo; else return FontInfoCache.defaultFontInfo; } } } return this.getCurrentValue(); } }