MCPcopy Create free account
hub / github.com/microsoft/SandDance / _ChromaticTextLayer

Function _ChromaticTextLayer

docs/tests/v2/es6/js/sanddance.js:144899–145134  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

144897};
144898
144899function _ChromaticTextLayer(props) {
144900 class __ChromaticTextLayer extends _base.base.deck.CompositeLayer {
144901 updateState({
144902 props,
144903 oldProps,
144904 changeFlags
144905 }) {
144906 const fontChanged = this.fontChanged(oldProps, props);
144907
144908 if (fontChanged) {
144909 this.updateFontAtlas();
144910 }
144911
144912 if (changeFlags.dataChanged || fontChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getText)) {
144913 this.transformStringToLetters();
144914 }
144915 }
144916
144917 updateFontAtlas() {
144918 const {
144919 gl
144920 } = this.context;
144921 const {
144922 fontSettings,
144923 fontFamily,
144924 fontWeight,
144925 characterSet
144926 } = this.props;
144927 const mergedFontSettings = Object.assign({}, _fontAtlas.DEFAULT_FONT_SETTINGS, fontSettings, {
144928 fontFamily,
144929 fontWeight,
144930 characterSet
144931 });
144932 const {
144933 scale,
144934 mapping,
144935 texture
144936 } = (0, _fontAtlas.makeFontAtlas)(gl, mergedFontSettings);
144937 this.setState({
144938 scale,
144939 iconAtlas: texture,
144940 iconMapping: mapping
144941 });
144942 }
144943
144944 fontChanged(oldProps, props) {
144945 if (oldProps.fontFamily !== props.fontFamily || oldProps.characterSet !== props.characterSet || oldProps.fontWeight !== props.fontWeight) {
144946 return true;
144947 }
144948
144949 if (oldProps.fontSettings === props.fontSettings) {
144950 return false;
144951 }
144952
144953 const oldFontSettings = oldProps.fontSettings || {};
144954 const fontSettings = props.fontSettings || {};
144955 return FONT_SETTINGS_PROPS.some(prop => oldFontSettings[prop] !== fontSettings[prop]);
144956 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected