Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in changing font text size #1324

Open
huynhk3 opened this issue Mar 15, 2016 · 1 comment
Open

Error in changing font text size #1324

huynhk3 opened this issue Mar 15, 2016 · 1 comment

Comments

@huynhk3
Copy link

huynhk3 commented Mar 15, 2016

Certain blocks in strings do not work as intended, using the string block where it modifies the text does not actually modify the text at all.

For example, using the blocks like in the picture gives a text output of "test," but changing the size variables in the first block modifier and the width parameter in the 2nd block does not have any affect.

example4

This was a small error I've found while fooling around with Waterbear, if I've found something irrelevant or I've structured the syntax wrong, please let me know.

@huynhk3
Copy link
Author

huynhk3 commented Apr 10, 2016

Hey, quick little update here, don't mind me. After extensive testing (and googling), I've found that in the function:

setFont: function(size, fontStyle) {
                var sizeString = size[0] + size[1];
                getContext().font = sizeString + " " + fontStyle;

            },

the parameter fontStyle was actually only returning 2, as indicated in this alert box I used for debugging.

example12

I modified the code slightly in the html for the list object and text input object in the font block to have IDs so I could reference them in the changes I did to the setFont function.

example13

setFont: function(size) {
                var list = document.getElementById("fontSizeList").selectedIndex;
                var family = document.getElementById("familyText").value;
                if (list == 0) {
                  getContext().font = size + "px " + family;
                } else if (list == 1) {
                  getContext().font = size + "em " + family;
                } else if (list == 2) {
                  getContext().font = size + "% " + family;
                } else if (list == 3) {
                  getContext().font = size + "pt " + family;
                }
            },

After testing, all functionality of the font block now works, you can modify the text to whatever family and change sizes depending on px, %, em, and pt. The code is a little messy (I'm not the greatest programmer) but I hope this can be useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant