drawtext

Draw text vertically on canvas

风格不统一 提交于 2019-11-29 07:35:06
I would like to learn how to draw vertical text on the canvas. Sorry for maybe stupid question, but I can not solve this problem. I can do so: if (i ==10) { this_str2 = "0.00"; } canvas.save(); canvas.rotate(-90,190,90); canvas.drawText(this_str2, x_guide +50, drawSizes[1] + drawSizes[3] - (i * drawSizes[3] / 10) +20, paint); canvas.restore(); } But it is not properly displayed on the X and Y is any other solution to this problem 7 Try this custom textview, I don't remember where I took if from (here in StackOverflow), if any one remembers, please post a link in the comments. import android

Android: Canvas.drawText() text size on different screen resolutions

不羁岁月 提交于 2019-11-28 18:13:38
For my Android game I have some calls to Canvas.drawText() . For testing, I use the standard font size which seems to be working fine. However, when I bump up the resolution to a higher density, the larger images are automatically loaded but the text is now incredibly small. Is there an easy way to calculate what size the text should be drawn at or am I bound to do this manually? edit: What was the point of editing my post @Suragch ? The easiest way is to define your font sizes in your resources with the units of scale-independent pixels ( sp ) -- this unit is like density independent pixels (

How to align text vertically?

你。 提交于 2019-11-28 16:58:46
Target: Android >= 1.6 on a pure Canvas. Suppose I want to write a function that will draw a (width, height) large red rectangle and then draw a black Hello World text inside. I want the text to be visually in the center of the rectangle. So let's try: void drawHelloRectangle(Canvas c, int topLeftX, int topLeftY, int width, int height) { Paint mPaint = new Paint(); // height of 'Hello World'; height*0.7 looks good int fontHeight = (int)(height*0.7); mPaint.setColor(COLOR_RED); mPaint.setStyle(Style.FILL); c.drawRect( topLeftX, topLeftY, topLeftX+width, topLeftY+height, mPaint); mPaint

How to align text vertically?

有些话、适合烂在心里 提交于 2019-11-28 16:39:01
问题 Target: Android >= 1.6 on a pure Canvas. Suppose I want to write a function that will draw a (width, height) large red rectangle and then draw a black Hello World text inside. I want the text to be visually in the center of the rectangle. So let's try: void drawHelloRectangle(Canvas c, int topLeftX, int topLeftY, int width, int height) { Paint mPaint = new Paint(); // height of 'Hello World'; height*0.7 looks good int fontHeight = (int)(height*0.7); mPaint.setColor(COLOR_RED); mPaint.setStyle

How to draw large sized text on a canvas?

不问归期 提交于 2019-11-28 11:33:11
I want to draw on canvas month's text vertical along screen height. Paint init: this.paint = new Paint(); this.paint.setAntiAlias(true); this.paint.setDither(true); this.paint.setSubpixelText(true); this.paint.setColor(color_text_dark); this.paint.setTextAlign(Align.RIGHT); Drawing: // Set the scale to the widest month float scale = getHeight() / this.max_month_width; String month_string = FULL_MONTH_NAME_FORMATTER. format(active_month_calendar.getTime()); canvas.save(); canvas.translate(getWidth(), 0); canvas.rotate(-90); canvas.scale(scale, scale); canvas.drawText(month_string, 0, 0, this

ffmpeg moving text drawtext

佐手、 提交于 2019-11-28 02:17:53
I'm using ffmpeg library to draw text on video in specific time and i'm success to do that Now i need to move the text from position to another and i can't do that so can any one suggest me how to do that i'm using this command to move text from top to down but i can't determine the x and Y to move from the x,y to specific x,y ffmpeg -i VideoInput.mp4 -vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf:text='Test test':x=(w-text_w)/2:y=w/50\*mod(t\,2):fontsize=65" -acodec copy outputVideo.mp4 Use ffmpeg -i VideoInput.mp4 \ -vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf

Android: Canvas.drawText() text size on different screen resolutions

坚强是说给别人听的谎言 提交于 2019-11-27 20:16:43
问题 For my Android game I have some calls to Canvas.drawText() . For testing, I use the standard font size which seems to be working fine. However, when I bump up the resolution to a higher density, the larger images are automatically loaded but the text is now incredibly small. Is there an easy way to calculate what size the text should be drawn at or am I bound to do this manually? edit: What was the point of editing my post @Suragch ? 回答1: The easiest way is to define your font sizes in your

The reason behind slow performance in WPF

醉酒当歌 提交于 2019-11-27 13:11:29
问题 I'm creating a large number of texts in WPF using DrawText and then adding them to a single Canvas . I need to redraw the screen in each MouseWheel event and I realized that the performance is a bit slow, so I measured the time the objects are created and it was less than 1 milliseconds! So what could be the problem? A long time ago I guess I read somewhere that it actually is the Rendering that takes the time, not creating and adding the visuals. Here is the code I'm using to create the text

Android 4.2 on Nexus 7: canvas.drawText() not working correctly

血红的双手。 提交于 2019-11-27 09:07:49
I'm facing a serious issue with my Application, published on Google Play and apparently working fine on all versions of Android except for > 4.0. This is a screenshoot from my Android 4.0 HTC phone: And this is what I get on Nexus 7, Android 4.2.1 (same behaviour in the emulator): I see the same behaviour for each text drawn using canvas.drawText() the Paint used to draw text is: paint = new Paint(); paint.setAntiAlias(true); paint.setColor(color); //some color paint.setTextSize(size); //some size paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextAlign(Align.CENTER); In

How to draw large sized text on a canvas?

独自空忆成欢 提交于 2019-11-27 06:15:40
问题 I want to draw on canvas month's text vertical along screen height. Paint init: this.paint = new Paint(); this.paint.setAntiAlias(true); this.paint.setDither(true); this.paint.setSubpixelText(true); this.paint.setColor(color_text_dark); this.paint.setTextAlign(Align.RIGHT); Drawing: // Set the scale to the widest month float scale = getHeight() / this.max_month_width; String month_string = FULL_MONTH_NAME_FORMATTER. format(active_month_calendar.getTime()); canvas.save(); canvas.translate