Didier9 Well-Known Member Licensed User Longtime User Jun 7, 2018 #1 I am using a typeface within the DrawText method on a canvas. I declare the typeface with "Dim tf As Typeface" and I use it in the DrawText call and it works, but I am getting a warning that Variable 'tf' was not initialized. There is no "Initialize" method for a typeface. How can I get rid of the error message?
I am using a typeface within the DrawText method on a canvas. I declare the typeface with "Dim tf As Typeface" and I use it in the DrawText call and it works, but I am getting a warning that Variable 'tf' was not initialized. There is no "Initialize" method for a typeface. How can I get rid of the error message?
Eme Fibonacci Well-Known Member Licensed User Longtime User Jun 7, 2018 #2 Hi, Why you declare tf? Why you just don't use typeface like that example? canvas1.DrawText("This is a nice sentence.", 200dip, 200dip, Typeface.DEFAULT_BOLD, 30, Colors.Blue, "LEFT") Upvote 0
Hi, Why you declare tf? Why you just don't use typeface like that example? canvas1.DrawText("This is a nice sentence.", 200dip, 200dip, Typeface.DEFAULT_BOLD, 30, Colors.Blue, "LEFT")
Didier9 Well-Known Member Licensed User Longtime User Jun 7, 2018 #3 Because when I do not declare it, I get "Undeclared variable 'tf' is used before it was assigned any value." and that is an error, so the code does not compile. By declaring it, I just get a warning and the code compiles and runs. Upvote 0
Because when I do not declare it, I get "Undeclared variable 'tf' is used before it was assigned any value." and that is an error, so the code does not compile. By declaring it, I just get a warning and the code compiles and runs.
Didier9 Well-Known Member Licensed User Longtime User Jun 7, 2018 #4 Didier9 said: Because when I do not declare it, I get "Undeclared variable 'tf' is used before it was assigned any value." and that is an error, so the code does not compile. By declaring it, I just get a warning and the code compiles and runs. Click to expand... Sorry, too quick of a response. Your code does work, thank you. I am not sure where I got the original code from, but this is simpler anyways. For completeness, here is how I was using it: Code: Copy Dim tf as TyeFace canvas1.DrawText("This is a nice sentence.", 200dip, 200dip, tf.CreateNew(Typeface.DEFAULT, Typeface.STYLE_NORMAL), 30, Colors.Blue, "LEFT") Thanks! Last edited: Jun 7, 2018 Upvote 0
Didier9 said: Because when I do not declare it, I get "Undeclared variable 'tf' is used before it was assigned any value." and that is an error, so the code does not compile. By declaring it, I just get a warning and the code compiles and runs. Click to expand... Sorry, too quick of a response. Your code does work, thank you. I am not sure where I got the original code from, but this is simpler anyways. For completeness, here is how I was using it: Code: Copy Dim tf as TyeFace canvas1.DrawText("This is a nice sentence.", 200dip, 200dip, tf.CreateNew(Typeface.DEFAULT, Typeface.STYLE_NORMAL), 30, Colors.Blue, "LEFT") Thanks!
Eme Fibonacci Well-Known Member Licensed User Longtime User Jun 7, 2018 #5 That code is not mine. I just copied it. In B4A autocomplete / intellisense there is the link example: (copy). Correct code 115% of the time. canvas1.DrawText... Upvote 0
That code is not mine. I just copied it. In B4A autocomplete / intellisense there is the link example: (copy). Correct code 115% of the time. canvas1.DrawText...