I am working on a shadow js application and I need to increase / decrease the font size when changing the font size with the mouse
my verified code
var canvas = new fabric.Canvas('canvas'); $(document).ready(function() { $('#text-font-size').keyup(function() { var val = $(this).val(); if (isNaN(val)) { alert('please enter number'); $(this).val(''); } var activeObject = canvas.getActiveObject(); activeObject.fontSize = val; canvas.renderAll(); }); $('#add-text-btn').click(function() { if ($('#text-font-size').val()) { var txtfontsize = $('#text-font-size').val(); } else { var txtfontsize = 40; } var message = $('#add-text-value').val();
<script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.5.0/fabric.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="add-text-btn">Add text</button><br><br> <textarea rows="7" id="add-text-value">Your Text Here</textarea> <br> <input id="text-font-size" type="text" class="form-control"> <canvas id='canvas' width="500" height="400" style="border:#000 1px solid;"></canvas>
but it just rescales the text without increasing / decreasing the font size, but I need to change the font size, as in this
source share