Konva Text : While using emoji in text, it renders as a line text instead of a filled emoji - konvajs

let complexText = new Konva.Text({
x: 0,
y: 0,
text: "๐Ÿ”‘ hello World ๐Ÿค—",
fontSize: 12,
fill: "#003049",
width: stage.width() - 10,
padding: 5,
align: "center",Received output
});
Expected Output:๐Ÿ”‘ hello World ๐Ÿค—

Emoji's are not available in all fonts. Look on the web for lists of emoji fonts such as: https://typography.guru/list/topic/emoji-fonts/.
But be aware that the emoji font maybe will not also provide letter characters - it might just be smileys only. You will have to create text nodes for each of the emojis and the text segments.

Related

how to make text vertically center in fabric js TextBox

I am working on one fabric js editor, in which I need to implement TextBox as a Button look and feel,
For that, I Have implemented TextBox with Background, But Problem is that Height of TextBox.
I am trying this kind of code :
var text = new fabric.Textbox("this is text", {
top: 0,
left: 0,
width: 300,
height: 500,
fill: 'red'
})
canvas.add(text);
Now my Textbox is rendered of width: 300 but height is not rendered. how can I set Height to My TextBox
And another Thing, when I set Height to TextBox, I need to keep text in Center of height (vertical center)
what should I do, I can't understand, how to override default fabtic.Textbox class.
Please help me, If any one have Any suggestion.

How can I show fraction number use Konva.Text

I want to show a fraction number (e.g. 2ยผ) in canvas using Konva.Text?
You can use just that Unicode as text:
const shape = new Konva.Text({
x: 10,
y: 10,
text: '2ยผ',
});
layer.add(shape);
Or you can make your own solution. Basically, it is just two numbers with a line.

How to use lineBreak inside the beforePageContent in jspdf autoTable

i'm using overFlow : linebreak in my program .And it work's fine this is my code ,
styles: {
fillStyle: 'DF',
overflow: 'linebreak',
columnWidth: 110,
lineWidth: 2,
lineColor: [85, 51, 27]
}
But that doesn't reflect inside the beforePageContent , Here is that code ,
beforePageContent: function(data) {
doc.setFontSize(12);
doc.setFont("courier");
doc.text("Process Name :",20 ,15);
doc.setFontStyle('bold');
//doc.overflow('linebreak');
doc.setFontStyle('normal');
doc.text("Description :"+sampData, 20, 30);
},
So how can i use lineBreak inside my beforePageContent block .
The overflow: linebreak; style is only for jspdf-autotable. In the hooks you are using pure jspdf and need to use jspdf methods. There are two functions that you are probably going to be helpful. The first one is doc.getStringUnitWidth("hello") and the second is doc.splitTextToSize("A longer title that might be split", 50).
Example 1:
var strArr = doc.splitTextToSize("A longer title that might be split", 50)
doc.text(strArr, 50, 50);
Example 2:
var str = "A longer title that /n is split";
doc.text(str, 50, 50);

Use attributed string with combined attributes hides last line of label

I'm adding a label as attributed string to my iPhone app. I want to use two attributes; Ti.UI.ATTRIBUTE_BASELINE_OFFSET and Ti.UI.ATTRIBUTE_FONT.
When I use those attributes apart, they both work fine. But when I combine them into one attributed string, my last line of text disappears and gets truncated. See my code below:
var attributedString = Ti.UI.createAttributedString({
text: text,
attributes: [
{
type: Ti.UI.ATTRIBUTE_BASELINE_OFFSET,
value: attributeBaseLineOffset,
range: [0, text.length]
},
{
type: Ti.UI.ATTRIBUTE_FONT,
value: {fontFamily: "Dosis-Bold", fontSize: "16dp"},
range: [5,10]
}
]
});
When I use the debug mode on the iOS simulator, I can see the height of the label gets adjusted to the first attribute(the baseline offset). However the font attributed adds a little extra padding at the top of the label, which is just enough to push the last line of text outside the label container and then it truncates.
As a workaround I tried setting the label height manually, but this has no effect.
Does anyone know how to stop the truncating and show my full text in the label?
This is an easy fix. Depending not the string length, the choice is really whether to use Ti.UI.Label vs Ti.UI.TextArea. Of course you can always use a TextArea everywhere if needed in place of Label.
Check out the following example, which should handle what your looking for using TextArea instead of Label.
var text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';
var attributedString = Ti.UI.createAttributedString({
text: text,
attributes: [
{
type: Ti.UI.ATTRIBUTE_BASELINE_OFFSET,
value: 25,
range: [0, text.length]
},
{
type: Ti.UI.ATTRIBUTE_FONT,
value: {fontFamily: "Dosis-Bold", fontSize: "16dp"},
range: [5,10]
}
]
});
var label = Titanium.UI.createTextArea({
left: 20,
right: 20,
height: Titanium.UI.SIZE,
borderWidth:1,
borderColor: "#ececec",
attributedString: attributedString
});
$.theView.add(label);
I don't know your text string / use case so can't certain, but this should work with your needs

What's "an array of ol.style.Style" good for?

A style of an ol.layer.Vector can be set as ol.style.Style, a style function or an array of ol.style.Style. What's the array for and what does it do -- compared to just passing an ol.style.Style object?
I cannot find any information on this, neither in the official API docs nor in the tutorials.
If you look at the draw features example, when drawing lines, they are displayed in blue with a white border/outline.
These is achieved by styling the line twice, first with a large white line, then a thin blue line above.
There are 2 styles for the same geometry. It canโ€™t be done with a single ol.style.Style, so to achieve this you need to pass an array of 2 styles: see the source for this.
Because I think this is still relevant and the edit queue is full for the approved answer, I'm posting this with the links updated and with code examples.
The most common way to see the array of styles in action is when drawing features since this is default style in Openlayers. For the line to appear blue with a white border it has to have two styles since it can't be done with a single Style. Openlayers does this by default like this:
styles['LineString'] = [
new Style({
stroke: new Stroke({
color: white,
width: width + 2,
}),
}),
new Style({
stroke: new Stroke({
color: blue,
width: width,
}),
}),
];
source
To expand on how usefull this feature could be you could check the custom polygons example. To have the vertices highlighted, they use two styles, one for the vertices and another for the polygon contour itself. Relevant piece of code:
const styles = [
new Style({
stroke: new Stroke({
color: 'blue',
width: 3,
}),
fill: new Fill({
color: 'rgba(0, 0, 255, 0.1)',
}),
}),
new Style({
image: new CircleStyle({
radius: 5,
fill: new Fill({
color: 'orange',
}),
}),
geometry: function (feature) {
// return the coordinates of the first ring of the polygon
const coordinates = feature.getGeometry().getCoordinates()[0];
return new MultiPoint(coordinates);
},
}),
];

Resources