Android grave accent isn't shown on canvas, when hardware accelerate is true - android-canvas

everyone.
This is my first question in stackoverflow.
I hope you understand my poor English.
I found strange issue on drawing grave accent on canvas. I have been testing that drawing text on canvas on android, then I realize that hardware accelerated canvas doesn't draw few grave accents.
Here is codes and properties.
hardwareAccelerated : true
canvas.drawText("\u0E36", 100, 100, paint);
canvas.drawText("isHardwareAccelerated : " + isHardwareAccelerated(), 150, 200, paint);
above codes doesn't draw \u0E36 character on canvas.
hardwareAccelerated : false, Unicode with space(or any string)
canvas.drawText(" \u0E36", 100, 100, paint);
canvas.drawText("isHardwareAccelerated : " + isHardwareAccelerated(), 150, 200, paint);
above codes draw \u0E36 character on canvas.
hardwareAccelerated : false
canvas.drawText("\u0E36", 100, 100, paint);
canvas.drawText("isHardwareAccelerated : " + isHardwareAccelerated(), 150, 200, paint);
above codes draw \u0E36 character on canvas.
I realized that when I set hardware acceleration true, grave accents doesn't shown without string.
but, if I put any characters or space just before the grave accent, it works.
and, if I set hardware acceleration false, canvas draws grave accents without any string.
My question is that why canvas doesn't draw grave accents when canvas is hardware accelerated?
I could guess it is related with hardware rendering and software rendering.
But I don't know exactly why.
here is what I want to draw on canvas with hardware acceleration.
It's Thai character. and I found some latin grave accents also doesn't shown on canvas.
http://www.unicodemap.org/details/0x0E36/index.html
My reputation points is 0, so I can't post pictures of them.
I hope you guys understand my poor English.

Related

Qt5 QtChart drop vertical lines while using QScatterSeries

When I am using QScatterSeries, I can very easily draw point at (x, y). However, instead of points I would like to draw short lines, like in the figure below. How can I get about doing so?
I tried using RectangleMarker, but it just draws a fat square. I would prefer a thin line about 2px wide and 20px in height.
Is there a way I can add custom marker shapes?
Here are the code and the settings I use to transform my points into lines :
//create scatter series to draw point
m_pSeries1 = new QtCharts::QScatterSeries();
m_pSeries1->setName("trig");
m_pSeries1->setMarkerSize(100.0);
//draw a thin rectangle (50 to 50)
QPainterPath linePath;
linePath.moveTo(50, 0);
linePath.lineTo(50, 100);
linePath.closeSubpath();
//adapt the size of the image with the size of your rectangle
QImage line1(100, 100, QImage::Format_ARGB32);
line1.fill(Qt::transparent);
QPainter painter1(&line1);
painter1.setRenderHint(QPainter::Antialiasing);
painter1.setPen(QColor(0, 0, 0));
painter1.setBrush(painter1.pen().color());
painter1.drawPath(linePath);
//attach your image of rectangle to your series
m_pSeries1->setBrush(line1);
m_pSeries1->setPen(QColor(Qt::transparent));
//then use the classic QtChart pipeline...
You can play the marker size, the dimension of the image and the drawing pattern in the painter to adapt the size and shape of the rectangle to obtain a line.
In the picture, it's the black line. As you can see you can repeat the process for other series.
Keep in mind that you cannot use the openGL acceleration:
m_pSeries0->setUseOpenGL(true);
My work is based on the QtCharts/QScatterSeries example : QScatterSeries example
Hope it will help you.
Florian

Gtkmm : Color swap while drawing a line on drawing area

I am drawing a simple straight line on an image which is already drawn at the drawing area.
But at one unix machine, the drawn line in black color instead of red color.
Following is the piece of code to draw straight line:
Gdk::Color red("red");
//winPtr is type of Gtk::Window*
Glib::RefPtr<Gdk::GC> gc = winPtr->get_window()->get_style()->get_white_gc();
gc->set_line_attributes ( 2, (Gdk::LineStyle)0, (Gdk::CapStyle)2, (Gdk::JoinStyle)1);
Glib::RefPtr<Gdk::Visual> some_visual;
some_visual = Gdk::Visual::get_best();
Glib::RefPtr<Gdk::Colormap> some_colormap = Gdk::Colormap::create(some_visual, true);
some_colormap->alloc_color (red, false, true);
gc->set_colormap(some_colormap);
gc->set_foreground(red);
imgDispArea->get_window()->draw_line ( gc, 100, 100, 200, 200);
PS : -- Where "imgDispArea" is a type Gtk::DrawingArea*
Any help is appreciated.
My best guess here is that the problematic unix machine the X11 rgb.txt file is different. Per the GdkColor documentation:
The string can either one of a large set of standard names (taken from the X11 rgb.txt file) or ...
My suggestion would be to specify the color as "#FF0000" rather than "red".

How to rotate text and images in a rotated PDF?

I am editing PDFs using PDFsharp (editing in the sense of adding images, text etc.), and that works perfectly well.
gfx.DrawImage(img, pointX, pointY, width, height);
gfx.DrawString(text, thumbFont, XBrushes.Black,
new XRect(pointX + 10, pointY + height + 2, width - 10, 5), XStringFormats.TopLeft);
But when I am trying to edit a PDF which has Rotate property as 270, the added text, images are coming horizontally.
The actual problem that I am facing is, the PDF is not actually rotated, it just changes the Page.Rotate property, so my question is how to add text and image at the correct co-ordinate and in correct orientation to have rotation of 270.
The rotation is applied to the page at display time. 270° clockwise are 90° counter-clockwise.
AFAIK you have to rotate the text you are adding to the PDF 270° CCW (90° CW) so the text shows normally on the rotated PDF page.

OpenGL prevent stretching on window resize

I have a ortho set up at the moment for 2D, when I resize the window it stretches anything that is drawn in the window, is there a way to either just have black bars show when the window is resized or at least maintain the aspect ratio of the contents, so they dont stretch at all. I have tried a few implementations that I have seen on here, but nothing really works.
EDIT: Sorry guys had a bit of a blonde moment
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
GL.Viewport(0, 0, Width, Height)
GL.MatrixMode(MatrixMode.Projection)
GL.LoadIdentity()
GL.Ortho(-1.0, testvalue, testvalue , 1.0, 0.0, 4.0)
End Sub
testvalue at the moment is 5000, window size is 800x800
I figured out what I had to do. Rather than utilizing the aspect ratio on the Ortho part, I used it on the view port as such:
Dim ar As Single = Width/Height
GL.Viewport( 0, 0, 800 * ar, 800 * ar)
This prevents all stretching and simply places a black bar on the right hand side when the width is greater than height.
When you resize, Windows creates its own message pump to handle events, bypassing your message pump. There are work-arounds (hacks) to get it to render whilst sizing, including running your update/rendering on a thread. Note that this is a problem for D3D as well as OpenGL.
There's a discussion here on an old Gamedev thread.
the ortho command comprises of: the following parameters: left, right, bottom, top, zNear, zFar further info: http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml
You will want to plug in your 'Width' into right and your 'Height' into bottom and ensure the Width and Height values reflect the new window size.
E.g.:
GL.Viewport(0, 0, Width, Height)
GL.MatrixMode(MatrixMode.Projection)
GL.LoadIdentity()
GL.Ortho(0.0, Width, Height, 0.0, 1.0, 2.0)
Since you're only after 2D your zNear and zFar can be quite small, just make sure to render between zNear and zFar and do not use 0.0 as your zNear, I would recommend using 0.1 or larger for your zNear.

List bullet size

How to increase the size of a list bullet? I am using ""\u2023 ABC" and applying style with font size :16. However the bullet size does not scale and only the font size scales.
"\u2023"= unicode for the bullet
Prasad, size of the bullet is also increasing with respect to the font size. But the probelm is the size of the bullet is small compared to the text. Please refer the screenshots I've taken in iPhone simulator with different font size
The above in the above images, each of them has font sizes 16, 30 and 80 respectively. You can see that the arrow size is also increasing with respect to the font size.
And here is a working solution for you.
Here I've used two labels - one for the arrow and other for the city name having a font size 40 and 20 respectively, added them to the tableViewRow. You can change the font size as per your requirement
Here is my code
for(var i = 0 ; i < number_of_cities; i++ ){
var lblArrow = Ti.UI.createLabel({
text : "\u2023",
font : {fontSize : 40},
left : '3%'
});
var lblValue = Ti.UI.createLabel({
text : cityList[i].name,
font : {fontSize : 20},
left : '10%'
});
tblData[i] = Ti.UI.createTableViewRow();
tblData[i].add(lblArrow);
tblData[i].add(lblValue);
}
Please note : I'm not sure that it's a best method, but it will resolve your issue
There are numerous variations of Unicode bullets and a quick visit to
Geometric Shapes is always useful. My personal favorite is "Black Circle" which, as with so much of Unicode, may be many things but a circle it is not.
● is a nice fat bullet — a bullet with attitude. In Hex it is ● and parsed for the purposes of list styling written as "\25AC" in the content value of your li:before tag:
li:before {
content: "\25AC";
etc.