(oldStyle, newStyle)
| 39158 | } |
| 39159 | |
| 39160 | function changeStyle(oldStyle, newStyle) { |
| 39161 | var ctxFont = "" + context.font; |
| 39162 | |
| 39163 | if(styletags.subscripts === true) { |
| 39164 | var oldIndex_Sub = oldStyle.indexOf(CHR_sub0); |
| 39165 | var newIndex_Sub = newStyle.indexOf(CHR_sub0); |
| 39166 | |
| 39167 | var oldSub = (oldIndex_Sub > -1) ? parseInt(oldStyle[1 + oldIndex_Sub]) : 0; |
| 39168 | var newSub = (newIndex_Sub > -1) ? parseInt(newStyle[1 + newIndex_Sub]) : 0; |
| 39169 | |
| 39170 | if(oldSub !== newSub) { |
| 39171 | ctxFont = ctxFont.replace(getTextFontSize(), "?px ") |
| 39172 | zPos *= Math.pow(0.75, (newSub - oldSub)) |
| 39173 | ctxFont = ctxFont.replace("?px ", getTextFontSize()) |
| 39174 | } |
| 39175 | yPos += 0.25 * lineHeight * (newSub - oldSub); |
| 39176 | } |
| 39177 | |
| 39178 | if(styletags.superscripts === true) { |
| 39179 | var oldIndex_Super = oldStyle.indexOf(CHR_super0); |
| 39180 | var newIndex_Super = newStyle.indexOf(CHR_super0); |
| 39181 | |
| 39182 | var oldSuper = (oldIndex_Super > -1) ? parseInt(oldStyle[1 + oldIndex_Super]) : 0; |
| 39183 | var newSuper = (newIndex_Super > -1) ? parseInt(newStyle[1 + newIndex_Super]) : 0; |
| 39184 | |
| 39185 | if(oldSuper !== newSuper) { |
| 39186 | ctxFont = ctxFont.replace(getTextFontSize(), "?px ") |
| 39187 | zPos *= Math.pow(0.75, (newSuper - oldSuper)) |
| 39188 | ctxFont = ctxFont.replace("?px ", getTextFontSize()) |
| 39189 | } |
| 39190 | yPos -= 0.25 * lineHeight * (newSuper - oldSuper); |
| 39191 | } |
| 39192 | |
| 39193 | if(styletags.bolds === true) { |
| 39194 | var wasBold = (oldStyle.indexOf(CHR_bold) > -1) |
| 39195 | var is_Bold = (newStyle.indexOf(CHR_bold) > -1) |
| 39196 | |
| 39197 | if(!wasBold && is_Bold) { |
| 39198 | if(wasItalic) { |
| 39199 | ctxFont = ctxFont.replace("italic ", "italic bold ") |
| 39200 | } else { |
| 39201 | ctxFont = "bold " + ctxFont |
| 39202 | } |
| 39203 | } |
| 39204 | if(wasBold && !is_Bold) { |
| 39205 | ctxFont = ctxFont.replace("bold ", '') |
| 39206 | } |
| 39207 | } |
| 39208 | |
| 39209 | if(styletags.italics === true) { |
| 39210 | var wasItalic = (oldStyle.indexOf(CHR_italic) > -1) |
| 39211 | var is_Italic = (newStyle.indexOf(CHR_italic) > -1) |
| 39212 | |
| 39213 | if(!wasItalic && is_Italic) { |
| 39214 | ctxFont = "italic " + ctxFont |
| 39215 | } |
| 39216 | if(wasItalic && !is_Italic) { |
| 39217 | ctxFont = ctxFont.replace("italic ", '') |
no test coverage detected
searching dependent graphs…