MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / _fontSizeLineHeight

Method _fontSizeLineHeight

packages/alphatab/src/model/Font.ts:146–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 }
145
146 private _fontSizeLineHeight() {
147 if (!this._currentToken) {
148 throw new Error('Missing font size');
149 }
150
151 const parts = this._currentToken.text.split('/');
152 if (parts.length >= 3) {
153 throw new Error(`Invalid font size '${this._currentToken}' specified`);
154 }
155
156 this._nextToken();
157
158 if (parts.length >= 2) {
159 if (parts[1] === '/') {
160 // size/ line-height (space after slash)
161 if (!this._currentToken) {
162 throw new Error('Missing line-height after font size');
163 }
164 this.lineHeight = this._currentToken.text;
165 this._nextToken();
166 } else {
167 // size/line-height (no spaces)
168 this.size = parts[0];
169 this.lineHeight = parts[1];
170 }
171 } else if (parts.length >= 1) {
172 this.size = parts[0];
173
174 if (this._currentToken && this._currentToken.text.indexOf('/') === 0) {
175 // size / line-height (with spaces befor and after slash)
176 if (this._currentToken.text === '/') {
177 this._nextToken();
178 if (!this._currentToken) {
179 throw new Error('Missing line-height after font size');
180 }
181 this.lineHeight = this._currentToken.text;
182 this._nextToken();
183 } else {
184 this.lineHeight = this._currentToken.text.substr(1);
185 this._nextToken();
186 }
187 }
188 } else {
189 throw new Error('Missing font size');
190 }
191 }
192
193 private _nextToken() {
194 this._currentTokenIndex++;

Callers 1

parseMethod · 0.95

Calls 2

_nextTokenMethod · 0.95
indexOfMethod · 0.45

Tested by

no test coverage detected