当前位置:网站首页>Fabric. JS iText superscript and subscript
Fabric. JS iText superscript and subscript
2022-07-02 05:18:00 【Director of Moral Education Department】
Brief introduction
give the thumbs-up + Focus on + Collection = Learned to
<br>
For projects in Mathematical Chemistry ,“ Superscript ” and “ Subscript ” Functions are commonly used , such as Power 、 chemical element Equivalent expression , Both need superscript or subscript .
<br>
stay Fabric.js
in , Text elements have Text
、IText
and Textbox
. This article mainly explains IText
How to implement superscript and subscript of . stay Text
and Textbox
The same is true of .
<br>
<br>
Superscript
const iText = new fabric.IText('32=9', { styles: { 0: { // The first 1 That's ok 1: { // The first 2 Characters deltaY: -14, // Offset down fontSize: 24, // Set font size } }})
This example shows 3 The square of is equal to 9, To set up deltaY
negative .
deltaY
Is used to define the text baseline , Moving the baseline upward sets a positive value , Move down to set a negative value , The default is 0 .
styles
The setting of is quite special , For a word , You need to locate by line number and character subscript .
Line number and Character subscript from 0 Start , and js
It's the same as an array of .
IText
Wrap is using \n
To operate .
In this case, only 1 That's ok , So the line number is 0.
2
Where the subscript is 1
.
If you don't understand this aspect , You can see Fabric.js IText Set the specified character color and background color .
<br>
<br>
Subscript
const iText = new fabric.IText('H2O', { styles: { 0: { 1: { deltaY: 0, fontSize: 24 } } }})
In this case , I am not going to shift the subscript downward , Because it doesn't look so good , So I just set fontSize
by 24, The font size has been reduced .
<br>
<br>
summary
In fact, the method of setting superscript and subscript in this article is the same , The main process is as follows 3 Step :
- Find the corresponding character by line number and text subscript
- adopt
deltaY
Sets the text baseline for the specified character - modify
fontSize
, Make the font size of the specified character smaller than that of other characters
Complete the above 3 Step can realize the function of superscript and subscript .
<br>
In addition to the above , In fact, there is another way to set superscript and subscript , But the application scenario of that method is a little different , The next article will talk about that method .
<br>
<br>
Source warehouse
Fabric IText Superscripts and subscripts
<br>
<br>
Recommended reading
《Fabric.js IText Set the specified character color and background color 》
《Fabric.js How to use an eraser ( Including recovery function )》
《Fabric.js Draw ellipses freely 》
《Fabric.js How to use the brush ?》
give the thumbs-up + Focus on + Collection = Learned to
边栏推荐
- Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share
- Detailed explanation of Pointer use
- Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
- 删除排序数组中的重复项go语言实现
- Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
- 黑马笔记---Map集合体系
- 2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
- Black Horse Notes - - set Series Collection
- Fasttext text text classification
- 画波形图_数字IC
猜你喜欢
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
Gee series: Unit 4 data import and export in Google Earth engine
Preparation for writing SAP ui5 applications using typescript
Here comes the chicken soup! Keep this quick guide for data analysts
LS1046nfs挂载文件系统
Mysql基础---查询(1天学会mysql基础)
Fabric.js 精简JSON
[high speed bus] Introduction to jesd204b
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
随机推荐
Nodejs (02) - built in module
Fabric.js 将本地图像上传到画布背景
Preparation for writing SAP ui5 applications using typescript
国产全中文-自动化测试软件Apifox
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
Leetcode basic programming: array
设置滚动条默认样式 谷歌浏览器
Dark horse notes -- map set system
在{{}}中拼接字符
C # picture display occupancy problem
Fabric.js IText 手动设置斜体
Detailed explanation of Pointer use
Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
CubeMx DMA笔记
Find the subscript with and as the target from the array
Feign realizes file uploading and downloading
6.网络-基础
Global and Chinese market of impact roll 2022-2028: Research Report on technology, participants, trends, market size and share
7. Eleven state sets of TCP